Skip to content

Commit

Permalink
Update platform check and add CUDA CMake version check
Browse files Browse the repository at this point in the history
  • Loading branch information
matyas-streamhpc committed Aug 16, 2024
1 parent 157c78e commit 38d117d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
1 change: 0 additions & 1 deletion Tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ file(RELATIVE_PATH folder_bin ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${folder_bin})

add_subdirectory(reduction)

13 changes: 10 additions & 3 deletions Tutorials/Reduction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
cmake_minimum_required(VERSION 3.25.2)
if("${GPU_RUNTIME}" STREQUAL "CUDA")
if(${CMAKE_VERSION} VERSION_LESS "3.25.2")
message(
STATUS
"Skipped: Reduction tutorial, because CMake version is too low."
)
return()
endif()
cmake_minimum_required(VERSION 3.25.2)
else()
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.21)
endif()

project(Reduction LANGUAGES CXX)
Expand Down
17 changes: 7 additions & 10 deletions Tutorials/Reduction/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
cmake_minimum_required(VERSION 3.25.2)
if("${GPU_RUNTIME}" STREQUAL "CUDA")
cmake_minimum_required(VERSION 3.25.2)
else()
cmake_minimum_required(VERSION 3.21)
endif()

project(reduction_benchmarks LANGUAGES CXX)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd")
cmake_minimum_required(VERSION 3.21)
# Add -fPIE flag to compiler.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

project(reduction_benchmarks LANGUAGES CXX)

include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake")
select_gpu_language()

Expand Down Expand Up @@ -63,7 +60,7 @@ set(include_dirs "../../../Common")
list(APPEND include_dirs "${PROJECT_SOURCE_DIR}")

# For examples targeting NVIDIA, include the HIP header directory.
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
list(APPEND include_dirs "${ROCM_ROOT}/include")
endif()

Expand Down Expand Up @@ -133,7 +130,7 @@ foreach(VER RANGE 0 10)
$<$<TARGET_EXISTS:TBB::tbb>:TBB::tbb>
)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
set_source_files_properties(
${Sources}
PROPERTIES LANGUAGE ${GPU_RUNTIME}
Expand Down
17 changes: 7 additions & 10 deletions Tutorials/Reduction/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
cmake_minimum_required(VERSION 3.25.2)
if("${GPU_RUNTIME}" STREQUAL "CUDA")
cmake_minimum_required(VERSION 3.25.2)
else()
cmake_minimum_required(VERSION 3.21)
endif()

project(reduction_examples LANGUAGES CXX)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd")
cmake_minimum_required(VERSION 3.21)
# Add -fPIE flag to compiler.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

project(reduction_examples LANGUAGES CXX)

include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake")
select_gpu_language()

Expand Down Expand Up @@ -63,7 +60,7 @@ set(include_dirs "../../../Common")
list(APPEND include_dirs "${PROJECT_SOURCE_DIR}")

# For examples targeting NVIDIA, include the HIP header directory.
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
list(APPEND include_dirs "${ROCM_ROOT}/include")
endif()

Expand Down Expand Up @@ -102,7 +99,7 @@ foreach(VER RANGE 1 9)

set_target_properties(${TargetName} PROPERTIES LINKER_LANGUAGE CXX)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
set_target_properties(${TargetName} PROPERTIES CUDA_STANDARD 20)
endif()

Expand Down
17 changes: 7 additions & 10 deletions Tutorials/Reduction/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
cmake_minimum_required(VERSION 3.25.2)
if("${GPU_RUNTIME}" STREQUAL "CUDA")
cmake_minimum_required(VERSION 3.25.2)
else()
cmake_minimum_required(VERSION 3.21)
endif()

project(reduction_tests LANGUAGES CXX)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd")
cmake_minimum_required(VERSION 3.21)
# Add -fPIE flag to compiler.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

project(reduction_tests LANGUAGES CXX)

include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake")
select_gpu_language()

Expand Down Expand Up @@ -63,7 +60,7 @@ set(include_dirs "../../../Common")
list(APPEND include_dirs "${PROJECT_SOURCE_DIR}")

# For examples targeting NVIDIA, include the HIP header directory.
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
list(APPEND include_dirs "${ROCM_ROOT}/include")
endif()

Expand Down Expand Up @@ -154,7 +151,7 @@ foreach(VER RANGE 1 10)
$<$<TARGET_EXISTS:TBB::tbb>:TBB::tbb>
)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
if("${GPU_RUNTIME}" STREQUAL "CUDA")
set_source_files_properties(
${Sources}
PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE}
Expand Down

0 comments on commit 38d117d

Please sign in to comment.