SWDEV-427855 - hipamd change for profiler and TF fix

This reverts commit 57cb840058.

Change-Id: Id69e47a1afd336ae1edb9c8e173be27e7b9dcc8d
This commit is contained in:
Rahul Garg
2023-11-29 15:50:10 -05:00
parent 3c6505c2d5
commit afc28b091e
10 changed files with 539 additions and 381 deletions
+37 -11
View File
@@ -22,25 +22,35 @@
#include "hip_internal.hpp"
#undef hipChooseDevice
#undef hipDeviceProp_t
namespace hip {
hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) {
HIP_INIT_API(hipChooseDevice, device, properties);
template <typename DeviceProp>
hipError_t ihipChooseDevice(int* device, const DeviceProp* properties) {
if (device == nullptr || properties == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
return hipErrorInvalidValue;
}
*device = 0;
cl_uint maxMatchedCount = 0;
int count = 0;
HIP_RETURN_ONFAIL(ihipDeviceGetCount(&count));
IHIP_RETURN_ONFAIL(ihipDeviceGetCount(&count));
for (cl_int i = 0; i < count; ++i) {
hipDeviceProp_t currentProp = {0};
DeviceProp currentProp = {0};
cl_uint validPropCount = 0;
cl_uint matchedCount = 0;
hipError_t err = ihipGetDeviceProperties(&currentProp, i);
hipError_t err = hipSuccess;
if constexpr (std::is_same_v<DeviceProp, hipDeviceProp_tR0600>){
err = ihipGetDeviceProperties(&currentProp, i);
}
else {
err = hipGetDevicePropertiesR0000(&currentProp, i);
}
if (properties->major != 0) {
validPropCount++;
if (currentProp.major >= properties->major) {
@@ -132,9 +142,25 @@ hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) {
}
}
return hipSuccess;
}
hipError_t hipChooseDeviceR0600(int* device, const hipDeviceProp_tR0600* properties) {
HIP_INIT_API(hipChooseDeviceR0600, device, properties);
HIP_RETURN(ihipChooseDevice(device, properties));
}
hipError_t hipChooseDeviceR0000(int* device, const hipDeviceProp_tR0000* properties) {
HIP_INIT_API(hipChooseDeviceR0000, device, properties);
HIP_RETURN(ihipChooseDevice(device, properties));
HIP_RETURN(hipSuccess);
}
extern "C" hipError_t hipChooseDevice(int* device, const hipDeviceProp_tR0000* properties);
hipError_t hipChooseDevice(int* device, const hipDeviceProp_tR0000* properties) {
return hipChooseDeviceR0000(device, properties);
}
hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) {
HIP_INIT_API(hipDeviceGetAttribute, pi, attr, device);
@@ -150,7 +176,7 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device)
}
// FIXME: should we cache the props, or just select from deviceHandle->info_?
hipDeviceProp_t prop = {0};
hipDeviceProp_tR0600 prop = {0};
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, device));
constexpr auto int32_max = static_cast<uint64_t>(std::numeric_limits<int32_t>::max());
@@ -442,7 +468,7 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusIdstr) {
HIP_RETURN_ONFAIL(ihipDeviceGetCount(&count));
for (cl_int i = 0; i < count; i++) {
hipDevice_t dev;
hipDeviceProp_t prop;
hipDeviceProp_tR0600 prop;
HIP_RETURN_ONFAIL(ihipDeviceGet(&dev, i));
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, dev));
@@ -482,7 +508,7 @@ hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) {
switch (limit) {
case hipLimitMallocHeapSize:
hipDeviceProp_t prop;
hipDeviceProp_tR0600 prop;
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, ihipGetDevice()));
*pValue = prop.totalGlobalMem;
break;
@@ -511,7 +537,7 @@ hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) {
HIP_RETURN(hipErrorInvalidValue);
}
hipDeviceProp_t prop;
hipDeviceProp_tR0600 prop;
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, device));
snprintf(pciBusId, len, "%04x:%02x:%02x.0", prop.pciDomainID, prop.pciBusID, prop.pciDeviceID);