Skip to content

remove optional symbols #799

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 0 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,29 +423,6 @@ if((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER)
# TODO do the same for ze_loader
endif()

# set optional symbols for map/def files
#
# TODO: ref. #649
set(UMF_OPTIONAL_SYMBOLS_LINUX "")
set(UMF_OPTIONAL_SYMBOLS_WINDOWS "")

if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
add_optional_symbol(umfLevelZeroMemoryProviderOps)
endif()

# Conditional configuration for CUDA provider
if(UMF_BUILD_CUDA_PROVIDER)
add_optional_symbol(umfCUDAMemoryProviderOps)
endif()

if(NOT UMF_DISABLE_HWLOC)
add_optional_symbol(umfOsMemoryProviderOps)
if(LINUX)
add_optional_symbol(umfDevDaxMemoryProviderOps)
add_optional_symbol(umfFileMemoryProviderOps)
endif()
endif()

add_subdirectory(src)

if(UMF_BUILD_TESTS)
Expand Down
9 changes: 0 additions & 9 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,3 @@ macro(add_sanitizer_flag flag)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
endmacro()

function(add_optional_symbol symbol)
set(UMF_OPTIONAL_SYMBOLS_WINDOWS
"${UMF_OPTIONAL_SYMBOLS_WINDOWS} \n ${symbol}"
PARENT_SCOPE)
set(UMF_OPTIONAL_SYMBOLS_LINUX
"${UMF_OPTIONAL_SYMBOLS_LINUX} \n ${symbol};"
PARENT_SCOPE)
endfunction()
91 changes: 33 additions & 58 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,69 +110,52 @@ set(UMF_SOURCES
memtarget.c
mempolicy.c
memspace.c
memspaces/memspace_host_all.c
memspaces/memspace_highest_capacity.c
memspaces/memspace_highest_bandwidth.c
memspaces/memspace_lowest_latency.c
memspaces/memspace_numa.c
provider/provider_cuda.c
provider/provider_devdax_memory.c
provider/provider_file_memory.c
provider/provider_level_zero.c
provider/provider_os_memory.c
provider/provider_tracking.c
critnib/critnib.c
ravl/ravl.c
pool/pool_proxy.c
pool/pool_scalable.c)

if(NOT UMF_DISABLE_HWLOC)
set(UMF_SOURCES ${UMF_SOURCES} ${HWLOC_DEPENDENT_SOURCES})
set(UMF_SOURCES ${UMF_SOURCES} ${HWLOC_DEPENDENT_SOURCES}
memtargets/memtarget_numa.c)
set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})
set(UMF_PRIVATE_LIBRARY_DIRS ${UMF_PRIVATE_LIBRARY_DIRS}
${LIBHWLOC_LIBRARY_DIRS})
else()
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_HWLOC=1")
endif()

set(UMF_SOURCES_LINUX libumf_linux.c)

set(UMF_SOURCES_MACOSX libumf_linux.c)

set(UMF_SOURCES_WINDOWS libumf_windows.c)

set(UMF_SOURCES_COMMON_LINUX_MACOSX
provider/provider_devdax_memory.c
provider/provider_file_memory.c
provider/provider_os_memory.c
memtargets/memtarget_numa.c
memspaces/memspace_numa.c
memspaces/memspace_host_all.c
memspaces/memspace_highest_capacity.c
memspaces/memspace_highest_bandwidth.c
memspaces/memspace_lowest_latency.c)

if(NOT UMF_DISABLE_HWLOC)
set(UMF_SOURCES_LINUX ${UMF_SOURCES_LINUX}
${UMF_SOURCES_COMMON_LINUX_MACOSX})

set(UMF_SOURCES_MACOSX ${UMF_SOURCES_MACOSX}
${UMF_SOURCES_COMMON_LINUX_MACOSX})

set(UMF_SOURCES_WINDOWS ${UMF_SOURCES_WINDOWS}
provider/provider_os_memory.c)

set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})

if(NOT WINDOWS)
add_optional_symbol(umfMemspaceCreateFromNumaArray)
add_optional_symbol(umfMemspaceHighestBandwidthGet)
add_optional_symbol(umfMemspaceHighestCapacityGet)
add_optional_symbol(umfMemspaceHostAllGet)
add_optional_symbol(umfMemspaceLowestLatencyGet)
endif()
# Add compile definitions to handle unsupported functions
if(NOT UMF_BUILD_CUDA_PROVIDER)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_CUDA_PROVIDER=1")
endif()

if(WINDOWS)
message(STATUS "UMF_OPTIONAL_SYMBOLS: ${UMF_OPTIONAL_SYMBOLS_WINDOWS}")
else()
message(STATUS "UMF_OPTIONAL_SYMBOLS: ${UMF_OPTIONAL_SYMBOLS_LINUX}")
if(NOT UMF_BUILD_LEVEL_ZERO_PROVIDER)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_LEVEL_ZERO_PROVIDER=1")
endif()
if(UMF_DISABLE_HWLOC OR WINDOWS)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_DEVDAX_PROVIDER=1")
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_FILE_PROVIDER=1")
endif()

