From b8dd3b208a6ac3d764050d5b504226758974380f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Apr 2025 12:08:48 -0400 Subject: [PATCH] clang-format: Apply formatting to HIP sources with .hip extension --- .gitattributes | 1 + Tests/HIP/InferHipLang1/interface.hip | 3 +-- Tests/HIP/InferHipLang2/interface.hip | 3 +-- Tests/HIP/MathFunctions/main.hip | 22 ++++++++++++---------- Tests/HIP/MixedLanguage/shared.hip | 4 +--- Tests/HIP/MixedLanguage/static.hip | 7 ++----- Tests/HIP/TryCompile/device_function.hip | 2 +- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.gitattributes b/.gitattributes index 0e7ab060a3..d414c68fa5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -60,6 +60,7 @@ coverage.xml.in tab-indent *.H our-c-style *.h our-c-style *.hh our-c-style +*.hip our-c-style *.hpp our-c-style *.hxx our-c-style *.notcu our-c-style diff --git a/Tests/HIP/InferHipLang1/interface.hip b/Tests/HIP/InferHipLang1/interface.hip index 6ac8641cca..21b7b0b505 100644 --- a/Tests/HIP/InferHipLang1/interface.hip +++ b/Tests/HIP/InferHipLang1/interface.hip @@ -1,15 +1,14 @@ #include #include + #include static __global__ void fake_hip_kernel() { } - int __host__ interface_hip_func(int x) { - fake_hip_kernel<<<1, 1>>>(); bool valid = (hipSuccess == hipGetLastError()); if (!valid) { diff --git a/Tests/HIP/InferHipLang2/interface.hip b/Tests/HIP/InferHipLang2/interface.hip index 6ac8641cca..21b7b0b505 100644 --- a/Tests/HIP/InferHipLang2/interface.hip +++ b/Tests/HIP/InferHipLang2/interface.hip @@ -1,15 +1,14 @@ #include #include + #include static __global__ void fake_hip_kernel() { } - int __host__ interface_hip_func(int x) { - fake_hip_kernel<<<1, 1>>>(); bool valid = (hipSuccess == hipGetLastError()); if (!valid) { diff --git a/Tests/HIP/MathFunctions/main.hip b/Tests/HIP/MathFunctions/main.hip index dae89fc3cf..149cfc1767 100644 --- a/Tests/HIP/MathFunctions/main.hip +++ b/Tests/HIP/MathFunctions/main.hip @@ -1,15 +1,15 @@ - -#include #include -#include #include +#include -#include #include +#include +#include namespace { -template -__global__ void global_entry_point(F f, T *out) { +template +__global__ void global_entry_point(F f, T* out) +{ *out = f(); } @@ -23,7 +23,9 @@ bool verify(F f, T expected) } bool result = true; hipLaunchKernelGGL(global_entry_point, 1, 1, 0, 0, f, gpu_T); - result = hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost) == hipSuccess && result; + result = hipMemcpy(cpu_T.get(), gpu_T, sizeof(T), hipMemcpyDeviceToHost) == + hipSuccess && + result; result = hipFree(gpu_T) == hipSuccess && result; result = *cpu_T == expected && result; return result; @@ -32,9 +34,9 @@ bool verify(F f, T expected) int main(int argc, char** argv) { - bool valid = verify([]__device__(){ return std::round(1.4f); }, 1.0f); - valid &= verify([]__device__(){ return max<_Float16>(1.0f, 2.0f); }, 2.0f); - valid &= verify([]__device__(){ return min<_Float16>(1.0f, 2.0f); }, 1.0f); + bool valid = verify([] __device__() { return std::round(1.4f); }, 1.0f); + valid &= verify([] __device__() { return max<_Float16>(1.0f, 2.0f); }, 2.0f); + valid &= verify([] __device__() { return min<_Float16>(1.0f, 2.0f); }, 1.0f); if (valid) { return 0; diff --git a/Tests/HIP/MixedLanguage/shared.hip b/Tests/HIP/MixedLanguage/shared.hip index e6fea9fe21..4b0454d495 100644 --- a/Tests/HIP/MixedLanguage/shared.hip +++ b/Tests/HIP/MixedLanguage/shared.hip @@ -1,5 +1,6 @@ #include #include + #include #ifdef _WIN32 @@ -8,15 +9,12 @@ # define EXPORT #endif - static __global__ void fake_hip_kernel() { } - int __host__ shared_hip_func(int x) { - fake_hip_kernel<<<1, 1>>>(); bool valid = (hipSuccess == hipGetLastError()); if (!valid) { diff --git a/Tests/HIP/MixedLanguage/static.hip b/Tests/HIP/MixedLanguage/static.hip index 359b9facda..8664a62f38 100644 --- a/Tests/HIP/MixedLanguage/static.hip +++ b/Tests/HIP/MixedLanguage/static.hip @@ -1,17 +1,14 @@ - -#include #include -#include +#include +#include static __global__ void fake_hip_kernel() { } - int __host__ static_hip_func(int x) { - fake_hip_kernel<<<1, 1>>>(); bool valid = (hipSuccess == hipGetLastError()); if (!valid) { diff --git a/Tests/HIP/TryCompile/device_function.hip b/Tests/HIP/TryCompile/device_function.hip index 7c1205e6d7..f8b97a6a73 100644 --- a/Tests/HIP/TryCompile/device_function.hip +++ b/Tests/HIP/TryCompile/device_function.hip @@ -1,4 +1,5 @@ #include + #include static __global__ void fake_hip_kernel() @@ -7,7 +8,6 @@ static __global__ void fake_hip_kernel() int __host__ try_compile_hip_func(int x) { - fake_hip_kernel<<<1, 1>>>(); bool valid = (hipSuccess == hipGetLastError()); if (!valid) {