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
@@ -46,8 +46,7 @@ static __global__ void device_function(float* C_d, float* A_d, size_t Num) {
}
}
static void HIPRT_CB Thread1_Callback(hipStream_t stream, hipError_t status,
void* userData) {
static void HIPRT_CB Thread1_Callback(hipStream_t stream, hipError_t status, void* userData) {
HIPASSERT(stream == mystream);
HIPASSERT(userData == nullptr);
HIPCHECK(status);
@@ -63,8 +62,7 @@ static void HIPRT_CB Thread1_Callback(hipStream_t stream, hipError_t status,
++Cb_count;
}
static void HIPRT_CB Thread2_Callback(hipStream_t stream, hipError_t status,
void* userData) {
static void HIPRT_CB Thread2_Callback(hipStream_t stream, hipError_t status, void* userData) {
HIPASSERT(stream == mystream);
HIPASSERT(userData == nullptr);
HIPCHECK(status);
@@ -80,13 +78,9 @@ static void HIPRT_CB Thread2_Callback(hipStream_t stream, hipError_t status,
++Cb_count;
}
void Thread1_func() {
HIPCHECK(hipStreamAddCallback(mystream, Thread1_Callback, nullptr, 0));
}
void Thread1_func() { HIPCHECK(hipStreamAddCallback(mystream, Thread1_Callback, nullptr, 0)); }
void Thread2_func() {
HIPCHECK(hipStreamAddCallback(mystream, Thread2_Callback, nullptr, 0));
}
void Thread2_func() { HIPCHECK(hipStreamAddCallback(mystream, Thread2_Callback, nullptr, 0)); }
/**
Test multiple hipStreamAddCallback() called over
@@ -110,30 +104,24 @@ TEST_CASE("Unit_hipStreamAddCallback_MultipleThreads") {
HIP_CHECK(hipMalloc(&A_d, Nbytes));
HIP_CHECK(hipMalloc(&C_d, Nbytes));
HIP_CHECK(
hipStreamCreateWithFlags(&mystream, hipStreamNonBlocking));
HIP_CHECK(hipStreamCreateWithFlags(&mystream, hipStreamNonBlocking));
HIP_CHECK(
hipMemcpyAsync(A_d, A1_h, Nbytes, hipMemcpyHostToDevice,
mystream));
HIP_CHECK(hipMemcpyAsync(A_d, A1_h, Nbytes, hipMemcpyHostToDevice, mystream));
constexpr unsigned threadsPerBlock = 256;
constexpr unsigned blocks = (N + 255)/threadsPerBlock;
constexpr unsigned blocks = (N + 255) / threadsPerBlock;
hipLaunchKernelGGL((device_function), dim3(blocks),
dim3(threadsPerBlock), 0,
mystream, C_d, A_d, N);
hipLaunchKernelGGL((device_function), dim3(blocks), dim3(threadsPerBlock), 0, mystream, C_d, A_d,
N);
LaunchDelayKernel(std::chrono::milliseconds(2000), mystream);
HIP_CHECK(hipGetLastError());
HIP_CHECK(
hipMemcpyAsync(C1_h, C_d, Nbytes,
hipMemcpyDeviceToHost, mystream));
HIP_CHECK(hipMemcpyAsync(C1_h, C_d, Nbytes, hipMemcpyDeviceToHost, mystream));
std::thread *T = new std::thread[numThreads];
std::thread* T = new std::thread[numThreads];
for (int i = 0; i < numThreads; i++) {
// Use different callback for every even thread
// The callbacks will be added to same stream from different threads
if ((i%2) == 0)
if ((i % 2) == 0)
T[i] = std::thread(Thread1_func);
else
T[i] = std::thread(Thread2_func);