@@ -390,60 +390,94 @@ if(hwloc_targ_SOURCE_DIR)
390
390
endif ()
391
391
endif ()
392
392
393
- # Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
394
- # headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
395
- if (UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
396
- set (LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git" )
397
- set (LEVEL_ZERO_LOADER_TAG v1.21.9)
398
-
399
- message (
400
- STATUS
401
- "Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG} ) from ${LEVEL_ZERO_LOADER_REPO} ..."
402
- )
393
+ if (UMF_BUILD_LEVEL_ZERO_PROVIDER)
394
+ if (UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
395
+ # Level Zero loader library is required to build Level Zero GPU tests
396
+ # and examples
397
+ find_package (ZE_LOADER REQUIRED ze_loader)
398
+ else ()
399
+ find_package (ZE_LOADER COMPONENTS ze_loader)
400
+ endif ()
403
401
404
- FetchContent_Declare(
405
- level-zero-loader
406
- GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
407
- GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
408
- EXCLUDE_FROM_ALL )
409
- # Only populate the repo - we don't need to build it
410
- FetchContent_Populate(level-zero-loader)
411
-
412
- set (LEVEL_ZERO_INCLUDE_DIRS
413
- ${level-zero-loader_SOURCE_DIR}/include
414
- CACHE PATH "Path to Level Zero headers" )
415
- message (STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS} " )
416
- elseif (UMF_BUILD_LEVEL_ZERO_PROVIDER)
417
- # Only header is needed to build UMF
418
- set (LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR} )
402
+ # If the Level Zero headers are not provided by the user and not found in
403
+ # the system, we will fetch them from the repo
404
+ if (UMF_LEVEL_ZERO_INCLUDE_DIR)
405
+ set (LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR} )
406
+ elseif (ZE_LOADER_INCLUDE_DIR)
407
+ set (LEVEL_ZERO_INCLUDE_DIRS ${ZE_LOADER_INCLUDE_DIR} )
408
+ else ()
409
+ set (LEVEL_ZERO_LOADER_REPO
410
+ "https://github.com/oneapi-src/level-zero.git" )
411
+ set (LEVEL_ZERO_LOADER_TAG v1.21.9)
412
+
413
+ message (STATUS "Fetching Level Zero loader (${LEVEL_ZERO_LOADER_TAG} ) "
414
+ "from ${LEVEL_ZERO_LOADER_REPO} ..." )
415
+ FetchContent_Declare(
416
+ level-zero-loader
417
+ GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
418
+ GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
419
+ EXCLUDE_FROM_ALL )
420
+ # Only populate the repo - we don't need to build it
421
+ FetchContent_Populate(level-zero-loader)
422
+
423
+ set (LEVEL_ZERO_INCLUDE_DIRS
424
+ ${level-zero-loader_SOURCE_DIR}/include
425
+ CACHE PATH "Path to Level Zero headers" )
426
+ endif ()
419
427
message (STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS} " )
428
+
429
+ if (ZE_LOADER_LIBRARIES)
430
+ set (UMF_LEVEL_ZERO_ENABLED TRUE )
431
+ else ()
432
+ message (
433
+ STATUS
434
+ "Disabling tests and examples that use the Level Zero Provider "
435
+ "because the Level Zero libraries they require were not found." )
436
+ endif ()
420
437
endif ()
421
438
422
- # Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
423
- # headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
424
- if (UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
425
- set (CUDA_REPO
426
- "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git" )
427
- set (CUDA_TAG cuda-12.5.1)
439
+ if (UMF_BUILD_CUDA_PROVIDER)
440
+ if (UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
441
+ # CUDA library is required to build CUDA GPU tests and examples
442
+ find_package (CUDA REQUIRED cuda)
443
+ else ()
444
+ find_package (CUDA COMPONENTS cuda)
445
+ endif ()
428
446
429
- message (STATUS "Fetching CUDA (${CUDA_TAG} ) from ${CUDA_REPO} ..." )
447
+ # If the CUDA headers are not provided by the user and not found in the
448
+ # system, we will fetch them from the repo
449
+ if (UMF_CUDA_INCLUDE_DIR)
450
+ set (CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR} )
451
+ elseif (CUDA_INCLUDE_DIR)
452
+ set (CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIR} )
453
+ else ()
454
+ set (CUDA_REPO
455
+ "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git" )
456
+ set (CUDA_TAG cuda-12.5.1)
430
457
431
- FetchContent_Declare(
432
- cuda-headers
433
- GIT_REPOSITORY ${CUDA_REPO}
434
- GIT_TAG ${CUDA_TAG}
435
- EXCLUDE_FROM_ALL )
436
- # Only populate the repo - we don't need to build it
437
- FetchContent_Populate(cuda-headers)
438
-
439
- set (CUDA_INCLUDE_DIRS
440
- ${cuda-headers_SOURCE_DIR}
441
- CACHE PATH "Path to CUDA headers" )
442
- message (STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
443
- elseif (UMF_BUILD_CUDA_PROVIDER)
444
- # Only header is needed to build UMF
445
- set (CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR} )
458
+ message (
459
+ STATUS "Fetching CUDA (${CUDA_TAG} ) headers from ${CUDA_REPO} ..." )
460
+ FetchContent_Declare(
461
+ cuda-headers
462
+ GIT_REPOSITORY ${CUDA_REPO}
463
+ GIT_TAG ${CUDA_TAG}
464
+ EXCLUDE_FROM_ALL )
465
+ # Only populate the repo - we don't need to build it
466
+ FetchContent_Populate(cuda-headers)
467
+
468
+ set (CUDA_INCLUDE_DIRS
469
+ ${cuda-headers_SOURCE_DIR}
470
+ CACHE PATH "Path to CUDA headers" )
471
+ endif ()
446
472
message (STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
473
+
474
+ if (CUDA_LIBRARIES)
475
+ set (UMF_CUDA_ENABLED TRUE )
476
+ else ()
477
+ message (
478
+ STATUS "Disabling tests and examples that use the CUDA Provider "
479
+ "because the CUDA libraries they require were not found." )
480
+ endif ()
447
481
endif ()
448
482
449
483
# Build the umfd target in a separate directory with Debug configuration
@@ -711,18 +745,6 @@ else()
711
745
)
712
746
endif ()
713
747
714
- if ((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER)
715
- find_package (CUDA REQUIRED cuda)
716
- if (CUDA_LIBRARIES)
717
- set (UMF_CUDA_ENABLED TRUE )
718
- else ()
719
- message (
720
- STATUS "Disabling tests and examples that use the CUDA provider "
721
- "because the CUDA libraries they require were not found." )
722
- endif ()
723
- # TODO do the same for ze_loader
724
- endif ()
725
-
726
748
add_subdirectory (src)
727
749
728
750
if (UMF_BUILD_TESTS)
0 commit comments