Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake-format to CI #121

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

color: false
definitions: []
indent: 4
line_length: 80
list_expansion: favour-inlining
quiet: false
unsafe: false
workers: 12
31 changes: 25 additions & 6 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,35 @@ name: Linting
on:
push:
branches:
- develop
- main
- 'release/rocm-rel*'
- develop
- main
- 'release/rocm-rel*'
pull_request:
branches:
- develop
- main
- 'release/roc-rel*'
- develop
- main
- 'release/rocm-rel*'

jobs:
call-workflow-passing-data:
name: Documentation
uses: ROCm/rocm-docs-core/.github/workflows/linting.yml@develop

cmake-formatting:
name: CMake File Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
python3 -m pip install gersemi
- name: Run gersemi
run: |
gersemi --check .
if [ $? -ne 0 ]; then
echo "CMake files are not formatted correctly. Please run gersemi ..."
echo "For example: \`gersemi -i .\`"
exit 1
fi
18 changes: 14 additions & 4 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 Down Expand Up @@ -30,7 +30,9 @@ 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 +42,17 @@ 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: 14 additions & 4 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 Down Expand Up @@ -30,7 +30,9 @@ 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 +42,17 @@ 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: 14 additions & 4 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 Down Expand Up @@ -30,7 +30,9 @@ 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 +42,17 @@ 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: 14 additions & 4 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 Down Expand Up @@ -30,7 +30,9 @@ 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 +42,17 @@ 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: 15 additions & 4 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 Down Expand Up @@ -30,7 +30,10 @@ 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 +42,17 @@ 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: 14 additions & 4 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 Down Expand Up @@ -30,7 +30,9 @@ 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 +42,17 @@ 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
57 changes: 36 additions & 21 deletions HIP-Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,64 @@ 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)
if(NOT "${GPU_RUNTIME}" STREQUAL "CUDA")

# Make sure the dependencies can be found before building.
find_program(
LLVM_DIS_COMMAND llvm-dis
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
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
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.")
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
Loading
Loading