SWDEV-306642 - [ABI Break] Add texture/surface/device capabilities device struct entries

- alias hipGetDeviceProperties to hipGetDevicePropertiesR0600
- alias hipDeviceProp_t to hipDeviceProp_tR0600
- remove gcnArch from new device property struct
- add new requested struct members

Change-Id: If3f5dbef3d608487d9f6f419285f4bf577ea9bf0
Tento commit je obsažen v:
Jatin Chaudhary
2023-08-02 13:34:19 +01:00
odevzdal Rakesh Roy
rodič 813907c29d
revize 2989840511
12 změnil soubory, kde provedl 854 přidání a 430 odebrání
+373 -316
Zobrazit soubor
@@ -23,7 +23,6 @@
#include "hip_internal.hpp"
hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) {
HIP_INIT_API(hipChooseDevice, device, properties);
if (device == nullptr || properties == nullptr) {
@@ -35,99 +34,97 @@ hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) {
int count = 0;
HIP_RETURN_ONFAIL(ihipDeviceGetCount(&count));
for (cl_int i = 0; i< count; ++i) {
for (cl_int i = 0; i < count; ++i) {
hipDeviceProp_t currentProp = {0};
cl_uint validPropCount = 0;
cl_uint matchedCount = 0;
hipError_t err = ihipGetDeviceProperties(&currentProp, i);
if (properties->major != 0) {
validPropCount++;
if(currentProp.major >= properties->major) {
if (currentProp.major >= properties->major) {
matchedCount++;
}
}
if (properties->minor != 0) {
validPropCount++;
if(currentProp.minor >= properties->minor) {
if (currentProp.minor >= properties->minor) {
matchedCount++;
}
}
if(properties->totalGlobalMem != 0) {
validPropCount++;
if(currentProp.totalGlobalMem >= properties->totalGlobalMem) {
matchedCount++;
}
if (properties->totalGlobalMem != 0) {
validPropCount++;
if (currentProp.totalGlobalMem >= properties->totalGlobalMem) {
matchedCount++;
}
}
if(properties->sharedMemPerBlock != 0) {
validPropCount++;
if(currentProp.sharedMemPerBlock >= properties->sharedMemPerBlock) {
matchedCount++;
}
if (properties->sharedMemPerBlock != 0) {
validPropCount++;
if (currentProp.sharedMemPerBlock >= properties->sharedMemPerBlock) {
matchedCount++;
}
}
if(properties->maxThreadsPerBlock != 0) {
validPropCount++;
if(currentProp.maxThreadsPerBlock >= properties->maxThreadsPerBlock ) {
matchedCount++;
}
if (properties->maxThreadsPerBlock != 0) {
validPropCount++;
if (currentProp.maxThreadsPerBlock >= properties->maxThreadsPerBlock) {
matchedCount++;
}
}
if(properties->totalConstMem != 0) {
validPropCount++;
if(currentProp.totalConstMem >= properties->totalConstMem ) {
matchedCount++;
}
if (properties->totalConstMem != 0) {
validPropCount++;
if (currentProp.totalConstMem >= properties->totalConstMem) {
matchedCount++;
}
}
if(properties->multiProcessorCount != 0) {
validPropCount++;
if(currentProp.multiProcessorCount >=
properties->multiProcessorCount ) {
matchedCount++;
}
if (properties->multiProcessorCount != 0) {
validPropCount++;
if (currentProp.multiProcessorCount >= properties->multiProcessorCount) {
matchedCount++;
}
}
if(properties->maxThreadsPerMultiProcessor != 0) {
validPropCount++;
if(currentProp.maxThreadsPerMultiProcessor >=
properties->maxThreadsPerMultiProcessor ) {
matchedCount++;
}
if (properties->maxThreadsPerMultiProcessor != 0) {
validPropCount++;
if (currentProp.maxThreadsPerMultiProcessor >= properties->maxThreadsPerMultiProcessor) {
matchedCount++;
}
}
if(properties->memoryClockRate != 0) {
validPropCount++;
if(currentProp.memoryClockRate >= properties->memoryClockRate ) {
matchedCount++;
}
if (properties->memoryClockRate != 0) {
validPropCount++;
if (currentProp.memoryClockRate >= properties->memoryClockRate) {
matchedCount++;
}
}
if(properties->memoryBusWidth != 0) {
validPropCount++;
if(currentProp.memoryBusWidth >= properties->memoryBusWidth ) {
matchedCount++;
}
if (properties->memoryBusWidth != 0) {
validPropCount++;
if (currentProp.memoryBusWidth >= properties->memoryBusWidth) {
matchedCount++;
}
}
if(properties->l2CacheSize != 0) {
validPropCount++;
if(currentProp.l2CacheSize >= properties->l2CacheSize ) {
matchedCount++;
}
if (properties->l2CacheSize != 0) {
validPropCount++;
if (currentProp.l2CacheSize >= properties->l2CacheSize) {
matchedCount++;
}
}
if(properties->regsPerBlock != 0) {
validPropCount++;
if(currentProp.regsPerBlock >= properties->regsPerBlock ) {
matchedCount++;
}
if (properties->regsPerBlock != 0) {
validPropCount++;
if (currentProp.regsPerBlock >= properties->regsPerBlock) {
matchedCount++;
}
}
if(properties->maxSharedMemoryPerMultiProcessor != 0) {
validPropCount++;
if(currentProp.maxSharedMemoryPerMultiProcessor >=
properties->maxSharedMemoryPerMultiProcessor ) {
matchedCount++;
}
if (properties->maxSharedMemoryPerMultiProcessor != 0) {
validPropCount++;
if (currentProp.maxSharedMemoryPerMultiProcessor >=
properties->maxSharedMemoryPerMultiProcessor) {
matchedCount++;
}
}
if(properties->warpSize != 0) {
validPropCount++;
if(currentProp.warpSize >= properties->warpSize ) {
matchedCount++;
}
if (properties->warpSize != 0) {
validPropCount++;
if (currentProp.warpSize >= properties->warpSize) {
matchedCount++;
}
}
if(validPropCount == matchedCount) {
if (validPropCount == matchedCount) {
*device = matchedCount > maxMatchedCount ? i : *device;
maxMatchedCount = std::max(matchedCount, maxMatchedCount);
}
@@ -137,7 +134,6 @@ hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* properties) {
}
hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) {
HIP_INIT_API(hipDeviceGetAttribute, pi, attr, device);
if (pi == nullptr) {
@@ -151,214 +147,282 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device)
HIP_RETURN(hipErrorInvalidDevice);
}
//FIXME: should we cache the props, or just select from deviceHandle->info_?
// FIXME: should we cache the props, or just select from deviceHandle->info_?
hipDeviceProp_t prop = {0};
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, device));
constexpr auto int32_max = static_cast<uint64_t>(std::numeric_limits<int32_t>::max());
switch (attr) {
case hipDeviceAttributeMaxThreadsPerBlock:
*pi = prop.maxThreadsPerBlock;
break;
case hipDeviceAttributeMaxBlockDimX:
*pi = prop.maxThreadsDim[0];
break;
case hipDeviceAttributeMaxBlockDimY:
*pi = prop.maxThreadsDim[1];
break;
case hipDeviceAttributeMaxBlockDimZ:
*pi = prop.maxThreadsDim[2];
break;
case hipDeviceAttributeMaxGridDimX:
*pi = prop.maxGridSize[0];
break;
case hipDeviceAttributeMaxGridDimY:
*pi = prop.maxGridSize[1];
break;
case hipDeviceAttributeMaxGridDimZ:
*pi = prop.maxGridSize[2];
break;
case hipDeviceAttributeMaxSharedMemoryPerBlock:
*pi = prop.sharedMemPerBlock;
break;
case hipDeviceAttributeTotalConstantMemory:
// size_t to int casting
*pi = std::min(prop.totalConstMem, int32_max);
break;
case hipDeviceAttributeWarpSize:
*pi = prop.warpSize;
break;
case hipDeviceAttributeMaxRegistersPerBlock:
*pi = prop.regsPerBlock;
break;
case hipDeviceAttributeClockRate:
*pi = prop.clockRate;
break;
case hipDeviceAttributeWallClockRate:
*pi = g_devices[device]->devices()[0]->info().wallClockFrequency_;
break;
case hipDeviceAttributeMemoryClockRate:
*pi = prop.memoryClockRate;
break;
case hipDeviceAttributeMemoryBusWidth:
*pi = prop.memoryBusWidth;
break;
case hipDeviceAttributeMultiprocessorCount:
*pi = prop.multiProcessorCount;
break;
case hipDeviceAttributeComputeMode:
*pi = prop.computeMode;
break;
case hipDeviceAttributeL2CacheSize:
*pi = prop.l2CacheSize;
break;
case hipDeviceAttributeMaxThreadsPerMultiProcessor:
*pi = prop.maxThreadsPerMultiProcessor;
break;
case hipDeviceAttributeComputeCapabilityMajor:
*pi = prop.major;
break;
case hipDeviceAttributeComputeCapabilityMinor:
*pi = prop.minor;
break;
case hipDeviceAttributePciBusId:
*pi = prop.pciBusID;
break;
case hipDeviceAttributeConcurrentKernels:
*pi = prop.concurrentKernels;
break;
case hipDeviceAttributePciDeviceId:
*pi = prop.pciDeviceID;
break;
case hipDeviceAttributeMaxSharedMemoryPerMultiprocessor:
*pi = prop.maxSharedMemoryPerMultiProcessor;
break;
case hipDeviceAttributeIsMultiGpuBoard:
*pi = prop.isMultiGpuBoard;
break;
case hipDeviceAttributeCooperativeLaunch:
*pi = prop.cooperativeLaunch;
break;
case hipDeviceAttributeCooperativeMultiDeviceLaunch:
*pi = prop.cooperativeMultiDeviceLaunch;
break;
case hipDeviceAttributeIntegrated:
*pi = prop.integrated;
break;
case hipDeviceAttributeMaxTexture1DWidth:
*pi = prop.maxTexture1D;
break;
case hipDeviceAttributeMaxTexture2DWidth:
*pi = prop.maxTexture2D[0];
break;
case hipDeviceAttributeMaxTexture2DHeight:
*pi = prop.maxTexture2D[1];
break;
case hipDeviceAttributeMaxTexture3DWidth:
*pi = prop.maxTexture3D[0];
break;
case hipDeviceAttributeMaxTexture3DHeight:
*pi = prop.maxTexture3D[1];
break;
case hipDeviceAttributeMaxTexture3DDepth:
*pi = prop.maxTexture3D[2];
break;
case hipDeviceAttributeHdpMemFlushCntl:
*reinterpret_cast<unsigned int**>(pi) = prop.hdpMemFlushCntl;
break;
case hipDeviceAttributeHdpRegFlushCntl:
*reinterpret_cast<unsigned int**>(pi) = prop.hdpRegFlushCntl;
break;
case hipDeviceAttributeMaxPitch:
// size_t to int casting
*pi = std::min(prop.memPitch, int32_max);
break;
case hipDeviceAttributeTextureAlignment:
*pi = prop.textureAlignment;
break;
case hipDeviceAttributeTexturePitchAlignment:
*pi = prop.texturePitchAlignment;
break;
case hipDeviceAttributeKernelExecTimeout:
*pi = prop.kernelExecTimeoutEnabled;
break;
case hipDeviceAttributeCanMapHostMemory:
*pi = prop.canMapHostMemory;
break;
case hipDeviceAttributeEccEnabled:
*pi = prop.ECCEnabled;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedFunc:
*pi = prop.cooperativeMultiDeviceUnmatchedFunc;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedGridDim:
*pi = prop.cooperativeMultiDeviceUnmatchedGridDim;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedBlockDim:
*pi = prop.cooperativeMultiDeviceUnmatchedBlockDim;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedSharedMem:
*pi = prop.cooperativeMultiDeviceUnmatchedSharedMem;
break;
case hipDeviceAttributeAsicRevision:
*pi = prop.asicRevision;
break;
case hipDeviceAttributeManagedMemory:
*pi = prop.managedMemory;
break;
case hipDeviceAttributeDirectManagedMemAccessFromHost:
*pi = prop.directManagedMemAccessFromHost;
break;
case hipDeviceAttributeConcurrentManagedAccess:
*pi = prop.concurrentManagedAccess;
break;
case hipDeviceAttributePageableMemoryAccess:
*pi = prop.pageableMemoryAccess;
break;
case hipDeviceAttributePageableMemoryAccessUsesHostPageTables:
*pi = prop.pageableMemoryAccessUsesHostPageTables;
break;
case hipDeviceAttributeIsLargeBar:
*pi = prop.isLargeBar;
break;
case hipDeviceAttributeUnifiedAddressing:
// HIP runtime always uses SVM for host memory allocations.
// Note: Host registered memory isn't covered by this feature
// and still requires hipMemHostGetDevicePointer() call
*pi = true;
break;
case hipDeviceAttributeCanUseStreamWaitValue:
// hipStreamWaitValue64() and hipStreamWaitValue32() support
*pi = g_devices[device]->devices()[0]->info().aqlBarrierValue_;
break;
case hipDeviceAttributeImageSupport:
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().imageSupport_);
break;
case hipDeviceAttributePhysicalMultiProcessorCount:
*pi = g_devices[device]->devices()[0]->info().maxPhysicalComputeUnits_;
break;
case hipDeviceAttributeFineGrainSupport:
*pi = static_cast<int>(g_devices[device]->devices()[0]->isFineGrainSupported());
break;
case hipDeviceAttributeMemoryPoolsSupported:
*pi = HIP_MEM_POOL_SUPPORT;
break;
case hipDeviceAttributeVirtualMemoryManagementSupported:
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().virtualMemoryManagement_);
break;
case hipDeviceAttributeHostRegisterSupported:
*pi = true;
break;
default:
HIP_RETURN(hipErrorInvalidValue);
case hipDeviceAttributeMaxThreadsPerBlock:
*pi = prop.maxThreadsPerBlock;
break;
case hipDeviceAttributeAsyncEngineCount:
*pi = prop.asyncEngineCount;
break;
case hipDeviceAttributeMaxBlockDimX:
*pi = prop.maxThreadsDim[0];
break;
case hipDeviceAttributeMaxBlockDimY:
*pi = prop.maxThreadsDim[1];
break;
case hipDeviceAttributeMaxBlockDimZ:
*pi = prop.maxThreadsDim[2];
break;
case hipDeviceAttributeMaxGridDimX:
*pi = prop.maxGridSize[0];
break;
case hipDeviceAttributeMaxGridDimY:
*pi = prop.maxGridSize[1];
break;
case hipDeviceAttributeMaxGridDimZ:
*pi = prop.maxGridSize[2];
break;
case hipDeviceAttributeMaxSurface1D:
*pi = prop.maxSurface1D;
break;
case hipDeviceAttributeMaxSharedMemoryPerBlock:
*pi = prop.sharedMemPerBlock;
break;
case hipDeviceAttributeSharedMemPerBlockOptin:
*pi = prop.sharedMemPerBlockOptin;
break;
case hipDeviceAttributeSharedMemPerMultiprocessor:
*pi = prop.sharedMemPerMultiprocessor;
break;
case hipDeviceAttributeStreamPrioritiesSupported:
*pi = prop.streamPrioritiesSupported;
break;
case hipDeviceAttributeSurfaceAlignment:
*pi = prop.surfaceAlignment;
break;
case hipDeviceAttributeTotalConstantMemory:
// size_t to int casting
*pi = std::min(prop.totalConstMem, int32_max);
break;
case hipDeviceAttributeTotalGlobalMem:
*pi = std::min(prop.totalGlobalMem, int32_max);
break;
case hipDeviceAttributeWarpSize:
*pi = prop.warpSize;
break;
case hipDeviceAttributeMaxRegistersPerBlock:
*pi = prop.regsPerBlock;
break;
case hipDeviceAttributeClockRate:
*pi = prop.clockRate;
break;
case hipDeviceAttributeWallClockRate:
*pi = g_devices[device]->devices()[0]->info().wallClockFrequency_;
break;
case hipDeviceAttributeMemoryClockRate:
*pi = prop.memoryClockRate;
break;
case hipDeviceAttributeMemoryBusWidth:
*pi = prop.memoryBusWidth;
break;
case hipDeviceAttributeMultiprocessorCount:
*pi = prop.multiProcessorCount;
break;
case hipDeviceAttributeComputeMode:
*pi = prop.computeMode;
break;
case hipDeviceAttributeComputePreemptionSupported:
*pi = prop.computePreemptionSupported;
break;
case hipDeviceAttributeL2CacheSize:
*pi = prop.l2CacheSize;
break;
case hipDeviceAttributeLocalL1CacheSupported:
*pi = prop.localL1CacheSupported;
break;
case hipDeviceAttributeLuidDeviceNodeMask:
*pi = prop.luidDeviceNodeMask;
break;
case hipDeviceAttributeMaxThreadsPerMultiProcessor:
*pi = prop.maxThreadsPerMultiProcessor;
break;
case hipDeviceAttributeComputeCapabilityMajor:
*pi = prop.major;
break;
case hipDeviceAttributeComputeCapabilityMinor:
*pi = prop.minor;
break;
case hipDeviceAttributeMultiGpuBoardGroupID:
*pi = prop.multiGpuBoardGroupID;
break;
case hipDeviceAttributePciBusId:
*pi = prop.pciBusID;
break;
case hipDeviceAttributeConcurrentKernels:
*pi = prop.concurrentKernels;
break;
case hipDeviceAttributePciDeviceId:
*pi = prop.pciDeviceID;
break;
case hipDeviceAttributePciDomainID:
*pi = prop.pciDomainID;
break;
case hipDeviceAttributePersistingL2CacheMaxSize:
*pi = prop.persistingL2CacheMaxSize;
break;
case hipDeviceAttributeMaxRegistersPerMultiprocessor:
*pi = prop.regsPerMultiprocessor;
break;
case hipDeviceAttributeReservedSharedMemPerBlock:
*pi = prop.reservedSharedMemPerBlock;
break;
case hipDeviceAttributeMaxSharedMemoryPerMultiprocessor:
*pi = prop.maxSharedMemoryPerMultiProcessor;
break;
case hipDeviceAttributeIsMultiGpuBoard:
*pi = prop.isMultiGpuBoard;
break;
case hipDeviceAttributeCooperativeLaunch:
*pi = prop.cooperativeLaunch;
break;
case hipDeviceAttributeHostRegisterSupported:
*pi = 1; // AMD GPUs allow you to register host memory regardless of the GPU
break;
case hipDeviceAttributeDeviceOverlap:
*pi = prop.asyncEngineCount > 0 ? 1 : 0;
break;
case hipDeviceAttributeCooperativeMultiDeviceLaunch:
*pi = prop.cooperativeMultiDeviceLaunch;
break;
case hipDeviceAttributeIntegrated:
*pi = prop.integrated;
break;
case hipDeviceAttributeMaxTexture1DWidth:
*pi = prop.maxTexture1D;
break;
case hipDeviceAttributeMaxTexture1DLinear:
*pi = prop.maxTexture1DLinear;
break;
case hipDeviceAttributeMaxTexture1DMipmap:
*pi = prop.maxTexture1DMipmap;
break;
case hipDeviceAttributeMaxTextureCubemap:
*pi = prop.maxTextureCubemap;
break;
case hipDeviceAttributeMaxTexture2DWidth:
*pi = prop.maxTexture2D[0];
break;
case hipDeviceAttributeMaxTexture2DHeight:
*pi = prop.maxTexture2D[1];
break;
case hipDeviceAttributeMaxTexture3DWidth:
*pi = prop.maxTexture3D[0];
break;
case hipDeviceAttributeMaxTexture3DHeight:
*pi = prop.maxTexture3D[1];
break;
case hipDeviceAttributeMaxTexture3DDepth:
*pi = prop.maxTexture3D[2];
break;
case hipDeviceAttributeHdpMemFlushCntl:
*reinterpret_cast<unsigned int**>(pi) = prop.hdpMemFlushCntl;
break;
case hipDeviceAttributeHdpRegFlushCntl:
*reinterpret_cast<unsigned int**>(pi) = prop.hdpRegFlushCntl;
break;
case hipDeviceAttributeMaxPitch:
// size_t to int casting
*pi = std::min(prop.memPitch, int32_max);
break;
case hipDeviceAttributeTextureAlignment:
*pi = prop.textureAlignment;
break;
case hipDeviceAttributeTexturePitchAlignment:
*pi = prop.texturePitchAlignment;
break;
case hipDeviceAttributeKernelExecTimeout:
*pi = prop.kernelExecTimeoutEnabled;
break;
case hipDeviceAttributeCanMapHostMemory:
*pi = prop.canMapHostMemory;
break;
case hipDeviceAttributeCanUseHostPointerForRegisteredMem:
*pi = prop.canUseHostPointerForRegisteredMem;
break;
case hipDeviceAttributeEccEnabled:
*pi = prop.ECCEnabled;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedFunc:
*pi = prop.cooperativeMultiDeviceUnmatchedFunc;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedGridDim:
*pi = prop.cooperativeMultiDeviceUnmatchedGridDim;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedBlockDim:
*pi = prop.cooperativeMultiDeviceUnmatchedBlockDim;
break;
case hipDeviceAttributeCooperativeMultiDeviceUnmatchedSharedMem:
*pi = prop.cooperativeMultiDeviceUnmatchedSharedMem;
break;
case hipDeviceAttributeAsicRevision:
*pi = prop.asicRevision;
break;
case hipDeviceAttributeManagedMemory:
*pi = prop.managedMemory;
break;
case hipDeviceAttributeMaxBlocksPerMultiProcessor:
*pi = prop.maxBlocksPerMultiProcessor;
break;
case hipDeviceAttributeDirectManagedMemAccessFromHost:
*pi = prop.directManagedMemAccessFromHost;
break;
case hipDeviceAttributeGlobalL1CacheSupported:
*pi = prop.globalL1CacheSupported;
break;
case hipDeviceAttributeHostNativeAtomicSupported:
*pi = prop.hostNativeAtomicSupported;
break;
case hipDeviceAttributeConcurrentManagedAccess:
*pi = prop.concurrentManagedAccess;
break;
case hipDeviceAttributePageableMemoryAccess:
*pi = prop.pageableMemoryAccess;
break;
case hipDeviceAttributePageableMemoryAccessUsesHostPageTables:
*pi = prop.pageableMemoryAccessUsesHostPageTables;
break;
case hipDeviceAttributeIsLargeBar:
*pi = prop.isLargeBar;
break;
case hipDeviceAttributeUnifiedAddressing:
// HIP runtime always uses SVM for host memory allocations.
// Note: Host registered memory isn't covered by this feature
// and still requires hipMemHostGetDevicePointer() call
*pi = true;
break;
case hipDeviceAttributeCanUseStreamWaitValue:
// hipStreamWaitValue64() and hipStreamWaitValue32() support
*pi = g_devices[device]->devices()[0]->info().aqlBarrierValue_;
break;
case hipDeviceAttributeImageSupport:
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().imageSupport_);
break;
case hipDeviceAttributePhysicalMultiProcessorCount:
*pi = g_devices[device]->devices()[0]->info().maxPhysicalComputeUnits_;
break;
case hipDeviceAttributeFineGrainSupport:
*pi = static_cast<int>(g_devices[device]->devices()[0]->isFineGrainSupported());
break;
case hipDeviceAttributeMemoryPoolsSupported:
*pi = HIP_MEM_POOL_SUPPORT;
break;
case hipDeviceAttributeVirtualMemoryManagementSupported:
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().virtualMemoryManagement_);
break;
default:
HIP_RETURN(hipErrorInvalidValue);
}
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGetByPCIBusId(int* device, const char*pciBusIdstr) {
hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusIdstr) {
HIP_INIT_API(hipDeviceGetByPCIBusId, device, pciBusIdstr);
if (device == nullptr || pciBusIdstr == nullptr) {
@@ -369,9 +433,9 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char*pciBusIdstr) {
int pciDeviceID = -1;
int pciDomainID = -1;
bool found = false;
if (sscanf (pciBusIdstr, "%04x:%02x:%02x", reinterpret_cast<unsigned int*>(&pciDomainID),
reinterpret_cast<unsigned int*>(&pciBusID),
reinterpret_cast<unsigned int*>(&pciDeviceID)) == 0x3) {
if (sscanf(pciBusIdstr, "%04x:%02x:%02x", reinterpret_cast<unsigned int*>(&pciDomainID),
reinterpret_cast<unsigned int*>(&pciBusID),
reinterpret_cast<unsigned int*>(&pciDeviceID)) == 0x3) {
int count = 0;
HIP_RETURN_ONFAIL(ihipDeviceGetCount(&count));
for (cl_int i = 0; i < count; i++) {
@@ -380,8 +444,8 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char*pciBusIdstr) {
HIP_RETURN_ONFAIL(ihipDeviceGet(&dev, i));
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, dev));
if ((pciBusID == prop.pciBusID) && (pciDomainID == prop.pciDomainID)
&& (pciDeviceID == prop.pciDeviceID)) {
if ((pciBusID == prop.pciBusID) && (pciDomainID == prop.pciDomainID) &&
(pciDeviceID == prop.pciDeviceID)) {
*device = i;
found = true;
break;
@@ -395,10 +459,10 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char*pciBusIdstr) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGetCacheConfig ( hipFuncCache_t * cacheConfig ) {
hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) {
HIP_INIT_API(hipDeviceGetCacheConfig, cacheConfig);
if(cacheConfig == nullptr) {
if (cacheConfig == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
@@ -407,8 +471,7 @@ hipError_t hipDeviceGetCacheConfig ( hipFuncCache_t * cacheConfig ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGetLimit ( size_t* pValue, hipLimit_t limit ) {
hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) {
HIP_INIT_API(hipDeviceGetLimit, pValue, limit);
if (pValue == nullptr || limit >= hipLimitRange) {
@@ -431,8 +494,7 @@ hipError_t hipDeviceGetLimit ( size_t* pValue, hipLimit_t limit ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGetPCIBusId ( char* pciBusId, int len, int device ) {
hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) {
HIP_INIT_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device);
int count;
@@ -442,24 +504,19 @@ hipError_t hipDeviceGetPCIBusId ( char* pciBusId, int len, int device ) {
HIP_RETURN(hipErrorInvalidDevice);
}
//pciBusId should be large enough to store 13 characters including the NULL-terminator.
// pciBusId should be large enough to store 13 characters including the NULL-terminator.
if (pciBusId == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
hipDeviceProp_t prop;
HIP_RETURN_ONFAIL(ihipGetDeviceProperties(&prop, device));
auto* deviceHandle = g_devices[device]->devices()[0];
snprintf (pciBusId, len, "%04x:%02x:%02x.%01x",
prop.pciDomainID,
prop.pciBusID,
prop.pciDeviceID,
deviceHandle->info().deviceTopology_.pcie.function);
snprintf(pciBusId, len, "%04x:%02x:%02x.0", prop.pciDomainID, prop.pciBusID, prop.pciDeviceID);
HIP_RETURN(len <= 12 ? hipErrorInvalidValue : hipSuccess);
}
hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig * pConfig ) {
hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) {
HIP_INIT_API(hipDeviceGetSharedMemConfig, pConfig);
if (pConfig == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
@@ -469,7 +526,7 @@ hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig * pConfig ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceReset ( void ) {
hipError_t hipDeviceReset(void) {
HIP_INIT_API(hipDeviceReset);
hip::getCurrentDevice()->Reset();
@@ -477,7 +534,7 @@ hipError_t hipDeviceReset ( void ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceSetCacheConfig ( hipFuncCache_t cacheConfig ) {
hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) {
HIP_INIT_API(hipDeviceSetCacheConfig, cacheConfig);
// No way to set cache config yet.
@@ -485,34 +542,33 @@ hipError_t hipDeviceSetCacheConfig ( hipFuncCache_t cacheConfig ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceSetLimit ( hipLimit_t limit, size_t value ) {
hipError_t hipDeviceSetLimit(hipLimit_t limit, size_t value) {
HIP_INIT_API(hipDeviceSetLimit, limit, value);
if (limit >= hipLimitRange) {
HIP_RETURN(hipErrorInvalidValue);
}
switch(limit) {
case hipLimitStackSize :
// need to query device size and take action
if (!hip::getCurrentDevice()->devices()[0]->UpdateStackSize(value)) {
HIP_RETURN(hipErrorInvalidValue);
}
break;
case hipLimitMallocHeapSize:
if (!hip::getCurrentDevice()->devices()[0]->UpdateInitialHeapSize(value)) {
HIP_RETURN(hipErrorInvalidValue);
}
break;
default:
LogPrintfError("UnsupportedLimit = %d is passed", limit);
HIP_RETURN(hipErrorUnsupportedLimit);
switch (limit) {
case hipLimitStackSize:
// need to query device size and take action
if (!hip::getCurrentDevice()->devices()[0]->UpdateStackSize(value)) {
HIP_RETURN(hipErrorInvalidValue);
}
break;
case hipLimitMallocHeapSize:
if (!hip::getCurrentDevice()->devices()[0]->UpdateInitialHeapSize(value)) {
HIP_RETURN(hipErrorInvalidValue);
}
break;
default:
LogPrintfError("UnsupportedLimit = %d is passed", limit);
HIP_RETURN(hipErrorUnsupportedLimit);
}
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig config ) {
hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) {
HIP_INIT_API(hipDeviceSetSharedMemConfig, config);
if (config != hipSharedMemBankSizeDefault &&
config != hipSharedMemBankSizeFourByte &&
if (config != hipSharedMemBankSizeDefault && config != hipSharedMemBankSizeFourByte &&
config != hipSharedMemBankSizeEightByte) {
HIP_RETURN(hipErrorInvalidValue);
}
@@ -530,13 +586,13 @@ hipError_t hipDeviceSynchronize() {
int ihipGetDevice() {
hip::Device* device = hip::getCurrentDevice();
if(device == nullptr){
if (device == nullptr) {
return -1;
}
return device->deviceId();
}
hipError_t hipGetDevice ( int* deviceId ) {
hipError_t hipGetDevice(int* deviceId) {
HIP_INIT_API(hipGetDevice, deviceId);
if (deviceId != nullptr) {
@@ -551,13 +607,13 @@ hipError_t hipGetDevice ( int* deviceId ) {
}
}
hipError_t hipGetDeviceCount ( int* count ) {
hipError_t hipGetDeviceCount(int* count) {
HIP_INIT_API_NO_RETURN(hipGetDeviceCount, count);
HIP_RETURN(ihipDeviceGetCount(count));
}
hipError_t hipGetDeviceFlags ( unsigned int* flags ) {
hipError_t hipGetDeviceFlags(unsigned int* flags) {
HIP_INIT_API(hipGetDeviceFlags, flags);
if (flags == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
@@ -566,7 +622,7 @@ hipError_t hipGetDeviceFlags ( unsigned int* flags ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipSetDevice ( int device ) {
hipError_t hipSetDevice(int device) {
HIP_INIT_API_NO_RETURN(hipSetDevice, device);
if (static_cast<unsigned int>(device) < g_devices.size()) {
hip::setCurrentDevice(device);
@@ -578,7 +634,7 @@ hipError_t hipSetDevice ( int device ) {
HIP_RETURN(hipErrorInvalidDevice);
}
hipError_t hipSetDeviceFlags ( unsigned int flags ) {
hipError_t hipSetDeviceFlags(unsigned int flags) {
HIP_INIT_API(hipSetDeviceFlags, flags);
if (g_devices.empty()) {
HIP_RETURN(hipErrorNoDevice);
@@ -590,9 +646,10 @@ hipError_t hipSetDeviceFlags ( unsigned int flags ) {
// Only one scheduling flag allowed a time
uint32_t scheduleFlag = flags & hipDeviceScheduleMask;
if (((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleSpin) && ((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleYield)
&& ((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleBlockingSync)
&& ((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleAuto)) {
if (((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleSpin) &&
((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleYield) &&
((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleBlockingSync) &&
((scheduleFlag & mutualExclusiveFlags) != hipDeviceScheduleAuto)) {
HIP_RETURN(hipErrorInvalidValue);
}
@@ -625,7 +682,7 @@ hipError_t hipSetDeviceFlags ( unsigned int flags ) {
HIP_RETURN(hipSuccess);
}
hipError_t hipSetValidDevices ( int* device_arr, int len ) {
hipError_t hipSetValidDevices(int* device_arr, int len) {
HIP_INIT_API(hipSetValidDevices, device_arr, len);
assert(0 && "Unimplemented");