Skip to content

Commit

Permalink
Fix failures in CMake linting
Browse files Browse the repository at this point in the history
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
  • Loading branch information
dgaliffiAMD committed Jun 3, 2024
1 parent a3b20fa commit be2c1a4
Show file tree
Hide file tree
Showing 109 changed files with 1,317 additions and 706 deletions.
18 changes: 13 additions & 5 deletions Applications/bitonic_sort/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,16 @@ set(example_name applications_bitonic_sort)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
set(ERROR_MESSAGE
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
)
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

Expand All @@ -40,9 +44,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
18 changes: 13 additions & 5 deletions Applications/convolution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,16 @@ set(example_name applications_convolution)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
set(ERROR_MESSAGE
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
)
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

Expand All @@ -40,9 +44,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
17 changes: 12 additions & 5 deletions Applications/floyd_warshall/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,15 @@ set(example_name applications_floyd_warshall)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\n
GPU_RUNTIME must be either HIP or CUDA.")
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

Expand All @@ -40,9 +43,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
18 changes: 13 additions & 5 deletions Applications/histogram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,16 @@ set(example_name applications_histogram)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
set(ERROR_MESSAGE
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
)
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

Expand All @@ -40,9 +44,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
19 changes: 14 additions & 5 deletions Applications/monte_carlo_pi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,17 @@ set(example_name applications_monte_carlo_pi)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
message(FATAL_ERROR "Only the following values are accepted for GPU_RUNTIME: ${GPU_RUNTIMES}")
message(
FATAL_ERROR
"Only the following values are accepted for GPU_RUNTIME: ${GPU_RUNTIMES}"
)
endif()

enable_language(${GPU_RUNTIME})
Expand All @@ -39,9 +44,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
18 changes: 13 additions & 5 deletions Applications/prefix_sum/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,12 +25,16 @@ set(example_name applications_prefix_sum)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_name} LANGUAGES CXX)

set(GPU_RUNTIME "HIP" CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIME
"HIP"
CACHE STRING "Switches between HIP and CUDA")
set(GPU_RUNTIMES "HIP" "CUDA")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})

if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA.")
set(ERROR_MESSAGE
"GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP or CUDA."
)
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()

Expand All @@ -40,9 +44,13 @@ set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)

if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
Expand Down
45 changes: 26 additions & 19 deletions HIP-Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ project(HIP-Basic LANGUAGES CXX)

# ROCm installation path
if(WIN32)
set(ROCM_ROOT "$ENV{HIP_PATH}" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"$ENV{HIP_PATH}"
CACHE PATH "Root directory of the ROCm installation")
else()
set(ROCM_ROOT "/opt/rocm" CACHE PATH "Root directory of the ROCm installation")
set(ROCM_ROOT
"/opt/rocm"
CACHE PATH "Root directory of the ROCm installation")
endif()

# Only supported on HIP (not CUDA)
Expand All @@ -37,37 +41,39 @@ if(NOT "${GPU_RUNTIME}" STREQUAL "CUDA")
find_program(
LLVM_DIS_COMMAND llvm-dis
PATH_SUFFIXES bin
PATHS
${ROCM_ROOT}/llvm
${CMAKE_INSTALL_PREFIX}/llvm)
PATHS ${ROCM_ROOT}/llvm ${CMAKE_INSTALL_PREFIX}/llvm)
find_program(
OFFLOAD_BUNDLER_COMMAND clang-offload-bundler
PATH_SUFFIXES bin
PATHS
${ROCM_ROOT}/llvm
${CMAKE_INSTALL_PREFIX}/llvm)
PATHS ${ROCM_ROOT}/llvm ${CMAKE_INSTALL_PREFIX}/llvm)
find_program(
LLVM_MC_COMMAND llvm-mc
PATH_SUFFIXES bin
PATHS
${ROCM_ROOT}/llvm
${CMAKE_INSTALL_PREFIX}/llvm)
PATHS ${ROCM_ROOT}/llvm ${CMAKE_INSTALL_PREFIX}/llvm)

if(LLVM_DIS_COMMAND AND OFFLOAD_BUNDLER_COMMAND AND LLVM_MC_COMMAND)
add_subdirectory(llvm_ir_to_executable)
else()
message("'llvm-dis', 'llvm-mc', or 'clang-offload-bundler' not found, not building assembly example.")
if(LLVM_DIS_COMMAND
AND OFFLOAD_BUNDLER_COMMAND
AND LLVM_MC_COMMAND)
add_subdirectory(llvm_ir_to_executable)
else()
message(
"'llvm-dis', 'llvm-mc', or 'clang-offload-bundler' not found, not building assembly example."
)
if(NOT WIN32)
message(" These tools can be found in the 'rocm-llvm-dev' package.")
message(
" These tools can be found in the 'rocm-llvm-dev' package.")
endif()
endif()

if(OFFLOAD_BUNDLER_COMMAND AND LLVM_MC_COMMAND)
add_subdirectory(assembly_to_executable)
else()
message("'llvm-mc' or 'clang-offload-bundler' not found, not building LLVM IR example.")
message(
"'llvm-mc' or 'clang-offload-bundler' not found, not building LLVM IR example."
)
if(NOT WIN32)
message(" These tools can be found in the 'rocm-llvm-dev' package.")
message(
" These tools can be found in the 'rocm-llvm-dev' package.")
endif()
endif()

Expand Down Expand Up @@ -107,7 +113,8 @@ add_subdirectory(occupancy)
add_subdirectory(runtime_compilation)
add_subdirectory(saxpy)
add_subdirectory(shared_memory)
# We cannot build the static library on Windows as the HIP SDK does not include CMAKE_AR.
# We cannot build the static library on Windows as the HIP SDK does not include
# CMAKE_AR.
if(NOT WIN32 AND NOT "${GPU_RUNTIME}" STREQUAL "HIP")
add_subdirectory(static_host_library)
endif()
Expand Down
Loading

0 comments on commit be2c1a4

Please sign in to comment.