Skip to content

remove unused UMF_NO_*_PROVIDER compile defs #1316

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

Merged
merged 1 commit into from
May 16, 2025
Merged
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
42 changes: 13 additions & 29 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,22 @@ set(UMF_SOURCES_LINUX libumf_linux.c)
set(UMF_SOURCES_MACOSX libumf_linux.c)
set(UMF_SOURCES_WINDOWS libumf_windows.c)

# 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(NOT UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(LINUX)
# WA for error ze_api.h:14234:20: no newline at end of file
# [-Werror,-Wnewline-eof]
set_source_files_properties(
provider/provider_level_zero.c
PROPERTIES APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-newline-eof")
endif()

set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_LEVEL_ZERO_PROVIDER=1")
"UMF_BUILD_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")

if(UMF_BUILD_CUDA_PROVIDER)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
"UMF_NO_FILE_PROVIDER=1")
"UMF_BUILD_CUDA_PROVIDER=1")
endif()

if(LINUX)
Expand Down Expand Up @@ -198,24 +200,6 @@ if(NOT WINDOWS AND UMF_POOL_JEMALLOC_ENABLED)
add_dependencies(umf jemalloc)
endif()

if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(LINUX)
# WA for error ze_api.h:14234:20: no newline at end of file
# [-Werror,-Wnewline-eof]
set_source_files_properties(
provider/provider_level_zero.c
PROPERTIES APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-newline-eof")
endif()

set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
endif()

if(UMF_BUILD_CUDA_PROVIDER)
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
"UMF_BUILD_CUDA_PROVIDER=1")
endif()

add_library(${PROJECT_NAME}::umf ALIAS umf)

if(LIBHWLOC_INCLUDE_DIRS)
Expand Down
114 changes: 57 additions & 57 deletions src/provider/provider_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,62 +25,7 @@ void fini_cu_global_state(void) {
}
}

#if defined(UMF_NO_CUDA_PROVIDER)

