Skip to content

Commit

Permalink
Merge pull request #787 from bratpiorka/rrudnick_miss_sym
Browse files Browse the repository at this point in the history
remove optional symbols
  • Loading branch information
bratpiorka authored Oct 11, 2024
2 parents 52152a1 + 104dd60 commit 0420d07
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 107 deletions.
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,70 +110,53 @@ 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_coarse.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 @@ -198,8 +181,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 @@ -215,11 +198,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 @@ -229,8 +207,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 @@ -244,7 +220,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 @@ -16,10 +16,13 @@ EXPORTS
umfCloseIPCHandle
umfCoarseMemoryProviderGetStats
umfCoarseMemoryProviderOps
umfCUDAMemoryProviderOps
umfDevDaxMemoryProviderOps
umfFree
umfFileMemoryProviderOps
umfGetIPCHandle
umfGetLastFailedMemoryProvider
umfMemoryTrackerGetAllocInfo
umfLevelZeroMemoryProviderOps
umfMemoryProviderAlloc
umfMemoryProviderAllocationMerge
umfMemoryProviderAllocationSplit
Expand All @@ -38,14 +41,20 @@ EXPORTS
umfMemoryProviderPurgeForce
umfMemoryProviderPurgeLazy
umfMemoryProviderPutIPCHandle
umfMemoryTrackerGetAllocInfo
umfMempolicyCreate
umfMempolicyDestroy
umfMempolicySetCustomSplitPartitions
umfMempolicySetInterleavePartSize
umfMemspaceClone
umfMemspaceCreateFromNumaArray
umfMemspaceDestroy
umfMemspaceFilterByCapacity
umfMemspaceFilterById
umfMemspaceHighestBandwidthGet
umfMemspaceHighestCapacityGet
umfMemspaceHostAllGet
umfMemspaceLowestLatencyGet
umfMemspaceMemtargetAdd
umfMemspaceMemtargetGet
umfMemspaceMemtargetNum
Expand All @@ -55,7 +64,8 @@ EXPORTS
umfMemtargetGetCapacity
umfMemtargetGetId
umfMemtargetGetType
umfOpenIPCHandle
umfOpenIPCHandle
umfOsMemoryProviderOps
umfPoolAlignedMalloc
umfPoolByPtr
umfPoolCalloc
Expand All @@ -72,4 +82,3 @@ EXPORTS
umfProxyPoolOps
umfPutIPCHandle
umfScalablePoolOps
@UMF_OPTIONAL_SYMBOLS_WINDOWS@
13 changes: 11 additions & 2 deletions src/libumf.map.in → src/libumf.map
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ UMF_1.0 {
umfCloseIPCHandle;
umfCoarseMemoryProviderGetStats;
umfCoarseMemoryProviderOps;
umfCUDAMemoryProviderOps;
umfDevDaxMemoryProviderOps;
umfFree;
umfFileMemoryProviderOps;
umfGetIPCHandle;
umfGetLastFailedMemoryProvider;
umfMemoryTrackerGetAllocInfo;
umfLevelZeroMemoryProviderOps;
umfMemoryProviderAlloc;
umfMemoryProviderAllocationMerge;
umfMemoryProviderAllocationSplit;
Expand All @@ -32,14 +35,20 @@ UMF_1.0 {
umfMemoryProviderPurgeForce;
umfMemoryProviderPurgeLazy;
umfMemoryProviderPutIPCHandle;
umfMemoryTrackerGetAllocInfo;
umfMempolicyCreate;
umfMempolicyDestroy;
umfMempolicySetCustomSplitPartitions;
umfMempolicySetInterleavePartSize;
umfMemspaceClone;
umfMemspaceCreateFromNumaArray;
umfMemspaceDestroy;
umfMemspaceFilterByCapacity;
umfMemspaceFilterById;
umfMemspaceHighestBandwidthGet;
umfMemspaceHighestCapacityGet;
umfMemspaceHostAllGet;
umfMemspaceLowestLatencyGet;
umfMemspaceMemtargetAdd;
umfMemspaceMemtargetGet;
umfMemspaceMemtargetNum;
Expand All @@ -50,6 +59,7 @@ UMF_1.0 {
umfMemtargetGetId;
umfMemtargetGetType;
umfOpenIPCHandle;
umfOsMemoryProviderOps;
umfPoolAlignedMalloc;
umfPoolByPtr;
umfPoolCalloc;
Expand All @@ -66,7 +76,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

0 comments on commit 0420d07

Please sign in to comment.