# Configure map/def files with optional symbols
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libumf.def.in"
"${CMAKE_CURRENT_BINARY_DIR}/libumf.def" @ONLY)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libumf.map.in"
"${CMAKE_CURRENT_BINARY_DIR}/libumf.map" @ONLY)

set(UMF_PRIVATE_LIBRARY_DIRS ${UMF_PRIVATE_LIBRARY_DIRS}
${LIBHWLOC_LIBRARY_DIRS})

if(LINUX)
set(UMF_SOURCES ${UMF_SOURCES} ${UMF_SOURCES_LINUX})
Expand All @@ -197,8 +180,8 @@ if(UMF_BUILD_SHARED_LIBRARY)
TYPE SHARED
SRCS ${UMF_SOURCES}
LIBS ${UMF_LIBS} ${HWLOC_LIB}
LINUX_MAP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def)
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.def)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_SHARED_LIBRARY")
set_target_properties(
Expand All @@ -214,11 +197,6 @@ else()
LIBS ${UMF_LIBS})
endif()

if(UMF_DISABLE_HWLOC)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
UMF_NO_HWLOC=1)
endif()

if(UMF_LINK_HWLOC_STATICALLY)
add_dependencies(umf ${UMF_HWLOC_NAME})
endif()
Expand All @@ -228,8 +206,6 @@ target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})
target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})

if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
target_sources(umf PRIVATE provider/provider_level_zero.c)

if(LINUX)
# WA for error ze_api.h:14234:20: no newline at end of file
# [-Werror,-Wnewline-eof]
Expand All @@ -243,7 +219,6 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
endif()