umf_result_t umfCUDAMemoryProviderParamsCreate(
umf_cuda_memory_provider_params_handle_t *hParams) {
(void)hParams;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsDestroy(
umf_cuda_memory_provider_params_handle_t hParams) {
(void)hParams;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetContext(
umf_cuda_memory_provider_params_handle_t hParams, void *hContext) {
(void)hParams;
(void)hContext;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetDevice(
umf_cuda_memory_provider_params_handle_t hParams, int hDevice) {
(void)hParams;
(void)hDevice;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetMemoryType(
umf_cuda_memory_provider_params_handle_t hParams,
umf_usm_memory_type_t memoryType) {
(void)hParams;
(void)memoryType;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetAllocFlags(
umf_cuda_memory_provider_params_handle_t hParams, unsigned int flags) {
(void)hParams;
(void)flags;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

const umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void) {
// not supported
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return NULL;
}

#else // !defined(UMF_NO_CUDA_PROVIDER)
#if UMF_BUILD_CUDA_PROVIDER

// disable warning 4201: nonstandard extension used: nameless struct/union
#if defined(_MSC_VER)
Expand Down Expand Up @@ -759,4 +704,59 @@ const umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void) {
return &UMF_CUDA_MEMORY_PROVIDER_OPS;
}

#endif // !defined(UMF_NO_CUDA_PROVIDER)
#else // !UMF_BUILD_CUDA_PROVIDER

umf_result_t umfCUDAMemoryProviderParamsCreate(
umf_cuda_memory_provider_params_handle_t *hParams) {
(void)hParams;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsDestroy(
umf_cuda_memory_provider_params_handle_t hParams) {
(void)hParams;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetContext(
umf_cuda_memory_provider_params_handle_t hParams, void *hContext) {
(void)hParams;
(void)hContext;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetDevice(
umf_cuda_memory_provider_params_handle_t hParams, int hDevice) {
(void)hParams;
(void)hDevice;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetMemoryType(
umf_cuda_memory_provider_params_handle_t hParams,
umf_usm_memory_type_t memoryType) {
(void)hParams;
(void)memoryType;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfCUDAMemoryProviderParamsSetAllocFlags(
umf_cuda_memory_provider_params_handle_t hParams, unsigned int flags) {
(void)hParams;
(void)flags;
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

const umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void) {
// not supported
LOG_ERR("CUDA provider is disabled (UMF_BUILD_CUDA_PROVIDER is OFF)!");
return NULL;
}

#endif // !UMF_BUILD_CUDA_PROVIDER
168 changes: 84 additions & 84 deletions src/provider/provider_level_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,89 +27,7 @@ void fini_ze_global_state(void) {
}
}

#if defined(UMF_NO_LEVEL_ZERO_PROVIDER)

umf_result_t umfLevelZeroMemoryProviderParamsCreate(
umf_level_zero_memory_provider_params_handle_t *hParams) {
(void)hParams;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsDestroy(
umf_level_zero_memory_provider_params_handle_t hParams) {
(void)hParams;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetContext(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_context_handle_t hContext) {
(void)hParams;
(void)hContext;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetDevice(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_device_handle_t hDevice) {
(void)hParams;
(void)hDevice;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetMemoryType(
umf_level_zero_memory_provider_params_handle_t hParams,
umf_usm_memory_type_t memoryType) {
(void)hParams;
(void)memoryType;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetResidentDevices(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_device_handle_t *hDevices, uint32_t deviceCount) {
(void)hParams;
(void)hDevices;
(void)deviceCount;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetFreePolicy(
umf_level_zero_memory_provider_params_handle_t hParams,
umf_level_zero_memory_provider_free_policy_t policy) {
(void)hParams;
(void)policy;
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetDeviceOrdinal(
umf_level_zero_memory_provider_params_handle_t hParams,
uint32_t deviceOrdinal) {
(void)hParams;
(void)deviceOrdinal;
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

const umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void) {
// not supported
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return NULL;
}

#else // !defined(UMF_NO_LEVEL_ZERO_PROVIDER)
#if UMF_BUILD_LEVEL_ZERO_PROVIDER

#include "base_alloc_global.h"
#include "libumf.h"
Expand Down Expand Up @@ -867,4 +785,86 @@ const umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void) {
return &UMF_LEVEL_ZERO_MEMORY_PROVIDER_OPS;
}

#endif // !defined(UMF_NO_LEVEL_ZERO_PROVIDER)
#else // !UMF_BUILD_LEVEL_ZERO_PROVIDER

umf_result_t umfLevelZeroMemoryProviderParamsCreate(
umf_level_zero_memory_provider_params_handle_t *hParams) {
(void)hParams;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsDestroy(
umf_level_zero_memory_provider_params_handle_t hParams) {
(void)hParams;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetContext(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_context_handle_t hContext) {
(void)hParams;
(void)hContext;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetDevice(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_device_handle_t hDevice) {
(void)hParams;
(void)hDevice;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetMemoryType(
umf_level_zero_memory_provider_params_handle_t hParams,
umf_usm_memory_type_t memoryType) {
(void)hParams;
(void)memoryType;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetResidentDevices(
umf_level_zero_memory_provider_params_handle_t hParams,
ze_device_handle_t *hDevices, uint32_t deviceCount) {
(void)hParams;
(void)hDevices;
(void)deviceCount;
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetFreePolicy(
umf_level_zero_memory_provider_params_handle_t hParams,
umf_level_zero_memory_provider_free_policy_t policy) {
(void)hParams;
(void)policy;
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_result_t umfLevelZeroMemoryProviderParamsSetDeviceOrdinal(
umf_level_zero_memory_provider_params_handle_t hParams,
uint32_t deviceOrdinal) {
(void)hParams;
(void)deviceOrdinal;
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

const umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void) {
// not supported
LOG_ERR("L0 memory provider is disabled! (UMF_BUILD_LEVEL_ZERO_PROVIDER is "
"OFF)");
return NULL;
}

#endif // !UMF_BUILD_LEVEL_ZERO_PROVIDER
Loading