|
2 | 2 | # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
4 | 4 |
|
| 5 | +message(STATUS "CMake version: ${CMAKE_VERSION}") |
5 | 6 | cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) |
| 7 | + |
6 | 8 | # needed when UMF is used as an external project |
7 | 9 | set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
8 | 10 |
|
@@ -388,58 +390,94 @@ if(hwloc_targ_SOURCE_DIR) |
388 | 390 | endif() |
389 | 391 | endif() |
390 | 392 |
|
391 | | -# Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0 |
392 | | -# headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR). |
393 | | -if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR)) |
394 | | - set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git") |
395 | | - set(LEVEL_ZERO_LOADER_TAG v1.21.9) |
| 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() |
396 | 401 |
|
397 | | - message( |
398 | | - STATUS |
399 | | - "Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG}) from ${LEVEL_ZERO_LOADER_REPO} ..." |
400 | | - ) |
| 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() |
| 427 | + message(STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS}") |
401 | 428 |
|
402 | | - FetchContent_Declare( |
403 | | - level-zero-loader |
404 | | - GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO} |
405 | | - GIT_TAG ${LEVEL_ZERO_LOADER_TAG} |
406 | | - EXCLUDE_FROM_ALL) |
407 | | - FetchContent_MakeAvailable(level-zero-loader) |
408 | | - |
409 | | - set(LEVEL_ZERO_INCLUDE_DIRS |
410 | | - ${level-zero-loader_SOURCE_DIR}/include |
411 | | - CACHE PATH "Path to Level Zero Headers") |
412 | | - message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}") |
413 | | -elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER) |
414 | | - # Only header is needed to build UMF |
415 | | - set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR}) |
416 | | - message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}") |
417 | | -endif() |
418 | | - |
419 | | -# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA |
420 | | -# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR). |
421 | | -if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR)) |
422 | | - set(CUDA_REPO |
423 | | - "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git") |
424 | | - set(CUDA_TAG cuda-12.5.1) |
425 | | - |
426 | | - message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...") |
| 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() |
| 437 | +endif() |
427 | 438 |
|
428 | | - FetchContent_Declare( |
429 | | - cuda-headers |
430 | | - GIT_REPOSITORY ${CUDA_REPO} |
431 | | - GIT_TAG ${CUDA_TAG} |
432 | | - EXCLUDE_FROM_ALL) |
433 | | - FetchContent_MakeAvailable(cuda-headers) |
434 | | - |
435 | | - set(CUDA_INCLUDE_DIRS |
436 | | - ${cuda-headers_SOURCE_DIR} |
437 | | - CACHE PATH "Path to CUDA headers") |
438 | | - message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}") |
439 | | -elseif(UMF_BUILD_CUDA_PROVIDER) |
440 | | - # Only header is needed to build UMF |
441 | | - set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR}) |
| 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() |
| 446 | + |
| 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) |
| 457 | + |
| 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() |
442 | 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() |
443 | 481 | endif() |
444 | 482 |
|
445 | 483 | # Build the umfd target in a separate directory with Debug configuration |
@@ -707,18 +745,6 @@ else() |
707 | 745 | ) |
708 | 746 | endif() |
709 | 747 |
|
710 | | -if((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER) |
711 | | - find_package(CUDA REQUIRED cuda) |
712 | | - if(CUDA_LIBRARIES) |
713 | | - set(UMF_CUDA_ENABLED TRUE) |
714 | | - else() |
715 | | - message( |
716 | | - STATUS "Disabling tests and examples that use the CUDA provider " |
717 | | - "because the CUDA libraries they require were not found.") |
718 | | - endif() |
719 | | - # TODO do the same for ze_loader |
720 | | -endif() |
721 | | - |
722 | 748 | add_subdirectory(src) |
723 | 749 |
|
724 | 750 | if(UMF_BUILD_TESTS) |
|
0 commit comments