Skip to content

Commit 8e7a0bc

Browse files
authored
Update CMake files to use ROCM_EXAMPLES_GPU_LANGUAGE instead of GPU_RUNTIME (#430)
* HIP-Basic move to using ROCM_EXAMPLES_GPU_LANGUAGE instead of GPU_RUNTIME * Libraries - Parent/Aggregator Cmake files * Hip BLAS/CUB/FFT cmake files * hip RAND/SOLVER/SPARSE cmake * hip Tensor and rocAL * roc ALUTION/BLAS/callback * roc Profiler-SDK/RAND/SOLVER * roc SPARSE/WMMA * tools cmake, tutorials, ci, documentation and json presets * fix paths * remove -Wno-dev * added files from commit 3b6c8d4
1 parent c74714c commit 8e7a0bc

211 files changed

Lines changed: 821 additions & 1145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-rocm-examples-reusable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
108108
- name: CMake configure
109109
run: |
110-
cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DROCM_ROOT="${ROCM_PATH}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" -Wno-dev 2> >(tee cmake_error.log >&2)
110+
cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DROCM_ROOT="${ROCM_PATH}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" 2> >(tee cmake_error.log >&2)
111111
112112
- name: CMake configure error summary
113113
if: ${{ !cancelled() }}

.github/workflows/build_applications_cuda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ jobs:
7676
- name: Configure and Build
7777
run: |
7878
cd Applications && mkdir build && cd build
79-
cmake -DGPU_RUNTIME=CUDA ..
79+
cmake -DROCM_EXAMPLES_GPU_LANGUAGE=CUDA ..
8080
cmake --build . -j

.github/workflows/build_hip_basic_cuda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ jobs:
5151
- name: Configure and Build
5252
run: |
5353
cd HIP-Basic && mkdir build && cd build
54-
cmake -DGPU_RUNTIME=CUDA ..
54+
cmake -DROCM_EXAMPLES_GPU_LANGUAGE=CUDA ..
5555
cmake --build . -j

.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ build:make-cuda:
183183
- build
184184
needs: []
185185
script:
186-
- cd $CI_PROJECT_DIR && make CXXFLAGS="$CUDA_FLAGS" GPU_RUNTIME=CUDA -j $(nproc)
186+
- cd $CI_PROJECT_DIR && make CXXFLAGS="$CUDA_FLAGS" ROCM_EXAMPLES_GPU_LANGUAGE=CUDA -j $(nproc)
187187

188188
########################
189189
# Ubuntu cmake #
@@ -233,7 +233,7 @@ build:cmake-cuda:
233233
- cmake
234234
-S $CI_PROJECT_DIR
235235
-B $CI_PROJECT_DIR/build
236-
-D GPU_RUNTIME=CUDA
236+
-D ROCM_EXAMPLES_GPU_LANGUAGE=CUDA
237237
-D CMAKE_CXX_FLAGS="$CXX_FLAGS"
238238
-D CMAKE_CUDA_FLAGS="$CUDA_FLAGS"
239239
-D CMAKE_MODULE_PATH=/opt/rocm/lib/cmake/hip
@@ -477,6 +477,6 @@ test:windows-nvcc-cmake:
477477
-D CMAKE_TOOLCHAIN_FILE="C:/Tools/Microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake"
478478
-D CMAKE_BUILD_TYPE="$BUILD_TYPE"
479479
-D CMAKE_CXX_COMPILER="cl.exe"
480-
-D GPU_RUNTIME=CUDA
480+
-D ROCM_EXAMPLES_GPU_LANGUAGE=CUDA
481481
2>&1 | Tee-Object -filepath cmake_log.txt
482482
- !reference [.test:windows-cmake, script]

Applications/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Make sure that the dependencies are installed, or use one of the [provided Docke
3131
All examples in the `Applications` subdirectory can either be built by a single CMake project or be built independently.
3232

3333
- `$ cd Libraries/Applications`
34-
- `$ cmake -S . -B build` (on ROCm) or `$ cmake -S . -B build -D GPU_RUNTIME=CUDA` (on CUDA, when supported)
34+
- `$ cmake -S . -B build` (on ROCm) or `$ cmake -S . -B build -D ROCM_EXAMPLES_GPU_LANGUAGE=CUDA` (on CUDA, when supported)
3535
- `$ cmake --build build`
3636

3737
#### Using Make
3838

3939
All examples can be built by a single invocation to Make or be built independently.
4040

4141
- `$ cd Libraries/Applications`
42-
- `$ make` (on ROCm) or `$ make GPU_RUNTIME=CUDA` (on CUDA, when supported)
42+
- `$ make` (on ROCm) or `$ make ROCM_EXAMPLES_GPU_LANGUAGE=CUDA` (on CUDA, when supported)
4343

4444
### Windows
4545

HIP-Basic/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ file(RELATIVE_PATH folder_bin ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
4949
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${folder_bin})
5050

5151
# Only supported on HIP (not CUDA)
52-
if(NOT "${GPU_RUNTIME}" STREQUAL "CUDA")
52+
if(NOT "${ROCM_EXAMPLES_GPU_LANGUAGE}" STREQUAL "CUDA")
5353
# Make sure the dependencies can be found before building.
5454
find_program(
5555
LLVM_DIS_COMMAND
@@ -121,7 +121,7 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
121121
message(WARNING "Perl not found, not building hipify example")
122122
endif()
123123
endif()
124-
if("${GPU_RUNTIME}" STREQUAL "CUDA")
124+
if("${ROCM_EXAMPLES_GPU_LANGUAGE}" STREQUAL "CUDA")
125125
add_subdirectory(hello_world_cuda)
126126
endif()
127127

@@ -136,7 +136,7 @@ add_subdirectory(shared_memory)
136136
# We cannot build the static library on Windows as the HIP SDK does not include CMAKE_AR.
137137
if(
138138
NOT CMAKE_SYSTEM_NAME MATCHES "Windows"
139-
AND NOT "${GPU_RUNTIME}" STREQUAL "HIP"
139+
AND NOT "${ROCM_EXAMPLES_GPU_LANGUAGE}" STREQUAL "HIP"
140140
)
141141
add_subdirectory(static_host_library)
142142
endif()

HIP-Basic/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Make sure that the dependencies are installed, or use one of the [provided Docke
3131
All examples in the `HIP-Basic` subdirectory can either be built by a single CMake project or be built independently.
3232

3333
- `$ cd HIP-Basic`
34-
- `$ cmake -S . -B build` (on ROCm) or `$ cmake -S . -B build -D GPU_RUNTIME=CUDA` (on CUDA, when supported)
34+
- `$ cmake -S . -B build` (on ROCm) or `$ cmake -S . -B build -D ROCM_EXAMPLES_GPU_LANGUAGE=CUDA` (on CUDA, when supported)
3535
- `$ cmake --build build`
3636

3737
#### Using Make
3838

3939
All examples can be built by a single invocation to Make or be built independently.
4040

4141
- `$ cd HIP-Basic`
42-
- `$ make` (on ROCm) or `$ make GPU_RUNTIME=CUDA` (on CUDA, when supported)
42+
- `$ make` (on ROCm) or `$ make ROCM_EXAMPLES_GPU_LANGUAGE=CUDA` (on CUDA, when supported)
4343

4444
### Windows
4545

HIP-Basic/bandwidth/CMakeLists.txt

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,14 @@ set(example_name hip_bandwidth)
2525
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
2626
project(${example_name} LANGUAGES CXX)
2727

28-
set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
29-
set(GPU_RUNTIMES "HIP" "CUDA")
30-
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})
28+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/HipPlatform.cmake")
29+
select_gpu_language()
30+
enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})
31+
select_hip_platform()
3132

