diff --git a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc index e46042fb37..b7fa5cb031 100644 --- a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc +++ b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc @@ -418,7 +418,7 @@ using AttributeToStringMap = std::array kCommonAttributes{{ +constexpr AttributeToStringMap<58> kCommonAttributes{{ {hipDeviceAttributeEccEnabled, "hipDeviceAttributeEccEnabled"}, {hipDeviceAttributeCanMapHostMemory, "hipDeviceAttributeCanMapHostMemory"}, {hipDeviceAttributeClockRate, "hipDeviceAttributeClockRate"}, @@ -479,9 +479,10 @@ constexpr AttributeToStringMap<57> kCommonAttributes{{ {hipDeviceAttributeTotalGlobalMem, "hipDeviceAttributeTotalGlobalMem"}, {hipDeviceAttributeWarpSize, "hipDeviceAttributeWarpSize"}, {hipDeviceAttributeMemoryPoolsSupported, "hipDeviceAttributeMemoryPoolsSupported"}, - {hipDeviceAttributeUnifiedAddressing, "hipDeviceAttributeUnifiedAddressing"}, + {hipDeviceAttributeUnifiedAddressing, "hipDeviceAttributeUnifiedAddressing"}, {hipDeviceAttributeVirtualMemoryManagementSupported, - "hipDeviceAttributeVirtualMemoryManagementSupported"} + "hipDeviceAttributeVirtualMemoryManagementSupported"}, + {hipDeviceAttributeHostRegisterSupported, "hipDeviceAttributeHostRegisterSupported"} }}; #if HT_NVIDIA @@ -610,3 +611,38 @@ TEST_CASE("Print_Out_Attributes") { std::flush(std::cout); } + +/** + * Test Description + * ------------------------ + * - verify hipDeviceAttributeHostRegisterSupported attribute. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceAttribute.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 6.0 + */ +TEST_CASE("Unit_hipGetDeviceAttribute_hipDevAttrHostRegisterSupported") { + hipError_t ret_val; + int hipDevAttr = 0; + ret_val = hipDeviceGetAttribute(&hipDevAttr, + hipDeviceAttributeHostRegisterSupported, 0); + INFO("hipDeviceAttributeHostRegisterSupported: " << hipDevAttr); + + if (ret_val == hipSuccess) { + auto x = std::unique_ptr(new int); + HIP_CHECK(hipHostRegister(x.get(), sizeof(int), hipHostRegisterDefault)); + + void* device_memory; + HIP_CHECK(hipHostGetDevicePointer(&device_memory, x.get(), 0)); + + HIP_CHECK(hipHostUnregister(x.get())); + HIP_CHECK_ERROR(hipHostGetDevicePointer(&device_memory, x.get(), 0), + hipErrorInvalidValue); + } else { + HipTest::HIP_SKIP_TEST("Skipping the test as GPU 0 doesn't support " + "hipDeviceAttributeHostRegisterSupported attribute.\n"); + return; + } +}