SWDEV-353281 - Initial support of memalloc in graph

Add memory allocation support in graph. Current implementation uses
cache from mempool  to hold the allocations which belong to the graph.
Also the resource tracking is disabled at this moment because mempool
operates with hip::Stream objects, but graph has execution with
amd::HostQueue objects.

Change-Id: I54fe3250126d24f5a26ada975f37d429bb4ef17b
This commit is contained in:
German Andryeyev
2022-12-14 18:54:16 -05:00
parent 873bc03034
commit eef47ca24a
13 changed files with 352 additions and 39 deletions
@@ -3792,9 +3792,19 @@ typedef struct hip_api_data_s {
};
// hipGraphAddMemAllocNode[('hipGraphNode_t*', 'pGraphNode'), ('hipGraph_t', 'graph'), ('const hipGraphNode_t*', 'pDependencies'), ('size_t', 'numDependencies'), ('hipMemAllocNodeParams*', 'pNodeParams')]
#define INIT_hipGraphAddMemAllocNode_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipGraphAddMemAllocNode.pGraphNode = (hipGraphNode_t*)pGraphNode; \
cb_data.args.hipGraphAddMemAllocNode.graph = (hipGraph_t)graph; \
cb_data.args.hipGraphAddMemAllocNode.pDependencies = (const hipGraphNode_t*)pDependencies; \
cb_data.args.hipGraphAddMemAllocNode.numDependencies = (size_t)numDependencies; \
cb_data.args.hipGraphAddMemAllocNode.pNodeParams = (hipMemAllocNodeParams*)pNodeParams; \
};
// hipGraphAddMemFreeNode[('hipGraphNode_t*', 'pGraphNode'), ('hipGraph_t', 'graph'), ('const hipGraphNode_t*', 'pDependencies'), ('size_t', 'numDependencies'), ('void*', 'dev_ptr')]
#define INIT_hipGraphAddMemFreeNode_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipGraphAddMemFreeNode.pGraphNode = (hipGraphNode_t*)pGraphNode; \
cb_data.args.hipGraphAddMemFreeNode.graph = (hipGraph_t)graph; \
cb_data.args.hipGraphAddMemFreeNode.pDependencies = (const hipGraphNode_t*)pDependencies; \
cb_data.args.hipGraphAddMemFreeNode.numDependencies = (size_t)numDependencies; \
cb_data.args.hipGraphAddMemFreeNode.dev_ptr = (void*)dev_ptr; \
};
// hipGraphAddMemcpyNode[('hipGraphNode_t*', 'pGraphNode'), ('hipGraph_t', 'graph'), ('const hipGraphNode_t*', 'pDependencies'), ('size_t', 'numDependencies'), ('const hipMemcpy3DParms*', 'pCopyParams')]
#define INIT_hipGraphAddMemcpyNode_CB_ARGS_DATA(cb_data) { \
@@ -4055,9 +4065,13 @@ typedef struct hip_api_data_s {
};
// hipGraphMemAllocNodeGetParams[('hipGraphNode_t', 'node'), ('hipMemAllocNodeParams*', 'pNodeParams')]
#define INIT_hipGraphMemAllocNodeGetParams_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipGraphMemAllocNodeGetParams.node = (hipGraphNode_t)node; \
cb_data.args.hipGraphMemAllocNodeGetParams.pNodeParams = (hipMemAllocNodeParams*)pNodeParams; \
};
// hipGraphMemFreeNodeGetParams[('hipGraphNode_t', 'node'), ('void*', 'dev_ptr')]
#define INIT_hipGraphMemFreeNodeGetParams_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipGraphMemFreeNodeGetParams.node = (hipGraphNode_t)node; \
cb_data.args.hipGraphMemFreeNodeGetParams.dev_ptr = (void*)dev_ptr; \
};
// hipGraphMemcpyNodeGetParams[('hipGraphNode_t', 'node'), ('hipMemcpy3DParms*', 'pNodeParams')]
#define INIT_hipGraphMemcpyNodeGetParams_CB_ARGS_DATA(cb_data) { \
@@ -1340,6 +1340,10 @@ typedef struct cudaHostNodeParams hipHostNodeParams;
typedef struct cudaKernelNodeParams hipKernelNodeParams;
typedef struct cudaMemsetParams hipMemsetParams;
#if CUDA_VERSION >= CUDA_11040
typedef struct cudaMemAllocNodeParams hipMemAllocNodeParams;
#endif
typedef enum cudaGraphExecUpdateResult hipGraphExecUpdateResult;
#define hipGraphExecUpdateSuccess cudaGraphExecUpdateSuccess
#define hipGraphExecUpdateError cudaGraphExecUpdateError
@@ -3208,6 +3212,30 @@ inline static hipError_t hipGraphInstantiateWithFlags(hipGraphExec_t* pGraphExec
unsigned long long flags) {
return hipCUDAErrorTohipError(cudaGraphInstantiateWithFlags(pGraphExec, graph, flags));
}
inline hipError_t hipGraphAddMemAllocNode(hipGraphNode_t* pGraphNode, hipGraph_t graph,
const hipGraphNode_t* pDependencies,
size_t numDependencies,
hipMemAllocNodeParams* pNodeParams) {
return hipCUDAErrorTohipError(cudaGraphAddMemAllocNode(
pGraphNode, graph, pDependencies, numDependencies, pNodeParams));
}
inline hipError_t hipGraphMemAllocNodeGetParams(hipGraphNode_t node,
hipMemAllocNodeParams* pNodeParams) {
return hipCUDAErrorTohipError(cudaGraphMemAllocNodeGetParams(node, pNodeParams));
}
inline hipError_t hipGraphAddMemFreeNode(hipGraphNode_t* pGraphNode, hipGraph_t graph,
const hipGraphNode_t* pDependencies,
size_t numDependencies, void* dev_ptr) {
return hipCUDAErrorTohipError(cudaGraphAddMemFreeNode(
pGraphNode, graph, pDependencies, numDependencies, dev_ptr));
}
inline hipError_t hipGraphMemFreeNodeGetParams(hipGraphNode_t node, void* dev_ptr) {
return hipCUDAErrorTohipError(cudaGraphMemFreeNodeGetParams(node, dev_ptr));
}
#endif
inline static hipError_t hipGraphLaunch(hipGraphExec_t graphExec, hipStream_t stream) {
return hipCUDAErrorTohipError(cudaGraphLaunch(graphExec, stream));