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

此提交包含在:
Danylo Lytovchenko
2025-08-20 16:28:06 +02:00
提交者 GitHub
父節點 5840940caa
當前提交 f7338717ae
共有 1574 個檔案被更改,包括 162972 行新增 和 199346 行删除
+55 -99
查看文件
@@ -45,29 +45,23 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_Basic") {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *hData{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, &hData, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, &hData, nullptr, width * NUM_H,
false);
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
HipTest::setDefaultData<float>(width*NUM_H, A_h, hData, nullptr);
HipTest::setDefaultData<float>(width * NUM_H, A_h, hData, nullptr);
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, hData, width,
width, NUM_H,
hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, hData, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d, 0, 0, width, NUM_H, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(A_h, hData, NUM_W, NUM_H) == true);
// Cleaning the memory
HIP_CHECK(hipFreeArray(A_d));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, hData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, hData, nullptr, false);
}
/*
@@ -79,22 +73,19 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_ExtentValidation") {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *hData{nullptr}, *valData{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, &hData, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
nullptr, &valData, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, &hData, nullptr, width * NUM_H,
false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, nullptr, &valData, nullptr, width * NUM_H,
false);
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
SECTION("Destination width is 0") {
REQUIRE(hipMemcpy2DFromArray(A_h, 0, A_d,
0, 0, NUM_W*sizeof(float),
NUM_H, hipMemcpyDeviceToHost) != hipSuccess);
REQUIRE(hipMemcpy2DFromArray(A_h, 0, A_d, 0, 0, NUM_W * sizeof(float), NUM_H,
hipMemcpyDeviceToHost) != hipSuccess);
}
// hipMemcpy2DFromArray API would return success for width and height as 0
// and does not perform any copy
@@ -104,12 +95,8 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_ExtentValidation") {
// with height 0(copy will not be performed)
// 3 validating hData<-->A_h which will not be equal as copy is not done.
SECTION("Height is 0") {
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0,
A_h, width, width,
NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(hData, width, A_d,
0, 0, width,
0, hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, A_h, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(hData, width, A_d, 0, 0, width, 0, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(hData, valData, NUM_W, NUM_H) == true);
}
// hipMemcpy2DFromArray API would return success for width and height as 0
@@ -121,21 +108,15 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_ExtentValidation") {
// 3 validating hData<-->A_h which will not be equal as copy is not done.
SECTION("Width is 0") {
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0,
A_h, width, width,
NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(hData, width, A_d,
0, 0, 0,
NUM_H, hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, A_h, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(hData, width, A_d, 0, 0, 0, NUM_H, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(hData, valData, NUM_W, NUM_H) == true);
}
// Cleaning the memory
HIP_CHECK(hipFreeArray(A_d));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, hData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
nullptr, valData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, hData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, nullptr, valData, nullptr, false);
}
/*
* This Scenario Verifies hipMemcpy2DFromArray API by copying the
@@ -152,33 +133,27 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_PinnedMemSameGPU") {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
constexpr auto def_val{10};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *PinnMem{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, nullptr, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, nullptr, nullptr, width * NUM_H,
false);
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&PinnMem), width * NUM_H));
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
HipTest::setDefaultData<float>(width*NUM_H, A_h, nullptr, nullptr);
for (int i = 0; i < NUM_W*NUM_H; i++) {
HipTest::setDefaultData<float>(width * NUM_H, A_h, nullptr, nullptr);
for (int i = 0; i < NUM_W * NUM_H; i++) {
PinnMem[i] = def_val + i;
}
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, PinnMem,
width, width, NUM_H,
hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, PinnMem, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d, 0, 0, width, NUM_H, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(A_h, PinnMem, NUM_W, NUM_H) == true);
// Cleaning the memory
HIP_CHECK(hipFreeArray(A_d));
HIP_CHECK(hipHostFree(PinnMem));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, nullptr, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, nullptr, nullptr, false);
}
/*
* This Scenario Verifies hipMemcpy2DFromArray API by copying the
@@ -202,34 +177,28 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_multiDevicePinnedMemPeerGpu") {
if (canAccessPeer) {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *E_h{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, nullptr, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, nullptr, nullptr, width * NUM_H,
false);
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
HipTest::setDefaultData<float>(width*NUM_H, A_h, nullptr, nullptr);
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, A_h,
width, width, NUM_H,
hipMemcpyHostToDevice));
HipTest::setDefaultData<float>(width * NUM_H, A_h, nullptr, nullptr);
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, A_h, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&E_h), width * NUM_H));
for (int i = 0; i < NUM_W*NUM_H; i++) {
for (int i = 0; i < NUM_W * NUM_H; i++) {
E_h[i] = def_val + i;
}
HIP_CHECK(hipSetDevice(1));
HIP_CHECK(hipMemcpy2DFromArray(E_h, width, A_d,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DFromArray(E_h, width, A_d, 0, 0, width, NUM_H, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(A_h, E_h, NUM_W, NUM_H) == true);
// Cleaning the memory
HIP_CHECK(hipFreeArray(A_d));
HIP_CHECK(hipHostFree(E_h));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, nullptr, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, nullptr, nullptr, false);
} else {
SUCCEED("Device Does not have P2P capability");
}
@@ -260,31 +229,25 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_multiDeviceContextChange") {
if (canAccessPeer) {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *hData{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, &hData, nullptr,
width*NUM_H, false);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, &hData, nullptr, width * NUM_H,
false);
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
HipTest::setDefaultData<float>(width*NUM_H, A_h, hData, nullptr);
HipTest::setDefaultData<float>(width * NUM_H, A_h, hData, nullptr);
HIP_CHECK(hipSetDevice(1));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, hData, width,
width, NUM_H,
hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DToArray(A_d, 0, 0, hData, width, width, NUM_H, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy2DFromArray(A_h, width, A_d, 0, 0, width, NUM_H, hipMemcpyDeviceToHost));
REQUIRE(HipTest::checkArray(A_h, hData, NUM_W, NUM_H) == true);
// Cleaning the memory
HIP_CHECK(hipFreeArray(A_d));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, hData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, hData, nullptr, false);
} else {
SUCCEED("Device Does not have P2P capability");
}
@@ -300,44 +263,37 @@ TEST_CASE("Unit_hipMemcpy2DFromArray_Negative") {
HIP_CHECK(hipSetDevice(0));
hipArray_t A_d{nullptr};
size_t width{sizeof(float)*NUM_W};
size_t width{sizeof(float) * NUM_W};
float *A_h{nullptr}, *hData{nullptr};
// Initialization of variables
HipTest::initArrays<float>(nullptr, nullptr, nullptr,
&A_h, &hData, nullptr,
width*NUM_H, false);
HipTest::setDefaultData<float>(width*NUM_H, A_h, hData, nullptr);
HipTest::initArrays<float>(nullptr, nullptr, nullptr, &A_h, &hData, nullptr, width * NUM_H,
false);
HipTest::setDefaultData<float>(width * NUM_H, A_h, hData, nullptr);
hipChannelFormatDesc desc = hipCreateChannelDesc<float>();
HIP_CHECK(hipMallocArray(&A_d, &desc, NUM_W, NUM_H, hipArrayDefault));
SECTION("Nullptr to destination") {
REQUIRE(hipMemcpy2DFromArray(nullptr, width, A_d,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost) != hipSuccess);
REQUIRE(hipMemcpy2DFromArray(nullptr, width, A_d, 0, 0, width, NUM_H, hipMemcpyDeviceToHost) !=
hipSuccess);
}
SECTION("Nullptr to source") {
REQUIRE(hipMemcpy2DFromArray(A_h, width, nullptr,
0, 0, width, NUM_H,
hipMemcpyDeviceToHost) != hipSuccess);
REQUIRE(hipMemcpy2DFromArray(A_h, width, nullptr, 0, 0, width, NUM_H, hipMemcpyDeviceToHost) !=
hipSuccess);
}
SECTION("Passing offset more than 0") {
REQUIRE(hipMemcpy2DFromArray(A_h, width, A_d, 1,
1, width, NUM_H,
hipMemcpyDeviceToHost) != hipSuccess);
REQUIRE(hipMemcpy2DFromArray(A_h, width, A_d, 1, 1, width, NUM_H, hipMemcpyDeviceToHost) !=
hipSuccess);
}
SECTION("Passing array more than allocated") {
REQUIRE(hipMemcpy2DFromArray(A_h, width, A_d, 0,
0, width+2, NUM_H+2,
REQUIRE(hipMemcpy2DFromArray(A_h, width, A_d, 0, 0, width + 2, NUM_H + 2,
hipMemcpyDeviceToHost) != hipSuccess);
}
// Cleaning of memory
HIP_CHECK(hipFreeArray(A_d));
HipTest::freeArrays<float>(nullptr, nullptr, nullptr,
A_h, hData, nullptr, false);
HipTest::freeArrays<float>(nullptr, nullptr, nullptr, A_h, hData, nullptr, false);
}