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 source format linting to the GitHub workflows #140

Merged
merged 18 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
27 changes: 27 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
- main
- 'release/rocm-rel*'

env:
CLANG_FORMAT: /usr/lib/llvm-18/bin/clang-format

jobs:
call-workflow-passing-data:
name: Documentation
Expand All @@ -35,3 +38,27 @@ jobs:
echo "For example: \`gersemi -i .\`"
exit 1
fi

source-formatting:
name: Source Code Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y git wget
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | sudo tee -a /etc/apt/sources.list.d/llvm-18.list
sudo echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | sudo tee -a /etc/apt/sources.list.d/llvm-18.list
sudo apt-get update -qq
sudo apt-get install -y clang-format-18
sudo apt-get install -y clang-tools-18 # Install git-clang-format
- name: Fetch all branches
run: git fetch --all
- name: Run clang-format
env:
GIT_CLANG_FORMAT: /usr/lib/llvm-18/bin/git-clang-format
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
Scripts/CodeFormat/check_format.sh origin/`if [[ "${{ github.event_name }}" == "push" ]]; then echo "develop"; else echo "${{ github.base_ref }}"; fi` --binary ${{env.CLANG_FORMAT}}
7 changes: 4 additions & 3 deletions Common/hipsolver_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ inline const char* hipsolverStatusToString(hipsolverStatus_t status)
case HIPSOLVER_STATUS_HANDLE_IS_NULLPTR: return "HIPSOLVER_STATUS_HANDLE_IS_NULLPTR";
case HIPSOLVER_STATUS_INVALID_ENUM: return "HIPSOLVER_STATUS_INVALID_ENUM";
case HIPSOLVER_STATUS_UNKNOWN: return "HIPSOLVER_STATUS_UNKNOWN";
#if (hipsolverVersionMajor == 1 && hipsolverVersionMinor >= 8) || hipsolverVersionMajor >= 2
#if(hipsolverVersionMajor == 1 && hipsolverVersionMinor >= 8) || hipsolverVersionMajor >= 2
case HIPSOLVER_STATUS_ZERO_PIVOT: return "HIPSOLVER_STATUS_ZERO_PIVOT";
#endif
#if (hipsolverVersionMajor >= 2 && hipsolverVersionMinor >= 1)
case HIPSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED : return "HIPSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
#if(hipsolverVersionMajor >= 2 && hipsolverVersionMinor >= 1)
case HIPSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
return "HIPSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
#endif
// We do use default because we are not in control of these enumeration values.
// Ideally this function is something hipsolver would provide
Expand Down
5 changes: 3 additions & 2 deletions Common/rocsparse_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ inline const char* rocsparse_status_to_string(rocsparse_status status)
case rocsparse_status_zero_pivot: return "rocsparse_status_zero_pivot";
case rocsparse_status_not_initialized: return "rocsparse_status_not_initialized";
case rocsparse_status_type_mismatch: return "rocsparse_status_type_mismatch";
case rocsparse_status_thrown_exception: return "rocsparse_status_thrown_exception";
case rocsparse_status_thrown_exception:
return "rocsparse_status_thrown_exception";
// rocSPARSE 3.0 adds new status
#if ROCSPARSE_VERSION_MAJOR >= 3
case rocsparse_status_continue: return "rocsparse_status_continue";
Expand All @@ -64,7 +65,7 @@ inline const char* rocsparse_status_to_string(rocsparse_status status)
/// with an error code.
#define ROCSPARSE_CHECK(condition) \
{ \
const rocsparse_status status = (condition); \
const rocsparse_status status = (condition); \
if(status != rocsparse_status_success) \
{ \
std::cerr << "rocSPARSE error encountered: \"" << rocsparse_status_to_string(status) \
Expand Down
3 changes: 2 additions & 1 deletion HIP-Basic/vulkan_interop/main.hip
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 @@ -62,6 +62,7 @@
#ifndef USE_SIGNAL_SEMAPHORE
#if defined(__HIP_PLATFORM_AMD__) && defined(_WIN64)
#define USE_SIGNAL_SEMAPHORE 0

#else
#define USE_SIGNAL_SEMAPHORE 1
#endif
Expand Down
5 changes: 2 additions & 3 deletions Libraries/hipSOLVER/sygvj/main.cpp
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 @@ -159,8 +159,7 @@ int main(const int /*argc*/, char* /*argv*/[])
int executed_sweeps{};

HIPSOLVER_CHECK(hipsolverXsyevjGetResidual(hipsolver_handle, syevj_params, &residual));
HIPSOLVER_CHECK(
hipsolverXsyevjGetSweeps(hipsolver_handle, syevj_params, &executed_sweeps));
HIPSOLVER_CHECK(hipsolverXsyevjGetSweeps(hipsolver_handle, syevj_params, &executed_sweeps));

std::cout << "Residual = " << residual << std::endl;
std::cout << "Number of executed sweeps = " << executed_sweeps << std::endl;
Expand Down
13 changes: 7 additions & 6 deletions Libraries/rocSPARSE/level_2/gemvi/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ int main()
// ( 0.0 )

// Dense matrix A in column-major
constexpr rocsparse_int A_rows = 3;
constexpr rocsparse_int A_cols = 5;
constexpr std::array<double, A_rows* A_cols> A
constexpr rocsparse_int A_rows = 3;
constexpr rocsparse_int A_cols = 5;
constexpr std::array<double, A_rows * A_cols> A
= {9, 14, 19, 10, 15, 20, 11, 16, 21, 12, 17, 22, 13, 18, 23};

constexpr rocsparse_int lda = A_rows;

// Sparse vector x
constexpr rocsparse_int x_non_zero = 3;
constexpr std::array<double, x_non_zero> x_values = {1, 2, 3};
constexpr std::array<rocsparse_int, x_non_zero> x_indices = {0, 1, 3};
constexpr rocsparse_int x_non_zero = 3;
constexpr std::array<double, x_non_zero> x_values = {1, 2, 3};

constexpr std::array<rocsparse_int, x_non_zero> x_indices = {0, 1, 3};

// Dense vector y
constexpr std::array<double, A_rows> y = {4, 5, 6};
Expand Down
4 changes: 2 additions & 2 deletions Scripts/CodeFormat/check_format.sh
dgaliffiAMD marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ grep '^no modified files to format$\|^clang-format did not modify any files$' \
# Dump formatting diff and signal failure
printf \
"\033[31m==== FORMATTING VIOLATIONS DETECTED ====\033[0m
run '\033[33m%s --style=file %s %s\033[0m' to apply these formating changes\n\n" \
run '\033[33m%s --style=file %s %s\033[0m' to apply these formatting changes\n\n" \
"$GIT_CLANG_FORMAT" "$*" "$SOURCE_COMMIT"

cat "$scratch"
exit 1
exit 1
Beanavil marked this conversation as resolved.
Show resolved Hide resolved
Loading