diff --git a/projects/hip-tests/catch/unit/memory/hipHostAlloc.cc b/projects/hip-tests/catch/unit/memory/hipHostAlloc.cc index 7996efeb8a..4cb3f32045 100644 --- a/projects/hip-tests/catch/unit/memory/hipHostAlloc.cc +++ b/projects/hip-tests/catch/unit/memory/hipHostAlloc.cc @@ -201,27 +201,24 @@ TEST_CASE("Unit_hipHostAlloc_Basic") { } else { float *A_h, *B_h, *C_h; float *A_d, *B_d, *C_d; + unsigned int flag = 0; HIP_CHECK(hipHostAlloc(reinterpret_cast(&A_h), SIZE, hipHostAllocWriteCombined | hipHostAllocMapped)); - SECTION("hipHostAllocDefault") { - HIP_CHECK(hipHostAlloc(reinterpret_cast(&B_h), SIZE, - hipHostAllocDefault)); - } -#if (HT_AMD == 1) && (HT_LINUX == 1) - SECTION("hipHostAllocUncached") { - HIP_CHECK(hipHostAlloc(reinterpret_cast(&B_h), SIZE, - hipHostAllocUncached)); - } -#endif - HIP_CHECK(hipHostAlloc(reinterpret_cast(&C_h), SIZE, - hipHostAllocMapped)); - HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast(&A_d), A_h, 0)); - HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast(&C_d), C_h, 0)); + SECTION("hipHostAllocDefault") { flag = hipHostAllocDefault; } +#if (HT_AMD == 1) && (HT_LINUX == 1) + SECTION("hipHostAllocUncached") { flag = hipHostAllocUncached; } +#endif + + HIP_CHECK(hipHostAlloc(reinterpret_cast(&B_h), SIZE, flag)); + HIP_CHECK(hipHostAlloc(reinterpret_cast(&C_h), SIZE, hipHostAllocMapped)); + + HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast(&A_d), A_h, 0)); + HIP_CHECK(hipHostGetDevicePointer(reinterpret_cast(&C_d), C_h, 0)); HipTest::setDefaultData(LEN, A_h, B_h, C_h); - HIP_CHECK(hipMalloc(reinterpret_cast(&B_d), SIZE)); + HIP_CHECK(hipMalloc(reinterpret_cast(&B_d), SIZE)); HIP_CHECK(hipMemcpy(B_d, B_h, SIZE, hipMemcpyHostToDevice)); dim3 dimGrid(LEN / 512, 1, 1); diff --git a/projects/hip-tests/catch/unit/memory/hipHostMalloc.cc b/projects/hip-tests/catch/unit/memory/hipHostMalloc.cc index 5b00f8d700..fa87bb30ea 100644 --- a/projects/hip-tests/catch/unit/memory/hipHostMalloc.cc +++ b/projects/hip-tests/catch/unit/memory/hipHostMalloc.cc @@ -127,26 +127,16 @@ TEST_CASE("Unit_hipHostMalloc_Basic") { } else { float *A_h, *B_h, *C_h; float *A_d, *B_d, *C_d; + unsigned int flag = 0; HIP_CHECK(hipHostMalloc(reinterpret_cast(&A_h), SIZE, hipHostMallocWriteCombined | hipHostMallocMapped)); - SECTION("hipHostMallocDefault") { - HIP_CHECK(hipHostMalloc(reinterpret_cast(&B_h), SIZE, - hipHostMallocDefault)); - } + SECTION("hipHostMallocDefault") { flag = hipHostMallocDefault; } #if (HT_AMD == 1) && (HT_LINUX == 1) - SECTION("hipHostMallocUncached") { - HIP_CHECK(hipHostMalloc(reinterpret_cast(&B_h), SIZE, - hipHostMallocUncached)); - } - SECTION("hipHostMallocCoherent") { - HIP_CHECK(hipHostMalloc(reinterpret_cast(&B_h), SIZE, - hipHostMallocCoherent)); - } - SECTION("hipHostMallocNonCoherent") { - HIP_CHECK(hipHostMalloc(reinterpret_cast(&B_h), SIZE, - hipHostMallocNonCoherent)); - } + SECTION("hipHostMallocUncached") { flag = hipHostMallocUncached; } + SECTION("hipHostMallocCoherent") { flag = hipHostMallocCoherent; } + SECTION("hipHostMallocNonCoherent") { flag = hipHostMallocNonCoherent; } #endif + HIP_CHECK(hipHostMalloc(reinterpret_cast(&B_h), SIZE, flag)); HIP_CHECK(hipHostMalloc(reinterpret_cast(&C_h), SIZE, hipHostMallocMapped));