Solve issues with hip-vdi runtime static lib

1.Combine libamdhip64_static_base.a and libamdvdi_static.a into libamdhip64_static.a.
2.Let hipcc use -use-staticlib to link libamdhip64_static.a.
3.Add some samples for static lib.
4.Fix compiling failure of code object.
Change-Id: Ia2333622a8d05639b90974c4c5d3d85654ba0138


[ROCm/hip commit: 4c2ab3f41e]
This commit is contained in:
Tao Sang
2020-04-06 09:58:35 -04:00
committed by Tao Sang
parent f89fcad87d
commit 8a42ac4d03
6 changed files with 46 additions and 13 deletions
+18 -5
View File
@@ -152,21 +152,33 @@ add_library(amdhip64 SHARED
$<TARGET_OBJECTS:hip64>
)
add_library(amdhip64_static STATIC
add_library(amdhip64_static_base STATIC
$<TARGET_OBJECTS:hip64>
)
add_library(host INTERFACE)
target_link_libraries(host INTERFACE amdhip64)
target_link_libraries(host INTERFACE amdhip64_static_base)
add_library(device INTERFACE)
target_link_libraries(device INTERFACE host)
target_link_libraries(amdhip64_static PRIVATE amdvdi_static pthread dl)
target_link_libraries(amdhip64_static_base PRIVATE amdvdi_static pthread dl)
target_link_libraries(amdhip64 PRIVATE amdvdi_static pthread dl)
set(STATICLIBNAME "${hip_BINARY_DIR}/lib/libamdhip64_static.a")
add_custom_command(
OUTPUT ${STATICLIBNAME}
COMMAND rm -f ${STATICLIBNAME}
COMMAND ${CMAKE_AR} -rcsT ${STATICLIBNAME} $<TARGET_FILE:amdhip64_static_base> $<TARGET_FILE:amdvdi_static>
DEPENDS amdhip64_static_base amdvdi_static
COMMENT "Combining static libs into ${STATICLIBNAME} "
)
add_custom_target(amdhip64_static ALL
DEPENDS ${STATICLIBNAME}
)
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64_static> DESTINATION lib COMPONENT MAIN)
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64> DESTINATION lib COMPONENT MAIN)
INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhip_hcc.so )" DESTINATION lib COMPONENT MAIN)
INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhiprtc.so )" DESTINATION lib COMPONENT MAIN)
@@ -174,6 +186,7 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhip_hcc.so DESTINATION lib COMPONENT MA
INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhiprtc.so DESTINATION lib COMPONENT MAIN)
INSTALL(TARGETS amdhip64_static amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR})
INSTALL(PROGRAMS ${STATICLIBNAME} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(TARGETS amdhip64_static_base amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR})
INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::)
+6
View File
@@ -132,6 +132,7 @@ namespace hip {
extern void init();
extern Device* getCurrentDevice();
extern void setCurrentDevice(unsigned int index);
/// Get VDI queue associated with hipStream
@@ -255,6 +256,11 @@ private:
~PlatformState() {}
public:
static PlatformState& instance() {
if (platform_ == nullptr) {
// __hipRegisterFatBinary() will call this when app starts, thus
// there is no multiple entry issue here.
platform_ = new PlatformState();
}
return *platform_;
}
+1 -1
View File
@@ -30,7 +30,7 @@
constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF"
thread_local std::stack<ihipExec_t> execStack_;
PlatformState* PlatformState::platform_ = new PlatformState();
PlatformState* PlatformState::platform_ = nullptr;
struct __CudaFatBinaryWrapper {
unsigned int magic;