if(UMF_BUILD_CUDA_PROVIDER)
target_sources(umf PRIVATE provider/provider_cuda.c)
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
"UMF_BUILD_CUDA_PROVIDER=1")
endif()
Expand Down
15 changes: 12 additions & 3 deletions src/libumf.def.in → src/libumf.def
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ EXPORTS
umfTearDown
umfGetCurrentVersion
umfCloseIPCHandle
umfCUDAMemoryProviderOps
umfDevDaxMemoryProviderOps
umfFree
umfFileMemoryProviderOps
umfGetIPCHandle
umfGetLastFailedMemoryProvider
umfMemoryTrackerGetAllocInfo
umfLevelZeroMemoryProviderOps
umfMemoryProviderAlloc
umfMemoryProviderAllocationMerge
umfMemoryProviderAllocationSplit
Expand All @@ -36,14 +39,20 @@ EXPORTS
umfMemoryProviderPurgeForce
umfMemoryProviderPurgeLazy
umfMemoryProviderPutIPCHandle
umfMemoryTrackerGetAllocInfo
umfMempolicyCreate
umfMempolicyDestroy
umfMempolicySetCustomSplitPartitions
umfMempolicySetInterleavePartSize
umfMemspaceClone
umfMemspaceCreateFromNumaArray
umfMemspaceDestroy
umfMemspaceFilterByCapacity
umfMemspaceFilterById
umfMemspaceHighestBandwidthGet
umfMemspaceHighestCapacityGet
umfMemspaceHostAllGet
umfMemspaceLowestLatencyGet
umfMemspaceMemtargetAdd
umfMemspaceMemtargetGet
umfMemspaceMemtargetNum
Expand All @@ -53,7 +62,8 @@ EXPORTS
umfMemtargetGetCapacity
umfMemtargetGetId
umfMemtargetGetType
umfOpenIPCHandle
umfOpenIPCHandle
umfOsMemoryProviderOps
umfPoolAlignedMalloc
umfPoolByPtr
umfPoolCalloc
Expand All @@ -70,4 +80,3 @@ EXPORTS
umfProxyPoolOps
umfPutIPCHandle
umfScalablePoolOps
@UMF_OPTIONAL_SYMBOLS_WINDOWS@
12 changes: 10 additions & 2 deletions src/libumf.map.in → src/libumf.map
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ UMF_1.0 {
umfTearDown;
umfGetCurrentVersion;
umfCloseIPCHandle;
umfCUDAMemoryProviderOps;
umfDevDaxMemoryProviderOps;
umfFree;
umfFileMemoryProviderOps;
umfGetIPCHandle;
umfGetLastFailedMemoryProvider;
umfMemoryTrackerGetAllocInfo;
umfLevelZeroMemoryProviderOps;
umfMemoryProviderAlloc;
umfMemoryProviderAllocationMerge;
umfMemoryProviderAllocationSplit;
Expand All @@ -30,6 +33,7 @@ UMF_1.0 {
umfMemoryProviderPurgeForce;
umfMemoryProviderPurgeLazy;
umfMemoryProviderPutIPCHandle;
umfMemoryTrackerGetAllocInfo;
umfMempolicyCreate;
umfMempolicyDestroy;
umfMempolicySetCustomSplitPartitions;
Expand All @@ -39,6 +43,10 @@ UMF_1.0 {
umfMemspaceDestroy;
umfMemspaceFilterByCapacity;
umfMemspaceFilterById;
umfMemspaceHighestBandwidthGet;
umfMemspaceHighestCapacityGet;
umfMemspaceHostAllGet;
umfMemspaceLowestLatencyGet;
umfMemspaceMemtargetAdd;
umfMemspaceMemtargetGet;
umfMemspaceMemtargetNum;
Expand All @@ -49,6 +57,7 @@ UMF_1.0 {
umfMemtargetGetId;
umfMemtargetGetType;
umfOpenIPCHandle;
umfOsMemoryProviderOps;
umfPoolAlignedMalloc;
umfPoolByPtr;
umfPoolCalloc;
Expand All @@ -65,7 +74,6 @@ UMF_1.0 {
umfProxyPoolOps;
umfPutIPCHandle;
umfScalablePoolOps;
@UMF_OPTIONAL_SYMBOLS_LINUX@
local:
*;
};
16 changes: 16 additions & 0 deletions src/memspaces/memspace_highest_bandwidth.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
#include <ctype.h>
#include <stdlib.h>

#include <umf.h>
#include <umf/memspace.h>

// UMF_MEMSPACE_HIGHEST_BANDWIDTH requires HWLOC
// Additionally, it is currently unsupported on Win
#if defined(_WIN32) || defined(UMF_NO_HWLOC)

umf_const_memspace_handle_t umfMemspaceHighestBandwidthGet(void) {
// not supported
return NULL;
}

#else // !defined(_WIN32) && !defined(UMF_NO_HWLOC)

#include "base_alloc_global.h"
#include "memspace_internal.h"
#include "memtarget_numa.h"
Expand Down Expand Up @@ -100,3 +114,5 @@ umf_const_memspace_handle_t umfMemspaceHighestBandwidthGet(void) {
umfMemspaceHighestBandwidthInit);
return UMF_MEMSPACE_HIGHEST_BANDWIDTH;
}

#endif // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
16 changes: 16 additions & 0 deletions src/memspaces/memspace_highest_capacity.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
#include <assert.h>
#include <stdlib.h>

#include <umf.h>
#include <umf/memspace.h>

// UMF_MEMSPACE_HIGHEST_CAPACITY requires HWLOC
// Additionally, it is currently unsupported on Win
#if defined(_WIN32) || defined(UMF_NO_HWLOC)

umf_const_memspace_handle_t umfMemspaceHighestCapacityGet(void) {
// not supported
return NULL;
}

#else // !defined(_WIN32) && !defined(UMF_NO_HWLOC)

#include "base_alloc_global.h"
#include "memspace_internal.h"
#include "memtarget_numa.h"
Expand Down Expand Up @@ -72,3 +86,5 @@ umf_const_memspace_handle_t umfMemspaceHighestCapacityGet(void) {
umfMemspaceHighestCapacityInit);
return UMF_MEMSPACE_HIGHEST_CAPACITY;
}

#endif // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
16 changes: 16 additions & 0 deletions src/memspaces/memspace_host_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
#include <assert.h>
#include <stdlib.h>

#include <umf.h>
#include <umf/memspace.h>

// UMF_MEMSPACE_HOST_ALL requires HWLOC
// Additionally, it is currently unsupported on Win

#if defined(_WIN32) || defined(UMF_NO_HWLOC)
umf_const_memspace_handle_t umfMemspaceHostAllGet(void) {
// not supported
return NULL;
}

#else // !defined(_WIN32) && !defined(UMF_NO_HWLOC)

#include "base_alloc_global.h"
#include "memspace_internal.h"
#include "memtarget_numa.h"
Expand Down Expand Up @@ -93,3 +107,5 @@ umf_const_memspace_handle_t umfMemspaceHostAllGet(void) {
utils_init_once(&UMF_MEMSPACE_HOST_ALL_INITIALIZED, umfMemspaceHostAllInit);
return UMF_MEMSPACE_HOST_ALL;
}

#endif // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
16 changes: 16 additions & 0 deletions src/memspaces/memspace_lowest_latency.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
#include <ctype.h>
#include <stdlib.h>

#include <umf.h>
#include <umf/memspace.h>

// UMF_MEMSPACE_LOWEST_LATENCY requires HWLOC
// Additionally, it is currently unsupported on Win
#if defined(_WIN32) || defined(UMF_NO_HWLOC)

umf_const_memspace_handle_t umfMemspaceLowestLatencyGet(void) {
// not supported
return NULL;
}

#else // !defined(_WIN32) && !defined(UMF_NO_HWLOC)

#include "base_alloc_global.h"
#include "memspace_internal.h"
#include "memtarget_numa.h"
Expand Down Expand Up @@ -100,3 +114,5 @@ umf_const_memspace_handle_t umfMemspaceLowestLatencyGet(void) {
umfMemspaceLowestLatencyInit);
return UMF_MEMSPACE_LOWEST_LATENCY;
}

#endif // !defined(_WIN32) && !defined(UMF_NO_HWLOC)
Loading
Loading