SWDEV-325711 - add Graph memory APIs skeleton

- hipDeviceGet/SetGraphMemAttr

- hipDeviceGraphMemTrim

- there is no memory pool for graphs currently

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Change-Id: I11db76ea7ea1c7732175fc93264448052357e8dc


[ROCm/clr commit: e8194dca76]
Этот коммит содержится в:
sdashmiz
2022-04-04 16:22:16 -04:00
коммит произвёл Shadi Dashmiz
родитель 2c9c07aaa8
Коммит 57a0d997d3
6 изменённых файлов: 142 добавлений и 1 удалений
+67 -1
Просмотреть файл
@@ -344,7 +344,10 @@ enum hip_api_id_t {
HIP_API_ID_hipMemRetainAllocationHandle = 331,
HIP_API_ID_hipMemSetAccess = 332,
HIP_API_ID_hipMemUnmap = 333,
HIP_API_ID_LAST = 333,
HIP_API_ID_hipDeviceSetGraphMemAttribute = 334,
HIP_API_ID_hipDeviceGetGraphMemAttribute = 335,
HIP_API_ID_hipDeviceGraphMemTrim = 336,
HIP_API_ID_LAST = 336,
HIP_API_ID_hipArray3DGetDescriptor = HIP_API_ID_NONE,
HIP_API_ID_hipArrayGetDescriptor = HIP_API_ID_NONE,
@@ -554,6 +557,9 @@ static inline const char* hip_api_name(const uint32_t id) {
case HIP_API_ID_hipGraphicsSubResourceGetMappedArray: return "hipGraphicsSubResourceGetMappedArray";
case HIP_API_ID_hipGraphicsUnmapResources: return "hipGraphicsUnmapResources";
case HIP_API_ID_hipGraphicsUnregisterResource: return "hipGraphicsUnregisterResource";
case HIP_API_ID_hipDeviceSetGraphMemAttribute: return "hipDeviceSetGraphMemAttribute";
case HIP_API_ID_hipDeviceGetGraphMemAttribute: return "hipDeviceGetGraphMemAttribute";
case HIP_API_ID_hipDeviceGraphMemTrim: return "hipDeviceGraphMemTrim";
case HIP_API_ID_hipHccModuleLaunchKernel: return "hipHccModuleLaunchKernel";
case HIP_API_ID_hipHostAlloc: return "hipHostAlloc";
case HIP_API_ID_hipHostFree: return "hipHostFree";
@@ -889,6 +895,9 @@ static inline uint32_t hipApiIdByName(const char* name) {
if (strcmp("hipGraphicsResourceGetMappedPointer", name) == 0) return HIP_API_ID_hipGraphicsResourceGetMappedPointer;
if (strcmp("hipGraphicsSubResourceGetMappedArray", name) == 0) return HIP_API_ID_hipGraphicsSubResourceGetMappedArray;
if (strcmp("hipGraphicsUnmapResources", name) == 0) return HIP_API_ID_hipGraphicsUnmapResources;
if (strcmp("hipDeviceGetGraphMemAttribute", name) == 0) return HIP_API_ID_hipDeviceGetGraphMemAttribute;
if (strcmp("hipDeviceSetGraphMemAttribute", name) == 0) return HIP_API_ID_hipDeviceSetGraphMemAttribute;
if (strcmp("hipDeviceGraphMemTrim", name) == 0) return HIP_API_ID_hipDeviceGraphMemTrim;
if (strcmp("hipGraphicsUnregisterResource", name) == 0) return HIP_API_ID_hipGraphicsUnregisterResource;
if (strcmp("hipHccModuleLaunchKernel", name) == 0) return HIP_API_ID_hipHccModuleLaunchKernel;
if (strcmp("hipHostAlloc", name) == 0) return HIP_API_ID_hipHostAlloc;
@@ -1930,6 +1939,19 @@ typedef struct hip_api_data_s {
size_t size__val;
hipGraphicsResource_t resource;
} hipGraphicsResourceGetMappedPointer;
struct {
int device;
hipGraphMemAttributeType attr;
void* value;
} hipDeviceGetGraphMemAttribute;
struct {
int device;
hipGraphMemAttributeType attr;
void* value;
} hipDeviceSetGraphMemAttribute;
struct {
int device;
} hipDeviceGraphMemTrim;
struct {
hipArray_t* array;
hipArray_t array__val;
@@ -3903,6 +3925,22 @@ typedef struct hip_api_data_s {
#define INIT_hipGraphicsUnregisterResource_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipGraphicsUnregisterResource.resource = (hipGraphicsResource_t)resource; \
};
// hipDeviceGetGraphMemAttribute[('int', 'device'), ('hipGraphMemAttributeType', 'attr'), ('void*', 'value')]
#define INIT_hipDeviceGetGraphMemAttribute_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipDeviceGetGraphMemAttribute.device = (int)device; \
cb_data.args.hipDeviceGetGraphMemAttribute.attr = (hipGraphMemAttributeType)attr; \
cb_data.args.hipDeviceGetGraphMemAttribute.value = (void*)value; \
};
// hipDeviceSetGraphMemAttribute[('int', 'device'), ('hipGraphMemAttributeType', 'attr'), ('void*', 'value')]
#define INIT_hipDeviceSetGraphMemAttribute_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipDeviceSetGraphMemAttribute.device = (int)device; \
cb_data.args.hipDeviceSetGraphMemAttribute.attr = (hipGraphMemAttributeType)attr; \
cb_data.args.hipDeviceSetGraphMemAttribute.value = (void*)value; \
};
// hipDeviceGraphMemTrim[('int', 'device')]
#define INIT_hipDeviceGraphMemTrim_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipDeviceGraphMemTrim.device = (int)device; \
};
// hipHccModuleLaunchKernel[('hipFunction_t', 'f'), ('unsigned int', 'globalWorkSizeX'), ('unsigned int', 'globalWorkSizeY'), ('unsigned int', 'globalWorkSizeZ'), ('unsigned int', 'blockDimX'), ('unsigned int', 'blockDimY'), ('unsigned int', 'blockDimZ'), ('size_t', 'sharedMemBytes'), ('hipStream_t', 'hStream'), ('void**', 'kernelParams'), ('void**', 'extra'), ('hipEvent_t', 'startEvent'), ('hipEvent_t', 'stopEvent')]
#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipHccModuleLaunchKernel.f = (hipFunction_t)f; \
@@ -5715,6 +5753,15 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) {
// hipGraphicsUnregisterResource[('hipGraphicsResource_t', 'resource')]
case HIP_API_ID_hipGraphicsUnregisterResource:
break;
// hipDeviceSetGraphMemAttribute[('int', 'device'), ('hipGraphMemAttributeType', 'attr'), ('void*', 'value')]
case HIP_API_ID_hipDeviceSetGraphMemAttribute:
break;
// hipDeviceGetGraphMemAttribute[('int', 'device'), ('hipGraphMemAttributeType', 'attr'), ('void*', 'value')]
case HIP_API_ID_hipDeviceGetGraphMemAttribute:
break;
// hipDeviceGraphMemTrim [('int', 'device')]
case HIP_API_ID_hipDeviceGraphMemTrim:
break;
// hipHccModuleLaunchKernel[('hipFunction_t', 'f'), ('unsigned int', 'globalWorkSizeX'), ('unsigned int', 'globalWorkSizeY'), ('unsigned int', 'globalWorkSizeZ'), ('unsigned int', 'blockDimX'), ('unsigned int', 'blockDimY'), ('unsigned int', 'blockDimZ'), ('size_t', 'sharedMemBytes'), ('hipStream_t', 'hStream'), ('void**', 'kernelParams'), ('void**', 'extra'), ('hipEvent_t', 'startEvent'), ('hipEvent_t', 'stopEvent')]
case HIP_API_ID_hipHccModuleLaunchKernel:
if (data->args.hipHccModuleLaunchKernel.kernelParams) data->args.hipHccModuleLaunchKernel.kernelParams__val = *(data->args.hipHccModuleLaunchKernel.kernelParams);
@@ -7533,6 +7580,25 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da
oss << ", numDependencies=" << data->args.hipGraphRemoveDependencies.numDependencies;
oss << ")";
break;
case HIP_API_ID_hipDeviceSetGraphMemAttribute:
oss << "hipDeviceSetGraphMemAttribute(";
oss << "device=" << data->args.hipDeviceSetGraphMemAttribute.device;
oss << ", attr=" << data->args.hipDeviceSetGraphMemAttribute.attr;
oss << ", value=" << data->args.hipDeviceSetGraphMemAttribute.value;
oss << ")";
break;
case HIP_API_ID_hipDeviceGraphMemTrim:
oss << "hipDeviceGraphMemTrim(";
oss << "device=" << data->args.hipDeviceGraphMemTrim.device;
oss << ")";
break;
case HIP_API_ID_hipDeviceGetGraphMemAttribute:
oss << "hipDeviceGetGraphMemAttribute(";
oss << "device=" << data->args.hipDeviceGetGraphMemAttribute.device;
oss << ", attr=" << data->args.hipDeviceGetGraphMemAttribute.attr;
oss << ", value=" << data->args.hipDeviceGetGraphMemAttribute.value;
oss << ")";
break;
case HIP_API_ID_hipGraphicsGLRegisterBuffer:
oss << "hipGraphicsGLRegisterBuffer(";
if (data->args.hipGraphicsGLRegisterBuffer.resource == NULL) oss << "resource=NULL";
+13
Просмотреть файл
@@ -1133,6 +1133,7 @@ typedef enum cudaStreamCaptureStatus hipStreamCaptureStatus;
typedef union cudaKernelNodeAttrValue hipKernelNodeAttrValue;
typedef enum cudaKernelNodeAttrID hipKernelNodeAttrID;
typedef enum cudaGraphMemAttributeType hipGraphMemAttributeType;
#if CUDA_VERSION >= CUDA_11030
typedef enum cudaStreamUpdateCaptureDependenciesFlags hipStreamUpdateCaptureDependenciesFlags;
@@ -3018,6 +3019,18 @@ inline static hipError_t hipGraphExecEventWaitNodeSetEvent(hipGraphExec_t hGraph
hipGraphNode_t hNode, hipEvent_t event) {
return hipCUDAErrorTohipError(cudaGraphExecEventWaitNodeSetEvent(hGraphExec, hNode, event));
}
inline static hipError_t hipDeviceGetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
return hipCUDAErrorTohipError(cudaDeviceGetGraphMemAttribute(device, attr, value));
}
inline static hipError_t hipDeviceSetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
return hipCUDAErrorTohipError(cudaDeviceSetGraphMemAttribute(device, attr, value));
}
inline static hipError_t hipDeviceGraphMemTrim(int device) {
return hipCUDAErrorTohipError(cudaDeviceGraphMemTrim(device));
}
#endif
inline static hipError_t hipGraphHostNodeSetParams(hipGraphNode_t node,
+3
Просмотреть файл
@@ -361,6 +361,9 @@ hipGraphExecHostNodeSetParams
hipGraphExecUpdate
hipGraphInstantiateWithFlags
hipGraphExecMemsetNodeSetParams
hipDeviceGetGraphMemAttribute
hipDeviceSetGraphMemAttribute
hipDeviceGraphMemTrim
amd_dbgapi_get_build_name
amd_dbgapi_get_git_hash
amd_dbgapi_get_build_id
+53
Просмотреть файл
@@ -1836,3 +1836,56 @@ hipError_t hipGraphExecUpdate(hipGraphExec_t hGraphExec, hipGraph_t hGraph,
*updateResult_out = hipGraphExecUpdateSuccess;
HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
HIP_INIT_API(hipDeviceGetGraphMemAttribute, device, attr, value);
if ((static_cast<size_t>(device) >= g_devices.size()) || device < 0 || value == nullptr) {
HIP_RETURN(hipErrorInvalidDevice);
}
// later use this to access memory pool
auto* deviceHandle = g_devices[device]->devices()[0];
switch (attr) {
case hipGraphMemAttrUsedMemCurrent:
*reinterpret_cast<int32_t*>(value) = 0;
break;
case hipGraphMemAttrUsedMemHigh:
*reinterpret_cast<int32_t*>(value) = 0;
break;
case hipGraphMemAttrReservedMemCurrent:
*reinterpret_cast<int32_t*>(value) = 0;
break;
case hipGraphMemAttrReservedMemHigh:
*reinterpret_cast<int32_t*>(value) = 0;
break;
default:
return HIP_RETURN(hipErrorInvalidValue);
}
return HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceSetGraphMemAttribute(int device, hipGraphMemAttributeType attr, void* value) {
HIP_INIT_API(hipDeviceSetGraphMemAttribute, device, attr, value);
if ((static_cast<size_t>(device) >= g_devices.size()) || device < 0 || value == nullptr) {
HIP_RETURN(hipErrorInvalidDevice);
}
// later use this to access memory pool
auto* deviceHandle = g_devices[device]->devices()[0];
switch (attr) {
case hipGraphMemAttrUsedMemHigh:
break;
case hipGraphMemAttrReservedMemHigh:
break;
default:
return HIP_RETURN(hipErrorInvalidValue);
}
return HIP_RETURN(hipSuccess);
}
hipError_t hipDeviceGraphMemTrim(int device) {
HIP_INIT_API(hipDeviceGraphMemTrim, device);
if ((static_cast<size_t>(device) >= g_devices.size()) || device < 0) {
HIP_RETURN(hipErrorInvalidDevice);
}
// not implemented yet
return HIP_RETURN(hipSuccess);
}
+3
Просмотреть файл
@@ -372,6 +372,9 @@ hipGraphExecHostNodeSetParams
hipGraphExecUpdate
hipGraphInstantiateWithFlags
hipGraphExecMemsetNodeSetParams
hipDeviceGetGraphMemAttribute
hipDeviceSetGraphMemAttribute
hipDeviceGraphMemTrim
amd_dbgapi_get_build_name
amd_dbgapi_get_git_hash
amd_dbgapi_get_build_id
+3
Просмотреть файл
@@ -382,6 +382,9 @@ global:
hipGraphExecUpdate;
hipGraphInstantiateWithFlags;
hipGraphExecMemsetNodeSetParams;
hipDeviceGetGraphMemAttribute;
hipDeviceSetGraphMemAttribute;
hipDeviceGraphMemTrim;
amd_dbgapi_get_build_name;
amd_dbgapi_get_git_hash;
amd_dbgapi_get_build_id;