Unverified Commit c04fbc92 authored by Artur Wojcik's avatar Artur Wojcik Committed by GitHub
Browse files

export API symbols from dynamic libraries (#1892)

Export API symbols for migraphx, migraphx_ref, migraphx_cpu, migrphx_gpu, migraphx_device, migraphx_tf, and migraphx_onnx. There is a separate PR for migrahx_c.

API symbol exporting affects only Windows. It is transparent on Linux.
parent c88d4a54
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#define MIGRAPHX_GUARD_RTGLIB_PACK_INT8_ARGS_HPP #define MIGRAPHX_GUARD_RTGLIB_PACK_INT8_ARGS_HPP
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/config.hpp>
#include <migraphx/gpu/context.hpp> #include <migraphx/gpu/context.hpp>
namespace migraphx { namespace migraphx {
...@@ -33,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -33,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
struct pack_int8_args struct MIGRAPHX_GPU_EXPORT pack_int8_args
{ {
std::string name() const { return "gpu::pack_int8_args"; } std::string name() const { return "gpu::pack_int8_args"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef MIGRAPHX_GUARD_MIGRAPHLIB_ROCBLAS_HPP #ifndef MIGRAPHX_GUARD_MIGRAPHLIB_ROCBLAS_HPP
#define MIGRAPHX_GUARD_MIGRAPHLIB_ROCBLAS_HPP #define MIGRAPHX_GUARD_MIGRAPHLIB_ROCBLAS_HPP
#include <migraphx/manage_ptr.hpp> #include <migraphx/manage_ptr.hpp>
#include <migraphx/config.hpp> #include <migraphx/gpu/config.hpp>
#include <rocblas/rocblas.h> #include <rocblas/rocblas.h>
namespace migraphx { namespace migraphx {
...@@ -38,9 +38,10 @@ rocblas_handle_ptr create_rocblas_handle_ptr(hipStream_t s); ...@@ -38,9 +38,10 @@ rocblas_handle_ptr create_rocblas_handle_ptr(hipStream_t s);
struct context; struct context;
bool get_compute_fp32_flag(); MIGRAPHX_GPU_EXPORT bool get_compute_fp32_flag();
MIGRAPHX_GPU_EXPORT bool get_int8_x4_format(context& ctx);
bool get_int8_x4_format(context& ctx);
} // namespace gpu } // namespace gpu
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/compile_options.hpp> #include <migraphx/compile_options.hpp>
#include <migraphx/config.hpp> #include <migraphx/gpu/config.hpp>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
struct target struct MIGRAPHX_GPU_EXPORT target
{ {
std::string name() const; std::string name() const;
std::vector<pass> get_passes(migraphx::context& gctx, const compile_options& options) const; std::vector<pass> get_passes(migraphx::context& gctx, const compile_options& options) const;
......
...@@ -32,7 +32,7 @@ namespace migraphx { ...@@ -32,7 +32,7 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
std::pair<double, double> MIGRAPHX_GPU_EXPORT std::pair<double, double>
time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n = 100); time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n = 100);
} // namespace gpu } // namespace gpu
......
...@@ -32,7 +32,7 @@ struct module; ...@@ -32,7 +32,7 @@ struct module;
namespace gpu { namespace gpu {
struct write_literals struct MIGRAPHX_GPU_EXPORT write_literals
{ {
context* ctx = nullptr; context* ctx = nullptr;
std::string name() const { return "gpu::write_literals"; } std::string name() const { return "gpu::write_literals"; }
......
...@@ -37,6 +37,8 @@ target_link_libraries(migraphx_ref PUBLIC migraphx) ...@@ -37,6 +37,8 @@ target_link_libraries(migraphx_ref PUBLIC migraphx)
target_include_directories(migraphx_ref PRIVATE ${BLAZE_INCLUDE}) target_include_directories(migraphx_ref PRIVATE ${BLAZE_INCLUDE})
target_compile_definitions(migraphx_ref PRIVATE -DBLAZE_USE_CPP_THREADS) target_compile_definitions(migraphx_ref PRIVATE -DBLAZE_USE_CPP_THREADS)
migraphx_generate_export_header(migraphx_ref)
rocm_install_targets( rocm_install_targets(
TARGETS migraphx_ref TARGETS migraphx_ref
INCLUDE INCLUDE
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define MIGRAPHX_GUARD_RTGLIB_CONTEXT_HPP #define MIGRAPHX_GUARD_RTGLIB_CONTEXT_HPP
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#include <migraphx/ref/export.h>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
......
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
#ifndef MIGRAPHX_GUARD_RTGLIB_CPU_LOWERING_HPP #ifndef MIGRAPHX_GUARD_RTGLIB_CPU_LOWERING_HPP
#define MIGRAPHX_GUARD_RTGLIB_CPU_LOWERING_HPP #define MIGRAPHX_GUARD_RTGLIB_CPU_LOWERING_HPP
#include <migraphx/ref/context.hpp>
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/config.hpp>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace ref { namespace ref {
struct lowering struct MIGRAPHX_REF_EXPORT lowering
{ {
std::string name() const { return "ref::lowering"; } std::string name() const { return "ref::lowering"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct pass; struct pass;
namespace ref { namespace ref {
struct target struct MIGRAPHX_REF_EXPORT target
{ {
std::string name() const; std::string name() const;
std::vector<pass> get_passes(migraphx::context& ctx, const compile_options&) const; std::vector<pass> get_passes(migraphx::context& ctx, const compile_options&) const;
......
...@@ -44,6 +44,7 @@ set_target_properties(tf-proto PROPERTIES POSITION_INDEPENDENT_CODE On) ...@@ -44,6 +44,7 @@ set_target_properties(tf-proto PROPERTIES POSITION_INDEPENDENT_CODE On)
file(GLOB TF_SRCS ${CONFIGURE_DEPENDS} *.cpp) file(GLOB TF_SRCS ${CONFIGURE_DEPENDS} *.cpp)
add_library(migraphx_tf ${TF_SRCS}) add_library(migraphx_tf ${TF_SRCS})
migraphx_generate_export_header(migraphx_tf)
target_include_directories(migraphx_tf PRIVATE include) target_include_directories(migraphx_tf PRIVATE include)
set_target_properties(migraphx_tf PROPERTIES EXPORT_NAME tf) set_target_properties(migraphx_tf PROPERTIES EXPORT_NAME tf)
rocm_set_soversion(migraphx_tf ${MIGRAPHX_SO_VERSION}) rocm_set_soversion(migraphx_tf ${MIGRAPHX_SO_VERSION})
......
...@@ -228,7 +228,7 @@ function(test_headers PREFIX) ...@@ -228,7 +228,7 @@ function(test_headers PREFIX)
string(MAKE_C_IDENTIFIER ${HEADER_REL} TEST_NAME) string(MAKE_C_IDENTIFIER ${HEADER_REL} TEST_NAME)
get_filename_component(BASE_NAME ${HEADER} NAME_WE) get_filename_component(BASE_NAME ${HEADER} NAME_WE)
test_header(header_${TEST_NAME} ${PREFIX}/${BASE_NAME}.hpp) test_header(header_${TEST_NAME} ${PREFIX}/${BASE_NAME}.hpp)
target_link_libraries(header_${TEST_NAME} migraphx_all_targets) target_link_libraries(header_${TEST_NAME} migraphx migraphx_onnx migraphx_tf migraphx_all_targets)
endforeach() endforeach()
endfunction() endfunction()
......
...@@ -675,8 +675,8 @@ bool has_finalize(const T& x) ...@@ -675,8 +675,8 @@ bool has_finalize(const T& x)
return detail::has_finalize_op(x); return detail::has_finalize_op(x);
} }
void migraphx_to_value(value& v, const operation& op); MIGRAPHX_EXPORT void migraphx_to_value(value& v, const operation& op);
void migraphx_from_value(const value& v, operation& op); MIGRAPHX_EXPORT void migraphx_from_value(const value& v, operation& op);
#endif #endif
......
...@@ -57,7 +57,7 @@ struct pass ...@@ -57,7 +57,7 @@ struct pass
#else #else
module& get_module(module_pass_manager& mpm); MIGRAPHX_EXPORT module& get_module(module_pass_manager& mpm);
namespace detail { namespace detail {
......
...@@ -28,6 +28,8 @@ trivial = [ ...@@ -28,6 +28,8 @@ trivial = [
'bool', 'any_ptr' 'bool', 'any_ptr'
] ]
export_macro = 'MIGRAPHX_EXPORT'
headers = ''' headers = '''
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
...@@ -41,7 +43,7 @@ form = string.Template(''' ...@@ -41,7 +43,7 @@ form = string.Template('''
#ifdef TYPE_ERASED_DECLARATION #ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for: // Type-erased interface for:
struct ${struct_name} struct ${export_macro} ${struct_name}
{ {
${decl_members} ${decl_members}
}; };
...@@ -395,7 +397,8 @@ def generate_form(name, members): ...@@ -395,7 +397,8 @@ def generate_form(name, members):
default_members=''.join(default_members), default_members=''.join(default_members),
decl_members=''.join(decl_members), decl_members=''.join(decl_members),
comment_members='\n'.join(comment_members), comment_members='\n'.join(comment_members),
struct_name=name) struct_name=name,
export_macro=export_macro)
def virtual(name, returns=None, **kwargs): def virtual(name, returns=None, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment