Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export symbol from DLL in test_jit #2861

Merged
merged 18 commits into from
Jun 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert extra changes
apwojcik committed May 8, 2024
commit 6036acf562b9f27659bee1866e4ceba720af2f0b
7 changes: 3 additions & 4 deletions src/dynamic_loader.cpp
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
#include <migraphx/errors.hpp>
#include <migraphx/file_buffer.hpp>
#include <migraphx/tmp_dir.hpp>
#include <migraphx/stringutils.hpp>
#include <utility>

#ifdef _WIN32
@@ -183,17 +182,17 @@ dynamic_loader::dynamic_loader(const std::vector<char>& buffer)
{
}

std::shared_ptr<void> dynamic_loader::get_symbol(std::string_view name) const
std::shared_ptr<void> dynamic_loader::get_symbol(const std::string& name) const
{
#ifndef _WIN32
// flush any previous error messages
check_load_error(true);
void* symbol = dlsym(impl->handle.get(), name.data());
void* symbol = dlsym(impl->handle.get(), name.c_str());
if(symbol == nullptr)
check_load_error();
return {impl, symbol};
#else
FARPROC addr = GetProcAddress(impl->handle, name.data());
FARPROC addr = GetProcAddress(impl->handle, name.c_str());
if(addr == nullptr)
MIGRAPHX_THROW("Symbol not found: " + name + " (" + std::to_string(GetLastError()) + ")");
return {impl, reinterpret_cast<void*>(addr)};
6 changes: 3 additions & 3 deletions src/include/migraphx/dynamic_loader.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -54,10 +54,10 @@ struct MIGRAPHX_EXPORT dynamic_loader

dynamic_loader(const std::vector<char>& buffer);

std::shared_ptr<void> get_symbol(std::string_view name) const;
std::shared_ptr<void> get_symbol(const std::string& name) const;

template <class F>
std::function<F> get_function(std::string_view name) const
std::function<F> get_function(const std::string& name) const
{
auto s = get_symbol(name);
return [=](auto&&... xs) -> decltype(auto) {
6 changes: 0 additions & 6 deletions src/include/migraphx/stringutils.hpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@
#include <sstream>
#include <unordered_map>
#include <vector>
#include <string_view>
#include <migraphx/config.hpp>

namespace migraphx {
@@ -39,11 +38,6 @@ inline namespace MIGRAPHX_INLINE_NS {
#define MIGRAPHX_STRINGIZE_1(...) #__VA_ARGS__
#define MIGRAPHX_STRINGIZE(...) MIGRAPHX_STRINGIZE_1(__VA_ARGS__)

inline std::string operator+(std::string_view left, std::string_view right)
{
return std::string{left}.append(right);
}

template <class F>
auto with_char(F f)
{
2 changes: 1 addition & 1 deletion test/jit.cpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ const std::string_view preamble = R"migraphx(
)migraphx";

template <class F>
std::function<F> compile_function(std::string_view src, std::string_view symbol_name)
std::function<F> compile_function(std::string_view src, const std::string& symbol_name)
{
migraphx::src_compiler compiler;
compiler.flags.emplace_back("-std=c++14");