SWDEV-338376 - CUDA VMM API mappings

Change-Id: I47595dbf57fcce352d23842dbbc2b98b4ec97fb5


[ROCm/clr commit: fa786c606a]
이 커밋은 다음에 포함됨:
Jaydeep Patel
2022-07-22 11:00:56 +00:00
커밋한 사람 Jaydeepkumar Patel
부모 6f564f9e76
커밋 2de8ca99ff
+78 -1
파일 보기
@@ -1177,6 +1177,16 @@ typedef enum cudaMemAllocationType hipMemAllocationType;
#define hipMemAllocationTypePinned cudaMemAllocationTypePinned
#define hipMemAllocationTypeMax cudaMemAllocationTypeMax
#define hipMemGenericAllocationHandle_t CUmemGenericAllocationHandle
//CUarrayMapInfo mappings
typedef CUarrayMapInfo hipArrayMapInfo;
typedef CUarraySparseSubresourceType hipArraySparseSubresourceType;
#define hipArraySparseSubresourceTypeSparseLevel CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL
#define hipArraySparseSubresourceTypeMiptail CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL
typedef CUmemOperationType hipMemOperationType;
#define hipMemOperationTypeMap CU_MEM_OPERATION_TYPE_MAP
#define hipMemOperationTypeUnmap CU_MEM_OPERATION_TYPE_UNMAP
typedef CUmemHandleType hipMemHandleType;
#define hipMemHandleTypeGeneric CU_MEM_HANDLE_TYPE_GENERIC
// Explicitely declaring hipMemAllocationProp based on CUmemAllocationProp but using CUDA runtime members instead
// Because hipMemAllocationType, hipMemAllocationHandleType & hipMemLocation are defined using CUDA runtime data types & also used by hipMemPoolProps
// Currently there doesn't exist CUDA inbuilt runtime structure corresponding to CUmemAllocationProp
@@ -1939,7 +1949,19 @@ inline static CUmemAllocationProp hipMemAllocationPropToCUmemAllocationProp(cons
cuProp.allocFlags.reserved[3] = prop->allocFlags.reserved[3];
return cuProp;
}
inline static CUmemLocation hipMemLocationToCUmemLocation(const hipMemLocation* loc) {
CUmemLocation cuLoc;
cuLoc.id = loc->id;
cuLoc.type = (CUmemLocationType)loc->type;
return cuLoc;
}
inline static CUmemAccessDesc hipMemAccessDescToCUmemAccessDesc(const hipMemAccessDesc* desc) {
CUmemAccessDesc cuDesc;
cuDesc.flags = (CUmemAccess_flags)desc->flags;
cuDesc.location.id = (desc->location).id;
cuDesc.location.type = (CUmemLocationType)((desc->location).type);
return cuDesc;
}
inline static hipError_t hipMemGetAllocationGranularity(size_t* granularity,
const hipMemAllocationProp* prop,
hipMemAllocationGranularity_flags option) {
@@ -1956,6 +1978,61 @@ inline static hipError_t hipMemCreate(hipMemGenericAllocationHandle_t* handle,
inline static hipError_t hipMemRelease(hipMemGenericAllocationHandle_t handle) {
return hipCUResultTohipError(cuMemRelease(handle));
}
inline static hipError_t hipMemAddressFree(hipDeviceptr_t ptr, size_t size) {
return hipCUResultTohipError(cuMemAddressFree(ptr, size));
}
inline static hipError_t hipMemAddressReserve(hipDeviceptr_t* ptr,
size_t size,
size_t alignment,
hipDeviceptr_t addr,
unsigned long long flags) {
return hipCUResultTohipError(cuMemAddressReserve(ptr, size, alignment, addr, flags));
}
inline static hipError_t hipMemExportToShareableHandle(void* shareableHandle,
hipMemGenericAllocationHandle_t handle,
hipMemAllocationHandleType handleType,
unsigned long long flags) {
return hipCUResultTohipError(cuMemExportToShareableHandle(shareableHandle, handle, (CUmemAllocationHandleType)handleType, flags));
}
inline static hipError_t hipMemGetAccess(unsigned long long* flags,
const hipMemLocation* location,
hipDeviceptr_t ptr) {
CUmemLocation loc = hipMemLocationToCUmemLocation(location);
return hipCUResultTohipError(cuMemGetAccess(flags, &loc, ptr));
}
inline static hipError_t hipMemGetAllocationPropertiesFromHandle(hipMemAllocationProp* prop,
hipMemGenericAllocationHandle_t handle) {
CUmemAllocationProp cuProp = hipMemAllocationPropToCUmemAllocationProp(prop);
return hipCUResultTohipError(cuMemGetAllocationPropertiesFromHandle(&cuProp, handle));
}
inline static hipError_t hipMemImportFromShareableHandle(hipMemGenericAllocationHandle_t* handle,
void* osHandle,
hipMemAllocationHandleType shHandleType) {
return hipCUResultTohipError(cuMemImportFromShareableHandle(handle, osHandle, (CUmemAllocationHandleType)shHandleType));
}
inline static hipError_t hipMemMap(hipDeviceptr_t ptr, size_t size, size_t offset,
hipMemGenericAllocationHandle_t handle,
unsigned long long flags) {
return hipCUResultTohipError(cuMemMap(ptr, size, offset, handle, flags));
}
inline static hipError_t hipMemMapArrayAsync(hipArrayMapInfo* mapInfoList,
unsigned int count,
hipStream_t stream) {
return hipCUResultTohipError(cuMemMapArrayAsync(mapInfoList, count, stream));
}
inline static hipError_t hipMemRetainAllocationHandle(hipMemGenericAllocationHandle_t* handle,
void* addr) {
return hipCUResultTohipError(cuMemRetainAllocationHandle(handle, addr));
}
inline static hipError_t hipMemSetAccess(hipDeviceptr_t ptr, size_t size,
const hipMemAccessDesc* desc,
size_t count) {
CUmemAccessDesc cuDesc = hipMemAccessDescToCUmemAccessDesc(desc);
return hipCUResultTohipError(cuMemSetAccess(ptr, size, &cuDesc, count));
}
inline static hipError_t hipMemUnmap(hipDeviceptr_t ptr, size_t size) {
return hipCUResultTohipError(cuMemUnmap(ptr, size));
}
#endif // CUDA_VERSION >= CUDA_10020
inline static hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks,