CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
283 lines
13 KiB
C++
283 lines
13 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <string.h>
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <array>
|
|
#include <iostream>
|
|
|
|
#include <hip_test_common.hh>
|
|
|
|
/**
|
|
* @addtogroup hipDeviceGetAttribute hipDeviceGetAttribute
|
|
* @{
|
|
* @ingroup DeviceTest
|
|
* `hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int deviceId)` -
|
|
* Query for a specific device attribute.
|
|
*/
|
|
|
|
static hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr,
|
|
int expectedValue = -1) {
|
|
int value = 0;
|
|
std::cout << "Test hipDeviceGetAttribute attribute " << attr;
|
|
if (expectedValue != -1) {
|
|
std::cout << " expected value " << expectedValue;
|
|
}
|
|
HIP_CHECK(hipDeviceGetAttribute(&value, attr, deviceId));
|
|
std::cout << " actual value " << value << std::endl;
|
|
if ((expectedValue != -1) && value != expectedValue) {
|
|
std::cout << "fail" << std::endl;
|
|
return hipErrorInvalidValue;
|
|
}
|
|
return hipSuccess;
|
|
}
|
|
|
|
static hipError_t test_hipDeviceGetHdpAddress(int deviceId, hipDeviceAttribute_t attr,
|
|
uint32_t* expectedValue) {
|
|
uint32_t* value = 0;
|
|
std::cout << "Test hipDeviceGetHdpAddress attribute " << attr;
|
|
if (expectedValue != reinterpret_cast<uint32_t*>(0xdeadbeef)) {
|
|
std::cout << " expected value " << expectedValue;
|
|
}
|
|
HIP_CHECK(hipDeviceGetAttribute(reinterpret_cast<int*>(&value), attr, deviceId));
|
|
std::cout << " actual value " << value << std::endl;
|
|
if ((expectedValue != reinterpret_cast<uint32_t*>(0xdeadbeef)) && value != expectedValue) {
|
|
std::cout << "fail" << std::endl;
|
|
return hipErrorInvalidValue;
|
|
}
|
|
return hipSuccess;
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Validate various device attributes against device properties.
|
|
* - Matching attribute and property value shall be equal.
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/device/hipGetDeviceAttribute.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipGetDeviceAttribute_CheckAttrValues) {
|
|
int deviceId;
|
|
HIP_CHECK(hipGetDevice(&deviceId));
|
|
hipDeviceProp_t props;
|
|
HIP_CHECK(hipGetDeviceProperties(&props, deviceId));
|
|
printf("info: running on device #%d %s\n", deviceId, props.name);
|
|
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerBlock,
|
|
props.maxThreadsPerBlock));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimX, props.maxThreadsDim[0]));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimY, props.maxThreadsDim[1]));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimZ, props.maxThreadsDim[2]));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimX, props.maxGridSize[0]));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimY, props.maxGridSize[1]));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimZ, props.maxGridSize[2]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerBlock,
|
|
props.sharedMemPerBlock));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeTotalConstantMemory,
|
|
props.totalConstMem));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeWarpSize, props.warpSize));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxRegistersPerBlock,
|
|
props.regsPerBlock));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeClockRate, props.clockRate));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryClockRate,
|
|
props.memoryClockRate));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryBusWidth, props.memoryBusWidth));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMultiprocessorCount,
|
|
props.multiProcessorCount));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeIsMultiGpuBoard,
|
|
props.isMultiGpuBoard));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeMode, props.computeMode));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeL2CacheSize, props.l2CacheSize));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor,
|
|
props.maxThreadsPerMultiProcessor));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMajor, props.major));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMinor, props.minor));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeConcurrentKernels,
|
|
props.concurrentKernels));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciBusId, props.pciBusID));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciDeviceId, props.pciDeviceID));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeIntegrated, props.integrated));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture1DWidth,
|
|
props.maxTexture1D));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture2DWidth,
|
|
props.maxTexture2D[0]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture2DHeight,
|
|
props.maxTexture2D[1]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DWidth,
|
|
props.maxTexture3D[0]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DHeight,
|
|
props.maxTexture3D[1]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxTexture3DDepth,
|
|
props.maxTexture3D[2]));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeCooperativeLaunch,
|
|
props.cooperativeLaunch));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeCooperativeMultiDeviceLaunch,
|
|
props.cooperativeMultiDeviceLaunch));
|
|
|
|
#if HT_AMD
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerMultiprocessor,
|
|
props.maxSharedMemoryPerMultiProcessor));
|
|
HIP_CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpMemFlushCntl,
|
|
props.hdpMemFlushCntl));
|
|
HIP_CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpRegFlushCntl,
|
|
props.hdpRegFlushCntl));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeDirectManagedMemAccessFromHost,
|
|
props.directManagedMemAccessFromHost));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeConcurrentManagedAccess,
|
|
props.concurrentManagedAccess));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePageableMemoryAccess,
|
|
props.pageableMemoryAccess));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
|
hipDeviceAttributePageableMemoryAccessUsesHostPageTables,
|
|
props.pageableMemoryAccessUsesHostPageTables));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
|
hipDeviceAttributeCooperativeMultiDeviceUnmatchedFunc,
|
|
props.cooperativeMultiDeviceUnmatchedFunc));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
|
hipDeviceAttributeCooperativeMultiDeviceUnmatchedGridDim,
|
|
props.cooperativeMultiDeviceUnmatchedGridDim));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
|
hipDeviceAttributeCooperativeMultiDeviceUnmatchedBlockDim,
|
|
props.cooperativeMultiDeviceUnmatchedBlockDim));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
|
hipDeviceAttributeCooperativeMultiDeviceUnmatchedSharedMem,
|
|
props.cooperativeMultiDeviceUnmatchedSharedMem));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeAsicRevision, props.asicRevision));
|
|
HIP_CHECK(
|
|
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeManagedMemory, props.managedMemory));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeNumberOfXccs));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeExpertSchedMode));
|
|
#endif
|
|
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxPitch, props.memPitch));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeTextureAlignment,
|
|
props.textureAlignment));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeKernelExecTimeout,
|
|
props.kernelExecTimeoutEnabled));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeCanMapHostMemory,
|
|
props.canMapHostMemory));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeEccEnabled, props.ECCEnabled));
|
|
HIP_CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeTexturePitchAlignment,
|
|
props.texturePitchAlignment));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Validates negative scenarios:
|
|
* -# When pointer to value is `nullptr`
|
|
* - Expected output: do not return `hipSuccess`
|
|
* -# When device ID is `-1`
|
|
* - Expected output: do not return `hipSuccess`
|
|
* -# When device ID is out of bounds
|
|
* - Expected output: do not return `hipSuccess`
|
|
* -# When attribute is invalid (-1)
|
|
* - Expected output: do not return `hipSuccess`
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/device/hipGetDeviceAttribute.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipDeviceGetAttribute_NegTst) {
|
|
int deviceCount = 0;
|
|
int pi = -1;
|
|
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
|
REQUIRE(deviceCount != 0);
|
|
printf("No.of gpus in the system: %d\n", deviceCount);
|
|
|
|
int device;
|
|
HIP_CHECK(hipGetDevice(&device));
|
|
|
|
// pi is nullptr
|
|
SECTION("pi is nullptr") {
|
|
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(nullptr, hipDeviceAttributePciBusId, device));
|
|
}
|
|
|
|
// device is -1
|
|
SECTION("device is -1") {
|
|
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(&pi, hipDeviceAttributePciBusId, -1));
|
|
}
|
|
|
|
// device is Non Existing Device
|
|
SECTION("device is Non Existing Device") {
|
|
REQUIRE_FALSE(hipSuccess ==
|
|
hipDeviceGetAttribute(&pi, hipDeviceAttributePciBusId, deviceCount));
|
|
}
|
|
|
|
// attr is Invalid Attribute
|
|
SECTION("attr is invalid") {
|
|
REQUIRE_FALSE(hipSuccess ==
|
|
hipDeviceGetAttribute(&pi, static_cast<hipDeviceAttribute_t>(-1), device));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - verify hipDeviceAttributeHostRegisterSupported attribute.
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/device/hipGetDeviceAttribute.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 6.0
|
|
*/
|
|
HIP_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<int>(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 {
|
|
HIP_SKIP_TEST(
|
|
"Skipping the test as GPU 0 doesn't support "
|
|
"hipDeviceAttributeHostRegisterSupported attribute.\n");
|
|
}
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipGetDeviceAttribute_hipDeviceAttributeGPUDirectRDMAWithHipVMMSupported) {
|
|
int hipVmmSupported = 0, hipDmaBufSupported = 0, hipRDMAWithHipVMMSupported = 0;
|
|
HIP_CHECK(hipDeviceGetAttribute(&hipRDMAWithHipVMMSupported, hipDeviceAttributeGPUDirectRDMAWithHipVMMSupported, 0));
|
|
HIP_CHECK(hipDeviceGetAttribute(&hipVmmSupported, hipDeviceAttributeVirtualMemoryManagementSupported, 0));
|
|
HIP_CHECK(hipDeviceGetAttribute(&hipDmaBufSupported, hipDeviceAttributeDmaBufSupported, 0));
|
|
INFO("hipDeviceAttributeGPUDirectRDMAWithHipVMMSupported: " << hipRDMAWithHipVMMSupported);
|
|
INFO("hipDeviceAttributeVirtualMemoryManagementSupported: " << hipVmmSupported);
|
|
INFO("hipDeviceAttributeDmaBufSupported: " << hipDmaBufSupported);
|
|
REQUIRE(hipRDMAWithHipVMMSupported == (hipVmmSupported && hipDmaBufSupported));
|
|
}
|
|
/**
|
|
* End doxygen group DeviceTest.
|
|
* @}
|
|
*/
|