Skip to content

Fix Level Zero related CMake configs #872

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 2 commits into from
Nov 7, 2024
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
58 changes: 58 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,64 @@ if(hwloc_targ_SOURCE_DIR)
endif()
endif()

# Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
# headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
include(FetchContent)

set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.17.39)

message(
STATUS
"Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG}) from ${LEVEL_ZERO_LOADER_REPO} ..."
)

FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(level-zero-loader)

set(LEVEL_ZERO_INCLUDE_DIRS
${level-zero-loader_SOURCE_DIR}/include
CACHE PATH "Path to Level Zero Headers")
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER)
# Only header is needed to build UMF
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
endif()

# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
include(FetchContent)

set(CUDA_REPO
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
set(CUDA_TAG cuda-12.5.1)

message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")

FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(cuda-headers)

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
CACHE PATH "Path to CUDA headers")
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
elseif(UMF_BUILD_CUDA_PROVIDER)
# Only header is needed to build UMF
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
endif()

# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
# set, because in this case the build type is determined after a CMake
# configuration is done (at the build time)
Expand Down
58 changes: 0 additions & 58 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,6 @@ set(UMF_CUDA_INCLUDE_DIR
# TODO: Cleanup the compile definitions across all the CMake files
set(UMF_COMMON_COMPILE_DEFINITIONS UMF_VERSION=${UMF_VERSION})

# Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
# headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
include(FetchContent)

set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.17.39)

message(
STATUS
"Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG}) from ${LEVEL_ZERO_LOADER_REPO} ..."
)

FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(level-zero-loader)

set(LEVEL_ZERO_INCLUDE_DIRS
${level-zero-loader_SOURCE_DIR}/include
CACHE PATH "Path to Level Zero Headers")
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER)
# Only header is needed to build UMF
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
endif()

# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
include(FetchContent)

set(CUDA_REPO
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
set(CUDA_TAG cuda-12.5.1)

message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")

FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(cuda-headers)

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
CACHE PATH "Path to CUDA headers")
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
elseif(UMF_BUILD_CUDA_PROVIDER)
# Only header is needed to build UMF
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
endif()

add_subdirectory(utils)

set(UMF_LIBS $<BUILD_INTERFACE:umf_utils>)
Expand Down
9 changes: 0 additions & 9 deletions test/providers/provider_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,6 @@ TEST_P(umfLevelZeroProviderTest, allocInvalidSize) {
umfMemoryProviderGetLastNativeError(provider, &message, &error);
ASSERT_EQ(error, ZE_RESULT_ERROR_UNSUPPORTED_SIZE);

// in case of size == 0 we should got INVALID_ARGUMENT error
// NOTE: this is invalid only for the DEVICE or SHARED allocations
if (params.memory_type != UMF_MEMORY_TYPE_HOST) {
umf_result = umfMemoryProviderAlloc(provider, 0, 0, &ptr);
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC);
umfMemoryProviderGetLastNativeError(provider, &message, &error);
ASSERT_EQ(error, ZE_RESULT_ERROR_UNSUPPORTED_SIZE);
}

umfMemoryProviderDestroy(provider);
}

Expand Down
Loading