Skip to content

Commit

Permalink
Merge pull request #727 from pbalcer/adapters-map
Browse files Browse the repository at this point in the history
[adapters] only export get proc table symbols in adapters
  • Loading branch information
pbalcer authored Jul 21, 2023
2 parents 8af5a83 + e97c22d commit 16a0354
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 17 deletions.
24 changes: 23 additions & 1 deletion source/adapters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,30 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

add_subdirectory(null)
function(add_ur_adapter name)
add_library(${name} ${ARGN})
if(MSVC)
set(TARGET_LIBNAME ${name})
string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME)

set(ADAPTER_VERSION_SCRIPT ${name}.def)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.def.in ${ADAPTER_VERSION_SCRIPT} @ONLY)
set_target_properties(${name} PROPERTIES
LINK_FLAGS "/DEF:${ADAPTER_VERSION_SCRIPT}"
)
else()
set(TARGET_LIBNAME lib${name}_${PROJECT_VERSION_MAJOR}.0)
string(TOUPPER ${TARGET_LIBNAME} TARGET_LIBNAME)

set(ADAPTER_VERSION_SCRIPT ${name}.map)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../adapter.map.in ${ADAPTER_VERSION_SCRIPT} @ONLY)
target_link_options(${name} PRIVATE "-Wl,--version-script=${ADAPTER_VERSION_SCRIPT}")
endif()
endfunction()

add_subdirectory(null)

if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_HIP)
# fetch adapter sources from SYCL
Expand Down
20 changes: 20 additions & 0 deletions source/adapters/adapter.def.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
LIBRARY @TARGET_LIBNAME@
EXPORTS
urGetBindlessImagesExpProcAddrTable
urGetCommandBufferExpProcAddrTable
urGetContextProcAddrTable
urGetDeviceProcAddrTable
urGetEnqueueProcAddrTable
urGetEventProcAddrTable
urGetGlobalProcAddrTable
urGetKernelProcAddrTable
urGetMemProcAddrTable
urGetPhysicalMemProcAddrTable
urGetPlatformProcAddrTable
urGetProgramProcAddrTable
urGetQueueProcAddrTable
urGetSamplerProcAddrTable
urGetUSMExpProcAddrTable
urGetUsmP2PExpProcAddrTable
urGetUSMProcAddrTable
urGetVirtualMemProcAddrTable
23 changes: 23 additions & 0 deletions source/adapters/adapter.map.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@TARGET_LIBNAME@ {
global:
urGetBindlessImagesExpProcAddrTable;
urGetCommandBufferExpProcAddrTable;
urGetContextProcAddrTable;
urGetDeviceProcAddrTable;
urGetEnqueueProcAddrTable;
urGetEventProcAddrTable;
urGetGlobalProcAddrTable;
urGetKernelProcAddrTable;
urGetMemProcAddrTable;
urGetPhysicalMemProcAddrTable;
urGetPlatformProcAddrTable;
urGetProgramProcAddrTable;
urGetQueueProcAddrTable;
urGetSamplerProcAddrTable;
urGetUSMExpProcAddrTable;
urGetUsmP2PExpProcAddrTable;
urGetUSMProcAddrTable;
urGetVirtualMemProcAddrTable;
local:
*;
};
2 changes: 1 addition & 1 deletion source/adapters/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CUDA_DIR "${SYCL_ADAPTER_DIR}/sycl/plugins/unified_runtime/ur/adapters/cuda"

set(TARGET_NAME ur_adapter_cuda)

add_library(${TARGET_NAME}
add_ur_adapter(${TARGET_NAME}
SHARED
${CUDA_DIR}/ur_interface_loader.cpp
${CUDA_DIR}/common.hpp
Expand Down
4 changes: 2 additions & 2 deletions source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif()
# Set includes used in added library (rocmdrv)
set(HIP_HEADERS "${UR_HIP_INCLUDE_DIR};${UR_HIP_HSA_INCLUDE_DIR}")

add_library(${TARGET_NAME}
add_ur_adapter(${TARGET_NAME}
SHARED
${HIP_DIR}/ur_interface_loader.cpp
${HIP_DIR}/common.hpp
Expand Down Expand Up @@ -75,7 +75,7 @@ add_library(${TARGET_NAME}
${HIP_DIR}/../../usm_allocator_config.hpp
)

if (NOT MSVC)
if(NOT MSVC)
target_compile_options(${TARGET_NAME} PRIVATE
-Wno-deprecated-declarations
)
Expand Down
8 changes: 1 addition & 7 deletions source/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ target_include_directories(LevelZeroLoader-Headers
INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}"
)

add_library(${TARGET_NAME}
add_ur_adapter(${TARGET_NAME}
SHARED
${L0_DIR}/ur_interface_loader.cpp
${L0_DIR}/common.hpp
Expand Down Expand Up @@ -120,9 +120,3 @@ target_include_directories(${TARGET_NAME} PRIVATE
${L0_DIR}/../../../
LevelZeroLoader-Headers
)

if(UNIX)
set(GCC_COVERAGE_COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
endif()

7 changes: 1 addition & 6 deletions source/adapters/null/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set(TARGET_NAME ur_adapter_null)

add_library(${TARGET_NAME}
add_ur_adapter(${TARGET_NAME}
SHARED
${CMAKE_CURRENT_SOURCE_DIR}/ur_null.hpp
${CMAKE_CURRENT_SOURCE_DIR}/ur_null.cpp
Expand All @@ -21,8 +21,3 @@ target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_NAME}::headers
${PROJECT_NAME}::common
)

if(UNIX)
set(GCC_COVERAGE_COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
endif()

0 comments on commit 16a0354

Please sign in to comment.