SWDEV-539145 - Add tests of hipHostMallocUncached, hipHostAllocUncached and hipHostRegisterUncached (#348)

Tá an tiomantas seo le fáil i:
Sang, Tao
2025-07-01 00:40:25 -04:00
tiomanta ag GitHub
tuismitheoir 2c7c7128ea
tiomantas 9499bf6d1e
D'athraigh 3 comhad le 46 breiseanna agus 8 scriosta
+12 -4
Féach ar an gComhad
@@ -202,11 +202,19 @@ TEST_CASE("Unit_hipHostAlloc_Basic") {
float *A_h, *B_h, *C_h;
float *A_d, *B_d, *C_d;
HIP_CHECK(hipHostAlloc(reinterpret_cast<void **>(&A_h), SIZE,
hipHostMallocWriteCombined | hipHostMallocMapped));
HIP_CHECK(hipHostAlloc(reinterpret_cast<void **>(&B_h), SIZE,
hipHostMallocDefault));
hipHostAllocWriteCombined | hipHostAllocMapped));
SECTION("hipHostAllocDefault") {
HIP_CHECK(hipHostAlloc(reinterpret_cast<void **>(&B_h), SIZE,
hipHostAllocDefault));
}
#if (HT_AMD == 1) && (HT_LINUX == 1)
SECTION("hipHostAllocUncached") {
HIP_CHECK(hipHostAlloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostAllocUncached));
}
#endif
HIP_CHECK(hipHostAlloc(reinterpret_cast<void **>(&C_h), SIZE,
hipHostMallocMapped));
hipHostAllocMapped));
HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast<void **>(&A_d), A_h, 0));
HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast<void **>(&C_d), C_h, 0));
+18 -2
Féach ar an gComhad
@@ -129,8 +129,24 @@ TEST_CASE("Unit_hipHostMalloc_Basic") {
float *A_d, *B_d, *C_d;
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&A_h), SIZE,
hipHostMallocWriteCombined | hipHostMallocMapped));
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostMallocDefault));
SECTION("hipHostMallocDefault") {
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostMallocDefault));
}
#if (HT_AMD == 1) && (HT_LINUX == 1)
SECTION("hipHostMallocUncached") {
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostMallocUncached));
}
SECTION("hipHostMallocCoherent") {
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostMallocCoherent));
}
SECTION("hipHostMallocNonCoherent") {
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&B_h), SIZE,
hipHostMallocNonCoherent));
}
#endif
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&C_h), SIZE,
hipHostMallocMapped));
+16 -2
Féach ar an gComhad
@@ -116,8 +116,18 @@ TEMPLATE_TEST_CASE("Unit_hipHostRegister_ReferenceFromKernelandhipMemset", "", \
HIP_CHECK(hipGetDeviceCount(&num_devices));
Ad = new TestType*[num_devices];
A = reinterpret_cast<TestType*>(malloc(sizeBytes));
HIP_CHECK(hipHostRegister(A, sizeBytes, 0));
SECTION("hipHostRegisterDefault") {
HIP_CHECK(hipHostRegister(A, sizeBytes, hipHostRegisterDefault));
}
#if (HT_AMD == 1) && (HT_LINUX == 1)
SECTION("hipExtHostRegisterUncached") {
HIP_CHECK(hipHostRegister(A, sizeBytes, hipExtHostRegisterUncached));
}
SECTION("hipHostRegisterPortable | hipHostRegisterMapped | hipExtHostRegisterUncached") {
HIP_CHECK(hipHostRegister(A, sizeBytes,
hipHostRegisterPortable | hipHostRegisterMapped | hipExtHostRegisterUncached));
}
#endif
for (int i = 0; i < LEN; i++) {
A[i] = static_cast<TestType>(1);
}
@@ -926,6 +936,10 @@ TEMPLATE_TEST_CASE("Unit_hipHostRegister_Flags", "", int, float, double) {
FlagType{0x08, true},
FlagType{hipHostRegisterPortable | hipHostRegisterMapped, true},
FlagType{hipHostRegisterPortable | hipHostRegisterMapped | 0x08, true},
#if (HT_AMD == 1) && (HT_LINUX == 1)
FlagType{hipExtHostRegisterUncached, true},
FlagType{hipHostRegisterPortable | hipHostRegisterMapped | hipExtHostRegisterUncached, true},
#endif
FlagType{0xF0, false},
FlagType{0xFFF2, false}, FlagType{0xFFFFFFFF, false});