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
@@ -39,8 +39,7 @@ THE SOFTWARE.
*/
TEST_CASE("Unit_hipGetProcAddress_VMM") {
int value = 0;
HIP_CHECK(hipDeviceGetAttribute(&value,
hipDeviceAttributeVirtualMemoryManagementSupported, 0));
HIP_CHECK(hipDeviceGetAttribute(&value, hipDeviceAttributeVirtualMemoryManagementSupported, 0));
if (value == 0) {
HipTest::HIP_SKIP_TEST("Machine does not support VMM. Skipping Test..");
return;
@@ -72,111 +71,75 @@ TEST_CASE("Unit_hipGetProcAddress_VMM") {
int currentHipVersion = 0;
HIP_CHECK(hipRuntimeGetVersion(&currentHipVersion));
HIP_CHECK(hipGetProcAddress("hipMemGetAllocationGranularity",
&hipMemGetAllocationGranularity_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemCreate",
&hipMemCreate_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemAddressReserve",
&hipMemAddressReserve_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemMap",
&hipMemMap_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemSetAccess",
&hipMemSetAccess_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemUnmap",
&hipMemUnmap_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemAddressFree",
&hipMemAddressFree_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemRelease",
&hipMemRelease_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemGetAccess",
&hipMemGetAccess_ptr,
HIP_CHECK(hipGetProcAddress("hipMemGetAllocationGranularity", &hipMemGetAllocationGranularity_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemCreate", &hipMemCreate_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemAddressReserve", &hipMemAddressReserve_ptr, currentHipVersion,
0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemMap", &hipMemMap_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(
hipGetProcAddress("hipMemSetAccess", &hipMemSetAccess_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemUnmap", &hipMemUnmap_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemAddressFree", &hipMemAddressFree_ptr, currentHipVersion, 0,
nullptr));
HIP_CHECK(hipGetProcAddress("hipMemRelease", &hipMemRelease_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(
hipGetProcAddress("hipMemGetAccess", &hipMemGetAccess_ptr, currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemGetAllocationPropertiesFromHandle",
&hipMemGetAllocationPropertiesFromHandle_ptr,
currentHipVersion, 0, nullptr));
HIP_CHECK(hipGetProcAddress("hipMemRetainAllocationHandle",
&hipMemRetainAllocationHandle_ptr,
&hipMemGetAllocationPropertiesFromHandle_ptr, currentHipVersion, 0,
nullptr));
HIP_CHECK(hipGetProcAddress("hipMemRetainAllocationHandle", &hipMemRetainAllocationHandle_ptr,
currentHipVersion, 0, nullptr));
hipError_t(*dyn_hipMemGetAllocationGranularity_ptr)(
size_t *, const hipMemAllocationProp *,
hipMemAllocationGranularity_flags) =
reinterpret_cast<hipError_t (*)(size_t *,
const hipMemAllocationProp *,
hipMemAllocationGranularity_flags)>
(hipMemGetAllocationGranularity_ptr);
hipError_t (*dyn_hipMemGetAllocationGranularity_ptr)(size_t*, const hipMemAllocationProp*,
hipMemAllocationGranularity_flags) =
reinterpret_cast<hipError_t (*)(size_t*, const hipMemAllocationProp*,
hipMemAllocationGranularity_flags)>(
hipMemGetAllocationGranularity_ptr);
hipError_t(*dyn_hipMemCreate_ptr)(
hipMemGenericAllocationHandle_t *,
size_t, const hipMemAllocationProp *,
uint64_t) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t *,
size_t, const hipMemAllocationProp *,
uint64_t)>
(hipMemCreate_ptr);
hipError_t (*dyn_hipMemCreate_ptr)(hipMemGenericAllocationHandle_t*, size_t,
const hipMemAllocationProp*, uint64_t) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t*, size_t,
const hipMemAllocationProp*, uint64_t)>(hipMemCreate_ptr);
hipError_t(*dyn_hipMemAddressReserve_ptr)(
void **, size_t, size_t, void *, uint64_t) =
reinterpret_cast<hipError_t (*)(void **, size_t, size_t, void *,
uint64_t)>
(hipMemAddressReserve_ptr);
hipError_t (*dyn_hipMemAddressReserve_ptr)(void**, size_t, size_t, void*, uint64_t) =
reinterpret_cast<hipError_t (*)(void**, size_t, size_t, void*, uint64_t)>(
hipMemAddressReserve_ptr);
hipError_t(*dyn_hipMemMap_ptr)(
void *, size_t, size_t,
hipMemGenericAllocationHandle_t, uint64_t) =
reinterpret_cast<hipError_t (*)(void *, size_t, size_t,
hipMemGenericAllocationHandle_t,
uint64_t)>
(hipMemMap_ptr);
hipError_t (*dyn_hipMemMap_ptr)(void*, size_t, size_t, hipMemGenericAllocationHandle_t,
uint64_t) =
reinterpret_cast<hipError_t (*)(void*, size_t, size_t, hipMemGenericAllocationHandle_t,
uint64_t)>(hipMemMap_ptr);
hipError_t(*dyn_hipMemSetAccess_ptr)(
void *, size_t, const hipMemAccessDesc *, size_t) =
reinterpret_cast<hipError_t (*)(void *, size_t,
const hipMemAccessDesc *, size_t)>
(hipMemSetAccess_ptr);
hipError_t (*dyn_hipMemSetAccess_ptr)(void*, size_t, const hipMemAccessDesc*, size_t) =
reinterpret_cast<hipError_t (*)(void*, size_t, const hipMemAccessDesc*, size_t)>(
hipMemSetAccess_ptr);
hipError_t(*dyn_hipMemUnmap_ptr)(
void *, size_t) =
reinterpret_cast<hipError_t (*)(void *, size_t)>
(hipMemUnmap_ptr);
hipError_t (*dyn_hipMemUnmap_ptr)(void*, size_t) =
reinterpret_cast<hipError_t (*)(void*, size_t)>(hipMemUnmap_ptr);
hipError_t(*dyn_hipMemAddressFree_ptr)(
void *, size_t) =
reinterpret_cast<hipError_t (*)(void *, size_t)>
(hipMemAddressFree_ptr);
hipError_t (*dyn_hipMemAddressFree_ptr)(void*, size_t) =
reinterpret_cast<hipError_t (*)(void*, size_t)>(hipMemAddressFree_ptr);
hipError_t(*dyn_hipMemRelease_ptr)(hipMemGenericAllocationHandle_t) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t)>
(hipMemRelease_ptr);
hipError_t (*dyn_hipMemRelease_ptr)(hipMemGenericAllocationHandle_t) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t)>(hipMemRelease_ptr);
hipError_t(*dyn_hipMemGetAccess_ptr)(
uint64_t *, const hipMemLocation *, void *) =
reinterpret_cast<hipError_t (*)(uint64_t *,
const hipMemLocation *, void *)>
(hipMemGetAccess_ptr);
hipError_t (*dyn_hipMemGetAccess_ptr)(uint64_t*, const hipMemLocation*, void*) =
reinterpret_cast<hipError_t (*)(uint64_t*, const hipMemLocation*, void*)>(
hipMemGetAccess_ptr);
hipError_t(*dyn_hipMemGetAllocationPropertiesFromHandle_ptr)(
hipMemAllocationProp *, hipMemGenericAllocationHandle_t) =
reinterpret_cast<hipError_t (*)(hipMemAllocationProp *,
hipMemGenericAllocationHandle_t)>
(hipMemGetAllocationPropertiesFromHandle_ptr);
hipError_t (*dyn_hipMemGetAllocationPropertiesFromHandle_ptr)(hipMemAllocationProp*,
hipMemGenericAllocationHandle_t) =
reinterpret_cast<hipError_t (*)(hipMemAllocationProp*, hipMemGenericAllocationHandle_t)>(
hipMemGetAllocationPropertiesFromHandle_ptr);
hipError_t(*dyn_hipMemRetainAllocationHandle_ptr)(
hipMemGenericAllocationHandle_t *, void *) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t *, void *)>
(hipMemRetainAllocationHandle_ptr);
hipError_t (*dyn_hipMemRetainAllocationHandle_ptr)(hipMemGenericAllocationHandle_t*, void*) =
reinterpret_cast<hipError_t (*)(hipMemGenericAllocationHandle_t*, void*)>(
hipMemRetainAllocationHandle_ptr);
const int N = 10;
const int Nbytes = 10 * sizeof(int);
int *hostMem = reinterpret_cast<int *>(malloc(Nbytes));
int* hostMem = reinterpret_cast<int*>(malloc(Nbytes));
REQUIRE(hostMem != nullptr);
fillHostArray(hostMem, N, 10);
@@ -190,10 +153,10 @@ TEST_CASE("Unit_hipGetProcAddress_VMM") {
size_t granularity = 0;
size_t granularityWithFuncPtr = 0;
HIP_CHECK(hipMemGetAllocationGranularity(&granularity,
&prop, hipMemAllocationGranularityMinimum));
HIP_CHECK(dyn_hipMemGetAllocationGranularity_ptr(&granularityWithFuncPtr,
&prop, hipMemAllocationGranularityMinimum));
HIP_CHECK(
hipMemGetAllocationGranularity(&granularity, &prop, hipMemAllocationGranularityMinimum));
HIP_CHECK(dyn_hipMemGetAllocationGranularity_ptr(&granularityWithFuncPtr, &prop,
hipMemAllocationGranularityMinimum));
REQUIRE(granularity > 0);
REQUIRE(granularityWithFuncPtr > 0);
@@ -223,7 +186,7 @@ TEST_CASE("Unit_hipGetProcAddress_VMM") {
// Performing some operations on ptr, to validate it
HIP_CHECK(hipMemcpy(ptr, hostMem, Nbytes, hipMemcpyHostToDevice));
addOneKernel<<< 1, 1 >>>(reinterpret_cast<int *>(ptr), N);
addOneKernel<<<1, 1>>>(reinterpret_cast<int*>(ptr), N);
HIP_CHECK(hipMemcpy(hostMem, ptr, Nbytes, hipMemcpyDeviceToHost));
validateHostArray(hostMem, N, 11);
@@ -235,8 +198,7 @@ TEST_CASE("Unit_hipGetProcAddress_VMM") {
// Validating hipMemGetAllocationPropertiesFromHandle API
hipMemAllocationProp requiredProp;
HIP_CHECK(dyn_hipMemGetAllocationPropertiesFromHandle_ptr(
&requiredProp, handle));
HIP_CHECK(dyn_hipMemGetAllocationPropertiesFromHandle_ptr(&requiredProp, handle));
REQUIRE(requiredProp.type == hipMemAllocationTypePinned);
REQUIRE(requiredProp.requestedHandleTypes == hipMemHandleTypeNone);
REQUIRE(requiredProp.location.type == hipMemLocationTypeDevice);
@@ -254,8 +216,7 @@ TEST_CASE("Unit_hipGetProcAddress_VMM") {
// Performing operation on ptr, to check it is invalidated or not
if (!xnackEnabled) {
REQUIRE(hipMemcpy(ptr, hostMem, Nbytes, hipMemcpyHostToDevice)
== hipErrorInvalidValue);
REQUIRE(hipMemcpy(ptr, hostMem, Nbytes, hipMemcpyHostToDevice) == hipErrorInvalidValue);
}
free(hostMem);
}
@@ -66,7 +66,7 @@ TEST_CASE("Unit_hipMemAddressFree_negative") {
HIP_CHECK(hipMemAddressReserve(&ptrA, size_mem, 0, 0, 0));
SECTION("nullptr to devptr") {
REQUIRE(hipMemAddressFree((hipDeviceptr_t)nullptr, size_mem) == hipErrorInvalidValue);
REQUIRE(hipMemAddressFree((hipDeviceptr_t) nullptr, size_mem) == hipErrorInvalidValue);
}
SECTION("pass zero to size") { REQUIRE(hipMemAddressFree(ptrA, 0) == hipErrorInvalidValue); }
@@ -76,6 +76,6 @@ TEST_CASE("Unit_hipMemAddressFree_negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -153,6 +153,6 @@ TEST_CASE("Unit_hipMemAddressReserve_Negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -461,6 +461,6 @@ TEST_CASE("Unit_hipMemCreate_Negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -113,8 +113,7 @@ TEST_CASE("Unit_hipMemExportToShareableHandle_Negative_Parameters") {
SECTION("handle == nullptr") {
HIP_CHECK_ERROR(
hipMemExportToShareableHandle(&shareable_handle,
(hipMemGenericAllocationHandle_t)nullptr,
hipMemExportToShareableHandle(&shareable_handle, (hipMemGenericAllocationHandle_t) nullptr,
hipMemHandleTypePosixFileDescriptor, 0),
hipErrorInvalidValue);
}
@@ -135,6 +134,6 @@ TEST_CASE("Unit_hipMemExportToShareableHandle_Negative_Parameters") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -182,6 +182,6 @@ TEST_CASE("Unit_hipMemGetAllocationGranularity_NegativeTests") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -122,6 +122,6 @@ TEST_CASE("Unit_hipMemGetAllocationPropertiesFromHandle_Negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -201,7 +201,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_ChldUseHdl") {
HIP_CHECK(hipMemcpyHtoD(ptrA, A_h.data(), buffer_size));
// Invoke kernel
hipLaunchKernelGGL(square_kernel, dim3(N / THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, 0,
reinterpret_cast<int*>(ptrA));
reinterpret_cast<int*>(ptrA));
HIP_CHECK(hipMemcpyDtoH(B_h.data(), ptrA, buffer_size));
HIP_CHECK(hipDeviceSynchronize());
// validate
@@ -232,8 +232,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_ChldUseHdl") {
HIP_CHECK(
hipMemGetAllocationGranularity(&granularity, &prop, hipMemAllocationGranularityMinimum));
REQUIRE(granularity > 0);
size_t size_mem =
((granularity + buffer_size - 1) / granularity) * granularity;
size_t size_mem = ((granularity + buffer_size - 1) / granularity) * granularity;
hipMemGenericAllocationHandle_t handle;
HIP_CHECK(hipMemCreate(&handle, size_mem, &prop, 0));
@@ -247,8 +246,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_ChldUseHdl") {
// Wait for the child process to receive msg
int sig = 0;
REQUIRE(read(fdSig[0], &sig, sizeof(int)) >= 0);
checkSysCallErrors(
sockObj.sendShareableHdl(shareable_handle, pid));
checkSysCallErrors(sockObj.sendShareableHdl(shareable_handle, pid));
// Wait for child process to exit.
int status;
REQUIRE(wait(&status) >= 0);
@@ -329,7 +327,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_ParntChldUseHdl") {
HIP_CHECK(hipMemcpyHtoD(ptrA, A_h.data(), buffer_size));
// Invoke kernel
hipLaunchKernelGGL(square_kernel, dim3(N / THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, 0,
reinterpret_cast<int*>(ptrA));
reinterpret_cast<int*>(ptrA));
HIP_CHECK(hipDeviceSynchronize());
// free resources
@@ -356,8 +354,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_ParntChldUseHdl") {
HIP_CHECK(
hipMemGetAllocationGranularity(&granularity, &prop, hipMemAllocationGranularityMinimum));
REQUIRE(granularity > 0);
size_t size_mem =
((granularity + buffer_size - 1) / granularity) * granularity;
size_t size_mem = ((granularity + buffer_size - 1) / granularity) * granularity;
hipMemGenericAllocationHandle_t handle;
HIP_CHECK(hipMemCreate(&handle, size_mem, &prop, 0));
@@ -516,8 +513,7 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_GrndChldUseHdl") {
HIP_CHECK(
hipMemGetAllocationGranularity(&granularity, &prop, hipMemAllocationGranularityMinimum));
REQUIRE(granularity > 0);
size_t size_mem =
((granularity + buffer_size - 1) / granularity) * granularity;
size_t size_mem = ((granularity + buffer_size - 1) / granularity) * granularity;
hipMemGenericAllocationHandle_t handle;
HIP_CHECK(hipMemCreate(&handle, size_mem, &prop, 0));
@@ -547,6 +543,6 @@ TEST_CASE("Unit_hipMemImportFromShareableHandle_MulProc_GrndChldUseHdl") {
}
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -393,7 +393,8 @@ TEST_CASE("Unit_hipMemMap_VMMMemoryReuse_SingleGPU") {
HIP_CHECK(hipMemcpyDtoH(B_h.data(), ptrA, buffer_size));
REQUIRE(true == std::equal(B_h.begin(), B_h.end(), A_h.data()));
#if HT_NVIDIA
square_kernel<<<dim3(N / threadsPerBlk), dim3(threadsPerBlk), 0, 0>>>(reinterpret_cast<int*>(ptrA));
square_kernel<<<dim3(N / threadsPerBlk), dim3(threadsPerBlk), 0, 0>>>(
reinterpret_cast<int*>(ptrA));
HIP_CHECK(hipMemcpyDtoH(B_h.data(), ptrA, buffer_size));
HIP_CHECK(hipStreamSynchronize(0));
REQUIRE(true == std::equal(B_h.begin(), B_h.end(), C_h.data()));
@@ -590,7 +591,7 @@ TEST_CASE("Unit_hipMemMap_negative") {
HIP_CHECK(hipMemAddressReserve(&ptrA, size_mem, 0, 0, 0));
SECTION("nullptr to ptrA") {
REQUIRE(hipMemMap((hipDeviceptr_t)nullptr, size_mem, 0, handle, 0) == hipErrorInvalidValue);
REQUIRE(hipMemMap((hipDeviceptr_t) nullptr, size_mem, 0, handle, 0) == hipErrorInvalidValue);
}
SECTION("pass zero to size") {
@@ -603,6 +604,6 @@ TEST_CASE("Unit_hipMemMap_negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -110,6 +110,6 @@ TEST_CASE("Unit_hipMemMapArrayAsync_Positive_Basic") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -50,6 +50,6 @@ TEST_CASE("Unit_hipMemRelease_negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -141,6 +141,6 @@ TEST_CASE("Unit_hipMemRetainAllocationHandle_NegTst") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -377,7 +377,7 @@ TEST_CASE("Unit_hipMemSetAccess_FuncTstOnMultDev") {
A_h[idx] = idx;
}
HIP_CHECK(hipMemcpyHtoD(ptrA, A_h.data(), buffer_size));
// Set the A_h to verify with square kernel.
// Set the A_h to verify with square kernel.
for (int idx = 0; idx < N; idx++) {
A_h[idx] = idx * idx;
}
@@ -1131,7 +1131,8 @@ TEST_CASE("Unit_hipMemSetAccess_GrowVMM") {
REQUIRE(ptrB_h != nullptr);
unsigned long long uiptr = reinterpret_cast<unsigned long long>(ptr);
uiptr = uiptr + buffer_size;
HIP_CHECK(hipMemcpyHtoD(reinterpret_cast<hipDeviceptr_t>(uiptr), ptrA_h, (buffer_size_new - buffer_size)));
HIP_CHECK(hipMemcpyHtoD(reinterpret_cast<hipDeviceptr_t>(uiptr), ptrA_h,
(buffer_size_new - buffer_size)));
HIP_CHECK(hipMemcpyDtoH(ptrB_h, ptr, buffer_size_new));
bool bPassed = true;
for (int idx = 0; idx < Nnew; idx++) {
@@ -1320,6 +1321,6 @@ TEST_CASE("Unit_hipMemSetAccess_negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
@@ -90,6 +90,6 @@ TEST_CASE("Unit_hipMemUnmap_negative") {
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}
*/
* End doxygen group VirtualMemoryManagementTest.
* @}
*/