32-
if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
33-
set(ERROR_MESSAGE
34-
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
35-
)
36-
message(FATAL_ERROR ${ERROR_MESSAGE})
37-
endif()
38-
39-
enable_language(${GPU_RUNTIME})
40-
set(CMAKE_${GPU_RUNTIME}_STANDARD 17)
41-
set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
42-
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)
33+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD 17)
34+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
35+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
4336

4437
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
4538
set(ROCM_ROOT
@@ -61,11 +54,11 @@ add_executable(${example_name} main.hip)
6154
# Make example runnable using ctest
6255
add_test(NAME ${example_name} COMMAND ${example_name})
6356
set(include_dirs "../../Common" "../../External")
64-
if(GPU_RUNTIME STREQUAL "CUDA")
57+
if(ROCM_EXAMPLES_GPU_LANGUAGE STREQUAL "CUDA")
6558
list(APPEND include_dirs "${ROCM_ROOT}/include")
6659
endif()
6760

6861
target_include_directories(${example_name} PRIVATE ${include_dirs})
69-
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${GPU_RUNTIME})
62+
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE})
7063

7164
install(TARGETS ${example_name})

HIP-Basic/bit_extract/CMakeLists.txt

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,14 @@ set(example_name hip_bit_extract)
2525
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
2626
project(${example_name} LANGUAGES CXX)
2727

