SWDEV-470698 - fix formatting, add format check workflow (#657)

This commit is contained in:
Danylo Lytovchenko
2025-08-20 16:28:06 +02:00
committed by GitHub
parent 5840940caa
commit f7338717ae
1574 changed files with 162972 additions and 199346 deletions
@@ -20,7 +20,7 @@ THE SOFTWARE.
#include <hip_test_kernels.hh>
#include <hip_test_checkers.hh>
#include <hip_test_common.hh>
#pragma clang diagnostic ignored "-Wunused-parameter"
@@ -29,32 +29,29 @@ unsigned threadsPerBlock = 256;
template <unsigned batch, typename T>
__device__ void sum(T* sdata, unsigned groupElements, unsigned tid) {
T tmp;
if (groupElements < batch)
return;
if (groupElements < batch) return;
// sdata[tid] += sdata[tid - batch/2] does not work when block size is
// greater than wave size because one wave may complete before another
// wave.
if (tid >= batch/2 && tid < groupElements)
tmp = sdata[tid - batch/2];
if (tid >= batch / 2 && tid < groupElements) tmp = sdata[tid - batch / 2];
__syncthreads();
if (tid >= batch/2 && tid < groupElements)
sdata[tid] += tmp;
if (tid >= batch / 2 && tid < groupElements) sdata[tid] += tmp;
__syncthreads();
}
template <typename T>
__global__ void testExternSharedKernel(const T* A_d, const T* B_d, T* C_d,
size_t numElements, size_t groupElements) {
__global__ void testExternSharedKernel(const T* A_d, const T* B_d, T* C_d, size_t numElements,
size_t groupElements) {
// declare dynamic shared memory
extern __shared__ double sdata0[];
T* sdata = reinterpret_cast<T *>(sdata0);
T* sdata = reinterpret_cast<T*>(sdata0);
size_t gid = (blockIdx.x * blockDim.x + threadIdx.x);
size_t tid = threadIdx.x;
// initialize dynamic shared memory
if (tid < groupElements) {
sdata[tid] = static_cast<T>(tid);
sdata[tid] = static_cast<T>(tid);
}
__syncthreads();
@@ -71,15 +68,14 @@ __global__ void testExternSharedKernel(const T* A_d, const T* B_d, T* C_d,
C_d[gid] = A_d[gid] + B_d[gid] + sdata[tid % groupElements];
}
template <typename T>
void testExternShared(size_t N, unsigned groupElements) {
template <typename T> void testExternShared(size_t N, unsigned groupElements) {
size_t Nbytes = N * sizeof(T);
T *A_d, *B_d, *C_d;
T *A_h, *B_h, *C_h;
HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false);
unsigned blocks = N/threadsPerBlock;
unsigned blocks = N / threadsPerBlock;
assert(N == blocks * threadsPerBlock);
HIP_CHECK(hipMemcpy(A_d, A_h, Nbytes, hipMemcpyHostToDevice));
@@ -90,8 +86,7 @@ void testExternShared(size_t N, unsigned groupElements) {
// launch kernel with dynamic shared memory
hipLaunchKernelGGL(HIP_KERNEL_NAME(testExternSharedKernel<T>), dim3(blocks),
dim3(threadsPerBlock), groupMemBytes, 0, A_d, B_d, C_d,
N, groupElements);
dim3(threadsPerBlock), groupMemBytes, 0, A_d, B_d, C_d, N, groupElements);
HIP_CHECK(hipDeviceSynchronize());
HIP_CHECK(hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost));
@@ -164,13 +159,12 @@ TEST_CASE("Unit_hipDynamicShared") {
SECTION("test case with float for max LDS size") {
int maxLDS = 0;
HIP_CHECK(hipDeviceGetAttribute(&maxLDS,
hipDeviceAttributeMaxSharedMemoryPerBlock, 0));
testExternShared<float>(1024, maxLDS/sizeof(float));
HIP_CHECK(hipDeviceGetAttribute(&maxLDS, hipDeviceAttributeMaxSharedMemoryPerBlock, 0));
testExternShared<float>(1024, maxLDS / sizeof(float));
}
}
/**
* End doxygen group KernelTest.
* @}
*/
* End doxygen group KernelTest.
* @}
*/