SWDEV-432951 - Fixed C build for nvidia

Change-Id: I61de3da60fd1274cbf8e32f16f4ecfd8c428d5d5
Tá an tiomantas seo le fáil i:
Ioannis Assiouras
2023-11-17 12:09:21 +00:00
tuismitheoir 2813f262d3
tiomantas 75ef32dfe9
@@ -552,99 +552,99 @@ typedef struct HIP_MEMCPY3D {
unsigned int Depth; unsigned int Depth;
} HIP_MEMCPY3D; } HIP_MEMCPY3D;
static inline void hipMemcpy3DTocudaMemcpy3D(CUDA_MEMCPY3D &a, const HIP_MEMCPY3D* p){ static inline void hipMemcpy3DTocudaMemcpy3D(CUDA_MEMCPY3D* a, const HIP_MEMCPY3D* p){
a.srcXInBytes = (size_t)p->srcXInBytes; a->srcXInBytes = (size_t)p->srcXInBytes;
a.srcY = (size_t)p->srcY; a->srcY = (size_t)p->srcY;
a.srcZ = (size_t)p->srcZ; a->srcZ = (size_t)p->srcZ;
a.srcLOD = (size_t)p->srcLOD; a->srcLOD = (size_t)p->srcLOD;
switch (p->srcMemoryType) { switch (p->srcMemoryType) {
case hipMemoryTypeHost: case hipMemoryTypeHost:
a.srcMemoryType = CU_MEMORYTYPE_HOST; a->srcMemoryType = CU_MEMORYTYPE_HOST;
break; break;
case hipMemoryTypeDevice: case hipMemoryTypeDevice:
a.srcMemoryType = CU_MEMORYTYPE_DEVICE; a->srcMemoryType = CU_MEMORYTYPE_DEVICE;
break; break;
case hipMemoryTypeArray: case hipMemoryTypeArray:
a.srcMemoryType = CU_MEMORYTYPE_ARRAY; a->srcMemoryType = CU_MEMORYTYPE_ARRAY;
break; break;
default: default:
a.srcMemoryType = CU_MEMORYTYPE_UNIFIED; a->srcMemoryType = CU_MEMORYTYPE_UNIFIED;
} }
a.srcHost = p->srcHost; a->srcHost = p->srcHost;
a.srcDevice =(CUdeviceptr)p->srcDevice; a->srcDevice =(CUdeviceptr)p->srcDevice;
a.srcArray = (CUarray)p->srcArray; a->srcArray = (CUarray)p->srcArray;
a.reserved0 = nullptr; a->reserved0 = NULL;
a.srcPitch = (size_t)p->srcPitch; a->srcPitch = (size_t)p->srcPitch;
a.srcHeight = (size_t)p->srcHeight; a->srcHeight = (size_t)p->srcHeight;
a.dstXInBytes = (size_t)p->dstXInBytes; a->dstXInBytes = (size_t)p->dstXInBytes;
a.dstY = (size_t)p->dstY; a->dstY = (size_t)p->dstY;
a.dstZ = (size_t)p->dstZ; a->dstZ = (size_t)p->dstZ;
a.dstLOD = (size_t)p->dstLOD; a->dstLOD = (size_t)p->dstLOD;
switch (p->dstMemoryType) { switch (p->dstMemoryType) {
case hipMemoryTypeHost: case hipMemoryTypeHost:
a.dstMemoryType = CU_MEMORYTYPE_HOST; a->dstMemoryType = CU_MEMORYTYPE_HOST;
break; break;
case hipMemoryTypeDevice: case hipMemoryTypeDevice:
a.dstMemoryType = CU_MEMORYTYPE_DEVICE; a->dstMemoryType = CU_MEMORYTYPE_DEVICE;
break; break;
case hipMemoryTypeArray: case hipMemoryTypeArray:
a.dstMemoryType = CU_MEMORYTYPE_ARRAY; a->dstMemoryType = CU_MEMORYTYPE_ARRAY;
break; break;
default: default:
a.dstMemoryType = CU_MEMORYTYPE_UNIFIED; a->dstMemoryType = CU_MEMORYTYPE_UNIFIED;
} }
a.dstHost = p->dstHost; a->dstHost = p->dstHost;
a.dstDevice = (CUdeviceptr)p->dstDevice; a->dstDevice = (CUdeviceptr)p->dstDevice;
a.dstArray = (CUarray)p->dstArray; a->dstArray = (CUarray)p->dstArray;
a.reserved1 = nullptr; a->reserved1 = NULL;
a.dstPitch = (size_t)p->dstPitch; a->dstPitch = (size_t)p->dstPitch;
a.dstHeight = (size_t)p->dstHeight; a->dstHeight = (size_t)p->dstHeight;
a.WidthInBytes = (size_t)p->WidthInBytes; a->WidthInBytes = (size_t)p->WidthInBytes;
a.Height = (size_t)p->Height; a->Height = (size_t)p->Height;
a.Depth = (size_t)p->Depth; a->Depth = (size_t)p->Depth;
} }
static inline void hipMemcpy2DTocudaMemcpy2D(CUDA_MEMCPY2D &a, const hip_Memcpy2D* p){ static inline void hipMemcpy2DTocudaMemcpy2D(CUDA_MEMCPY2D* a, const hip_Memcpy2D* p){
a.srcXInBytes = (size_t)p->srcXInBytes; a->srcXInBytes = (size_t)p->srcXInBytes;
a.srcY = (size_t)p->srcY; a->srcY = (size_t)p->srcY;
switch (p->srcMemoryType) { switch (p->srcMemoryType) {
case hipMemoryTypeHost: case hipMemoryTypeHost:
a.srcMemoryType = CU_MEMORYTYPE_HOST; a->srcMemoryType = CU_MEMORYTYPE_HOST;
break; break;
case hipMemoryTypeDevice: case hipMemoryTypeDevice:
a.srcMemoryType = CU_MEMORYTYPE_DEVICE; a->srcMemoryType = CU_MEMORYTYPE_DEVICE;
break; break;
case hipMemoryTypeArray: case hipMemoryTypeArray:
a.srcMemoryType = CU_MEMORYTYPE_ARRAY; a->srcMemoryType = CU_MEMORYTYPE_ARRAY;
break; break;
default: default:
a.srcMemoryType = CU_MEMORYTYPE_UNIFIED; a->srcMemoryType = CU_MEMORYTYPE_UNIFIED;
} }
a.srcHost = p->srcHost; a->srcHost = p->srcHost;
a.srcDevice = (CUdeviceptr)p->srcDevice; a->srcDevice = (CUdeviceptr)p->srcDevice;
a.srcArray = (CUarray)p->srcArray; a->srcArray = (CUarray)p->srcArray;
a.srcPitch = (size_t)p->srcPitch; a->srcPitch = (size_t)p->srcPitch;
a.dstXInBytes = (size_t)p->dstXInBytes; a->dstXInBytes = (size_t)p->dstXInBytes;
a.dstY = (size_t)p->dstY; a->dstY = (size_t)p->dstY;
switch (p->dstMemoryType) { switch (p->dstMemoryType) {
case hipMemoryTypeHost: case hipMemoryTypeHost:
a.dstMemoryType = CU_MEMORYTYPE_HOST; a->dstMemoryType = CU_MEMORYTYPE_HOST;
break; break;
case hipMemoryTypeDevice: case hipMemoryTypeDevice:
a.dstMemoryType = CU_MEMORYTYPE_DEVICE; a->dstMemoryType = CU_MEMORYTYPE_DEVICE;
break; break;
case hipMemoryTypeArray: case hipMemoryTypeArray:
a.dstMemoryType = CU_MEMORYTYPE_ARRAY; a->dstMemoryType = CU_MEMORYTYPE_ARRAY;
break; break;
default: default:
a.dstMemoryType = CU_MEMORYTYPE_UNIFIED; a->dstMemoryType = CU_MEMORYTYPE_UNIFIED;
} }
a.dstHost = p->dstHost; a->dstHost = p->dstHost;
a.dstDevice = (CUdeviceptr)p->dstDevice; a->dstDevice = (CUdeviceptr)p->dstDevice;
a.dstArray = (CUarray)p->dstArray; a->dstArray = (CUarray)p->dstArray;
a.dstPitch = (size_t)p->dstPitch; a->dstPitch = (size_t)p->dstPitch;
a.WidthInBytes = (size_t)p->WidthInBytes; a->WidthInBytes = (size_t)p->WidthInBytes;
a.Height = (size_t)p->Height; a->Height = (size_t)p->Height;
} }
@@ -1976,21 +1976,21 @@ inline static hipMemoryType getHipMemoryType(CUmemorytype type) {
} }
inline static hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) { inline static hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) {
if(pCopy == nullptr) { if(pCopy == NULL) {
return hipCUResultTohipError(cuMemcpy2D(nullptr)); return hipCUResultTohipError(cuMemcpy2D(NULL));
} else { } else {
CUDA_MEMCPY2D cudaCopy = {0}; CUDA_MEMCPY2D cudaCopy = {0};
hipMemcpy2DTocudaMemcpy2D(cudaCopy, pCopy); hipMemcpy2DTocudaMemcpy2D(&cudaCopy, pCopy);
return hipCUResultTohipError(cuMemcpy2D((const CUDA_MEMCPY2D*)&cudaCopy)); return hipCUResultTohipError(cuMemcpy2D((const CUDA_MEMCPY2D*)&cudaCopy));
} }
} }
inline static hipError_t hipMemcpyParam2DAsync(const hip_Memcpy2D* pCopy, hipStream_t stream __dparm(0)) { inline static hipError_t hipMemcpyParam2DAsync(const hip_Memcpy2D* pCopy, hipStream_t stream __dparm(0)) {
if(pCopy == nullptr) { if(pCopy == NULL) {
return hipCUResultTohipError(cuMemcpy2DAsync(nullptr, stream)); return hipCUResultTohipError(cuMemcpy2DAsync(NULL, stream));
} else { } else {
CUDA_MEMCPY2D cudaCopy = {0}; CUDA_MEMCPY2D cudaCopy = {0};
hipMemcpy2DTocudaMemcpy2D(cudaCopy, pCopy); hipMemcpy2DTocudaMemcpy2D(&cudaCopy, pCopy);
return hipCUResultTohipError(cuMemcpy2DAsync((const CUDA_MEMCPY2D*)&cudaCopy, stream)); return hipCUResultTohipError(cuMemcpy2DAsync((const CUDA_MEMCPY2D*)&cudaCopy, stream));
} }
} }
@@ -2004,21 +2004,21 @@ inline static hipError_t hipMemcpy3DAsync(const struct hipMemcpy3DParms *p, hipS
} }
inline static hipError_t hipDrvMemcpy3D(const HIP_MEMCPY3D* pcopy) { inline static hipError_t hipDrvMemcpy3D(const HIP_MEMCPY3D* pcopy) {
if(pcopy == nullptr) { if(pcopy == NULL) {
return hipCUResultTohipError(cuMemcpy3D(nullptr)); return hipCUResultTohipError(cuMemcpy3D(NULL));
} else { } else {
CUDA_MEMCPY3D cudaCopy = {0}; CUDA_MEMCPY3D cudaCopy = {0};
hipMemcpy3DTocudaMemcpy3D(cudaCopy, pcopy); hipMemcpy3DTocudaMemcpy3D(&cudaCopy, pcopy);
return hipCUResultTohipError(cuMemcpy3D((const CUDA_MEMCPY3D*)&cudaCopy)); return hipCUResultTohipError(cuMemcpy3D((const CUDA_MEMCPY3D*)&cudaCopy));
} }
} }
inline static hipError_t hipDrvMemcpy3DAsync(const HIP_MEMCPY3D *pcopy, hipStream_t stream) { inline static hipError_t hipDrvMemcpy3DAsync(const HIP_MEMCPY3D *pcopy, hipStream_t stream) {
if(pcopy == nullptr) { if(pcopy == NULL) {
return hipCUResultTohipError(cuMemcpy3DAsync(nullptr, stream)); return hipCUResultTohipError(cuMemcpy3DAsync(NULL, stream));
} else { } else {
CUDA_MEMCPY3D cudaCopy = {0}; CUDA_MEMCPY3D cudaCopy = {0};
hipMemcpy3DTocudaMemcpy3D(cudaCopy, pcopy); hipMemcpy3DTocudaMemcpy3D(&cudaCopy, pcopy);
return hipCUResultTohipError(cuMemcpy3DAsync((const CUDA_MEMCPY3D*)&cudaCopy, stream)); return hipCUResultTohipError(cuMemcpy3DAsync((const CUDA_MEMCPY3D*)&cudaCopy, stream));
} }
} }
@@ -2745,8 +2745,8 @@ inline static hipError_t hipPointerGetAttribute(void* data, hipPointer_attribute
hipError_t err = hipCUResultTohipError(cuPointerGetAttribute(data, attribute, ptr)); hipError_t err = hipCUResultTohipError(cuPointerGetAttribute(data, attribute, ptr));
if (err == hipSuccess && if (err == hipSuccess &&
attribute == HIP_POINTER_ATTRIBUTE_MEMORY_TYPE && attribute == HIP_POINTER_ATTRIBUTE_MEMORY_TYPE &&
data != nullptr) { data != NULL) {
*reinterpret_cast<uint32_t*>(data) = getHipMemoryType(*reinterpret_cast<CUmemorytype*>(data)); *(uint32_t*) data = getHipMemoryType(*(CUmemorytype*) data);
} }
return err; return err;
} }
@@ -2755,10 +2755,10 @@ inline static hipError_t hipDrvPointerGetAttributes(unsigned int numAttributes,
hipPointer_attribute* attributes, hipPointer_attribute* attributes,
void** data, hipDeviceptr_t ptr) { void** data, hipDeviceptr_t ptr) {
hipError_t err = hipCUResultTohipError(cuPointerGetAttributes(numAttributes, attributes, data, ptr)); hipError_t err = hipCUResultTohipError(cuPointerGetAttributes(numAttributes, attributes, data, ptr));
if (err == hipSuccess && attributes != nullptr) { if (err == hipSuccess && attributes != NULL) {
for(int i = 0; i < numAttributes; i++) { for(int i = 0; i < numAttributes; i++) {
if(attributes[i] == HIP_POINTER_ATTRIBUTE_MEMORY_TYPE) { if(attributes[i] == HIP_POINTER_ATTRIBUTE_MEMORY_TYPE) {
*reinterpret_cast<uint32_t**>(data)[i] = getHipMemoryType(*reinterpret_cast<CUmemorytype**>(data)[i]); *((uint32_t**) data)[i] = getHipMemoryType(*((CUmemorytype**) data)[i]);
break; break;
} }
} }