28-
set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
29-
set(GPU_RUNTIMES "HIP" "CUDA")
30-
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})
28+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/HipPlatform.cmake")
29+
select_gpu_language()
30+
enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})
31+
select_hip_platform()
3132

32-
if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
33-
set(ERROR_MESSAGE
34-
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
35-
)
36-
message(FATAL_ERROR ${ERROR_MESSAGE})
37-
endif()
38-
39-
enable_language(${GPU_RUNTIME})
40-
set(CMAKE_${GPU_RUNTIME}_STANDARD 17)
41-
set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
42-
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)
33+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD 17)
34+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
35+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
4336

4437
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
4538
set(ROCM_ROOT
@@ -62,11 +55,11 @@ add_executable(${example_name} main.hip)
6255
add_test(NAME ${example_name} COMMAND ${example_name})
6356

6457
set(include_dirs "../../Common" "../../External")
65-
if(GPU_RUNTIME STREQUAL "CUDA")
58+
if(ROCM_EXAMPLES_GPU_LANGUAGE STREQUAL "CUDA")
6659
list(APPEND include_dirs "${ROCM_ROOT}/include")
6760
endif()
6861

6962
target_include_directories(${example_name} PRIVATE ${include_dirs})
70-
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${GPU_RUNTIME})
63+
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE})
7164

7265
install(TARGETS ${example_name})

HIP-Basic/cooperative_groups/CMakeLists.txt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,15 @@ set(example_name hip_cooperative_groups)
2525
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
2626
project(${example_name} LANGUAGES CXX)
2727

28-
set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
29-
set(GPU_RUNTIMES "HIP" "CUDA")
30-
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})
28+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/HipPlatform.cmake")
29+
select_gpu_language()
30+
enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})
31+
select_hip_platform()
3132

32-
if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
33-
set(ERROR_MESSAGE
34-
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
35-
)
36-
message(FATAL_ERROR ${ERROR_MESSAGE})
37-
endif()
38-
39-
enable_language(${GPU_RUNTIME})
40-
set(CMAKE_${GPU_RUNTIME}_STANDARD 17)
41-
set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
42-
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)
33+
enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})
34+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD 17)
35+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
36+
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
4337

4438
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
4539
set(ROCM_ROOT
@@ -62,7 +56,7 @@ add_executable(${example_name} main.hip)
6256
add_test(NAME ${example_name} COMMAND ${example_name})
6357

6458
set(include_dirs "../../Common" "../../External")
65-
if(GPU_RUNTIME STREQUAL "CUDA")
59+
if(ROCM_EXAMPLES_GPU_LANGUAGE STREQUAL "CUDA")
6660
list(APPEND include_dirs "${ROCM_ROOT}/include")
6761
else()
6862
# Add NDEBUG for HIP version >= 5.5 and < 6.0 due to a known bug in the cooperative groups header
@@ -75,6 +69,6 @@ else()
7569
endif()
7670

7771
target_include_directories(${example_name} PRIVATE ${include_dirs})
78-
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${GPU_RUNTIME})
72+
set_source_files_properties(main.hip PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE})
7973

8074
install(TARGETS ${example_name})

0 commit comments

Comments
 (0)