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
@@ -22,10 +22,10 @@ THE SOFTWARE.
#include <hip_test_common.hh>
#include <hip_test_kernels.hh>
#include <stdlib.h>
constexpr size_t buffer_size = (1024*1024);
constexpr size_t buffer_size = (1024 * 1024);
constexpr int test_iteration_hstvismem = 5;
constexpr int test_iteration_noncohmem = 10;
constexpr int block_size = 512;
@@ -51,17 +51,16 @@ constexpr int block_size = 512;
*/
TEST_CASE("Unit_hipEventCreateWithFlags_Positive") {
#if HT_AMD
const unsigned int flagUnderTest = GENERATE(hipEventDefault,
hipEventBlockingSync, hipEventDisableTiming,
hipEventInterprocess | hipEventDisableTiming,
hipEventReleaseToDevice, hipEventReleaseToSystem);
const unsigned int flagUnderTest =
GENERATE(hipEventDefault, hipEventBlockingSync, hipEventDisableTiming,
hipEventInterprocess | hipEventDisableTiming, hipEventReleaseToDevice,
hipEventReleaseToSystem);
#else
// On Non-AMD platforms hipEventReleaseToDevice / hipEventReleaseToSystem
// are not defined.
const unsigned int flagUnderTest = GENERATE(hipEventDefault,
hipEventBlockingSync,
hipEventDisableTiming,
hipEventInterprocess | hipEventDisableTiming);
const unsigned int flagUnderTest =
GENERATE(hipEventDefault, hipEventBlockingSync, hipEventDisableTiming,
hipEventInterprocess | hipEventDisableTiming);
#endif
hipEvent_t event;
@@ -82,11 +81,7 @@ enum class eSyncToTest {
eEventSynchronize
};
enum class eMemoryToTest {
eHostVisibleMemory,
eNonCoherentHostMemory,
eCoherentHostMemory
};
enum class eMemoryToTest { eHostVisibleMemory, eNonCoherentHostMemory, eCoherentHostMemory };
static void init_input(int* a, size_t size) {
unsigned int seed = time(nullptr);
@@ -97,12 +92,11 @@ static void init_input(int* a, size_t size) {
static void check_output(int* inp, int* out, size_t size) {
for (size_t i = 0; i < size; i++) {
REQUIRE(out[i] == (inp[i]*inp[i]));
REQUIRE(out[i] == (inp[i] * inp[i]));
}
}
// local function
static void testMemCoherency(eSyncToTest test, eMemoryToTest mem,
uint32_t flags) {
static void testMemCoherency(eSyncToTest test, eMemoryToTest mem, uint32_t flags) {
hipDeviceProp_t prop;
HIP_CHECK(hipGetDeviceProperties(&prop, 0));
// If the GPU is not large bar then exit the test
@@ -111,8 +105,7 @@ static void testMemCoherency(eSyncToTest test, eMemoryToTest mem,
return;
}
constexpr auto blocksPerCU = 6;
unsigned grid_size = HipTest::setNumBlocks(blocksPerCU,
block_size, buffer_size);
unsigned grid_size = HipTest::setNumBlocks(blocksPerCU, block_size, buffer_size);
hipEvent_t event;
HIP_CHECK(hipEventCreateWithFlags(&event, flags));
hipStream_t stream;
@@ -122,24 +115,20 @@ static void testMemCoherency(eSyncToTest test, eMemoryToTest mem,
REQUIRE(ibuf_h != nullptr);
int total_iter = 0;
if (mem == eMemoryToTest::eHostVisibleMemory) {
HIP_CHECK(hipMalloc(&buf_d, buffer_size*sizeof(int)));
HIP_CHECK(hipMalloc(&buf_d, buffer_size * sizeof(int)));
total_iter = test_iteration_hstvismem;
} else if (mem == eMemoryToTest::eNonCoherentHostMemory) {
HIP_CHECK(hipHostMalloc(&buf_d, buffer_size*sizeof(int),
hipHostMallocNonCoherent));
HIP_CHECK(hipHostMalloc(&buf_d, buffer_size * sizeof(int), hipHostMallocNonCoherent));
total_iter = test_iteration_noncohmem;
} else if (mem == eMemoryToTest::eCoherentHostMemory) {
HIP_CHECK(hipHostMalloc(&buf_d, buffer_size*sizeof(int),
hipHostMallocCoherent));
HIP_CHECK(hipHostMalloc(&buf_d, buffer_size * sizeof(int), hipHostMallocCoherent));
total_iter = test_iteration_noncohmem;
}
for (int iter = 0; iter < total_iter; iter++) {
// Inititalize the buffer with random data
init_input(ibuf_h, buffer_size);
HIP_CHECK(hipMemcpy(buf_d, ibuf_h, sizeof(int)*buffer_size,
hipMemcpyDefault));
HipTest::vector_square<int><<<grid_size, block_size, 0, stream>>>(
buf_d, buf_d, buffer_size);
HIP_CHECK(hipMemcpy(buf_d, ibuf_h, sizeof(int) * buffer_size, hipMemcpyDefault));
HipTest::vector_square<int><<<grid_size, block_size, 0, stream>>>(buf_d, buf_d, buffer_size);
HIP_CHECK(hipEventRecord(event, stream));
// test different synchronization APIs
if (test == eSyncToTest::eStreamSynchronize) {
@@ -159,7 +148,7 @@ static void testMemCoherency(eSyncToTest test, eMemoryToTest mem,
if (mem == eMemoryToTest::eHostVisibleMemory) {
HIP_CHECK(hipFree(buf_d));
} else if ((mem == eMemoryToTest::eNonCoherentHostMemory) ||
(mem == eMemoryToTest::eCoherentHostMemory)) {
(mem == eMemoryToTest::eCoherentHostMemory)) {
HIP_CHECK(hipHostFree(buf_d));
}
}
@@ -182,13 +171,13 @@ static void testMemCoherency(eSyncToTest test, eMemoryToTest mem,
TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_HstVisMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eHostVisibleMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eHostVisibleMemory,
hipEventDisableSystemFence);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eHostVisibleMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eHostVisibleMemory,
hipEventDisableSystemFence);
}
}
@@ -209,18 +198,18 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_HstVisMem") {
TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_HstVisMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eHostVisibleMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eHostVisibleMemory,
hipEventDefault);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eHostVisibleMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eHostVisibleMemory,
hipEventDefault);
}
SECTION("Check with hipEventSynchronize") {
INFO("Check with hipEventSynchronize");
testMemCoherency(eSyncToTest::eEventSynchronize,
eMemoryToTest::eHostVisibleMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eEventSynchronize, eMemoryToTest::eHostVisibleMemory,
hipEventDefault);
}
}
@@ -241,13 +230,13 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_HstVisMem") {
TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_NonCohHstMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eNonCoherentHostMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eNonCoherentHostMemory,
hipEventDisableSystemFence);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eNonCoherentHostMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eNonCoherentHostMemory,
hipEventDisableSystemFence);
}
}
@@ -269,18 +258,18 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_NonCohHstMem") {
TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_NonCohHstMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eNonCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eNonCoherentHostMemory,
hipEventDefault);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eNonCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eNonCoherentHostMemory,
hipEventDefault);
}
SECTION("Check with hipEventSynchronize") {
INFO("Check with hipEventSynchronize");
testMemCoherency(eSyncToTest::eEventSynchronize,
eMemoryToTest::eNonCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eEventSynchronize, eMemoryToTest::eNonCoherentHostMemory,
hipEventDefault);
}
}
@@ -301,18 +290,18 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_NonCohHstMem") {
TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_CohHstMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDisableSystemFence);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDisableSystemFence);
}
SECTION("Check with hipEventSynchronize") {
INFO("Check with hipEventSynchronize");
testMemCoherency(eSyncToTest::eEventSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDisableSystemFence);
testMemCoherency(eSyncToTest::eEventSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDisableSystemFence);
}
}
@@ -333,18 +322,18 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DisableSystemFence_CohHstMem") {
TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_CohHstMem") {
SECTION("Check with hipStreamSynchronize") {
INFO("Check with hipStreamSynchronize");
testMemCoherency(eSyncToTest::eStreamSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eStreamSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDefault);
}
SECTION("Check with hipDeviceSynchronize") {
INFO("Check with hipDeviceSynchronize");
testMemCoherency(eSyncToTest::eDeviceSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eDeviceSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDefault);
}
SECTION("Check with hipEventSynchronize") {
INFO("Check with hipEventSynchronize");
testMemCoherency(eSyncToTest::eEventSynchronize,
eMemoryToTest::eCoherentHostMemory, hipEventDefault);
testMemCoherency(eSyncToTest::eEventSynchronize, eMemoryToTest::eCoherentHostMemory,
hipEventDefault);
}
}
#endif
@@ -385,4 +374,3 @@ TEST_CASE("Unit_hipEventCreateWithFlags_Verify_Capture") {
* End doxygen group hipEventCreateWithFlags.
* @}
*/