SWDEV-403382 - Add missing graph APIs
- add external semaphor signal and wait node Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: If205d48bc4fb60ce2966ca6ed0419e7700755bdd
This commit is contained in:
@@ -870,6 +870,24 @@ typedef int (*t_hipGetStreamDeviceId)(hipStream_t stream);
|
|||||||
typedef hipError_t (*t_hipDrvGraphAddMemsetNode)(hipGraphNode_t* phGraphNode, hipGraph_t hGraph,
|
typedef hipError_t (*t_hipDrvGraphAddMemsetNode)(hipGraphNode_t* phGraphNode, hipGraph_t hGraph,
|
||||||
const hipGraphNode_t* dependencies, size_t numDependencies,
|
const hipGraphNode_t* dependencies, size_t numDependencies,
|
||||||
const HIP_MEMSET_NODE_PARAMS* memsetParams, hipCtx_t ctx);
|
const HIP_MEMSET_NODE_PARAMS* memsetParams, hipCtx_t ctx);
|
||||||
|
typedef hipError_t (*t_hipGraphAddExternalSemaphoresWaitNode)(hipGraphNode_t* pGraphNode, hipGraph_t graph,
|
||||||
|
const hipGraphNode_t* pDependencies, size_t numDependencies,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams);
|
||||||
|
typedef hipError_t (*t_hipGraphAddExternalSemaphoresSignalNode)(hipGraphNode_t* pGraphNode, hipGraph_t graph,
|
||||||
|
const hipGraphNode_t* pDependencies, size_t numDependencies,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams);
|
||||||
|
typedef hipError_t (*t_hipGraphExternalSemaphoresSignalNodeSetParams)(hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams);
|
||||||
|
typedef hipError_t (*t_hipGraphExternalSemaphoresWaitNodeSetParams)(hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams);
|
||||||
|
typedef hipError_t (*t_hipGraphExternalSemaphoresSignalNodeGetParams)(hipGraphNode_t hNode,
|
||||||
|
hipExternalSemaphoreSignalNodeParams* params_out);
|
||||||
|
typedef hipError_t (*t_hipGraphExternalSemaphoresWaitNodeGetParams)(hipGraphNode_t hNode,
|
||||||
|
hipExternalSemaphoreWaitNodeParams* params_out);
|
||||||
|
typedef hipError_t (*t_hipGraphExecExternalSemaphoresSignalNodeSetParams)(hipGraphExec_t hGraphExec, hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams);
|
||||||
|
typedef hipError_t (*t_hipGraphExecExternalSemaphoresWaitNodeSetParams)(hipGraphExec_t hGraphExec, hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams);
|
||||||
|
|
||||||
// HIP Compiler dispatch table
|
// HIP Compiler dispatch table
|
||||||
struct HipCompilerDispatchTable {
|
struct HipCompilerDispatchTable {
|
||||||
@@ -1321,4 +1339,12 @@ struct HipDispatchTable {
|
|||||||
t_hipLaunchHostFunc_spt hipLaunchHostFunc_spt_fn;
|
t_hipLaunchHostFunc_spt hipLaunchHostFunc_spt_fn;
|
||||||
t_hipGetStreamDeviceId hipGetStreamDeviceId_fn;
|
t_hipGetStreamDeviceId hipGetStreamDeviceId_fn;
|
||||||
t_hipDrvGraphAddMemsetNode hipDrvGraphAddMemsetNode_fn;
|
t_hipDrvGraphAddMemsetNode hipDrvGraphAddMemsetNode_fn;
|
||||||
|
t_hipGraphAddExternalSemaphoresWaitNode hipGraphAddExternalSemaphoresWaitNode_fn;
|
||||||
|
t_hipGraphAddExternalSemaphoresSignalNode hipGraphAddExternalSemaphoresSignalNode_fn;
|
||||||
|
t_hipGraphExternalSemaphoresSignalNodeSetParams hipGraphExternalSemaphoresSignalNodeSetParams_fn;
|
||||||
|
t_hipGraphExternalSemaphoresWaitNodeSetParams hipGraphExternalSemaphoresWaitNodeSetParams_fn;
|
||||||
|
t_hipGraphExternalSemaphoresSignalNodeGetParams hipGraphExternalSemaphoresSignalNodeGetParams_fn;
|
||||||
|
t_hipGraphExternalSemaphoresWaitNodeGetParams hipGraphExternalSemaphoresWaitNodeGetParams_fn;
|
||||||
|
t_hipGraphExecExternalSemaphoresSignalNodeSetParams hipGraphExecExternalSemaphoresSignalNodeSetParams_fn;
|
||||||
|
t_hipGraphExecExternalSemaphoresWaitNodeSetParams hipGraphExecExternalSemaphoresWaitNodeSetParams_fn;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -451,3 +451,11 @@ hipGraphMemFreeNodeGetParams
|
|||||||
hipDrvGraphAddMemcpyNode
|
hipDrvGraphAddMemcpyNode
|
||||||
hipDrvGraphAddMemsetNode
|
hipDrvGraphAddMemsetNode
|
||||||
hipExtGetLastError
|
hipExtGetLastError
|
||||||
|
hipGraphAddExternalSemaphoresSignalNode
|
||||||
|
hipGraphAddExternalSemaphoresWaitNode
|
||||||
|
hipGraphExternalSemaphoresSignalNodeSetParams
|
||||||
|
hipGraphExternalSemaphoresSignalNodeGetParams
|
||||||
|
hipGraphExternalSemaphoresWaitNodeSetParams
|
||||||
|
hipGraphExternalSemaphoresWaitNodeGetParams
|
||||||
|
hipGraphExecExternalSemaphoresSignalNodeSetParams
|
||||||
|
hipGraphExecExternalSemaphoresWaitNodeSetParams
|
||||||
|
|||||||
@@ -2623,4 +2623,117 @@ hipError_t hipGraphUpload(hipGraphExec_t graphExec, hipStream_t stream) {
|
|||||||
// memory for memAlloc nodes if any when support is added with mempool feature
|
// memory for memAlloc nodes if any when support is added with mempool feature
|
||||||
HIP_RETURN(hipSuccess);
|
HIP_RETURN(hipSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphAddExternalSemaphoresSignalNode(hipGraphNode_t* pGraphNode, hipGraph_t graph,
|
||||||
|
const hipGraphNode_t* pDependencies, size_t numDependencies,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphAddExternalSemaphoresSignalNode, pGraphNode, graph, pDependencies,
|
||||||
|
numDependencies, nodeParams);
|
||||||
|
if (pGraphNode == nullptr || graph == nullptr ||
|
||||||
|
(numDependencies > 0 && pDependencies == nullptr) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
hip::GraphNode* node = new hip::hipGraphExternalSemSignalNode(nodeParams);
|
||||||
|
hipError_t status = ihipGraphAddNode(node, reinterpret_cast<hip::Graph*>(graph),
|
||||||
|
reinterpret_cast<hip::GraphNode* const*>(pDependencies), numDependencies);
|
||||||
|
*pGraphNode = reinterpret_cast<hipGraphNode_t>(node);
|
||||||
|
HIP_RETURN(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphAddExternalSemaphoresWaitNode(hipGraphNode_t* pGraphNode, hipGraph_t graph,
|
||||||
|
const hipGraphNode_t* pDependencies, size_t numDependencies,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphAddExternalSemaphoresWaitNode, pGraphNode, graph, pDependencies,
|
||||||
|
numDependencies, nodeParams);
|
||||||
|
if (pGraphNode == nullptr || graph == nullptr ||
|
||||||
|
(numDependencies > 0 && pDependencies == nullptr) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
hip::GraphNode* node = new hip::hipGraphExternalSemWaitNode(nodeParams);
|
||||||
|
hipError_t status = ihipGraphAddNode(node, reinterpret_cast<hip::Graph*>(graph),
|
||||||
|
reinterpret_cast<hip::GraphNode* const*>(pDependencies), numDependencies);
|
||||||
|
*pGraphNode = reinterpret_cast<hipGraphNode_t>(node);
|
||||||
|
HIP_RETURN(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExternalSemaphoresSignalNodeSetParams(hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphExternalSemaphoresSignalNodeSetParams, hNode, nodeParams);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
if (!hip::GraphNode::isNodeValid(n) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
HIP_RETURN(reinterpret_cast<hip::hipGraphExternalSemSignalNode*>(n)->SetParams(nodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExternalSemaphoresWaitNodeSetParams(hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphExternalSemaphoresWaitNodeSetParams, hNode, nodeParams);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
if (!hip::GraphNode::isNodeValid(n) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
HIP_RETURN(reinterpret_cast<hip::hipGraphExternalSemWaitNode*>(n)->SetParams(nodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExternalSemaphoresSignalNodeGetParams(hipGraphNode_t hNode,
|
||||||
|
hipExternalSemaphoreSignalNodeParams* params_out) {
|
||||||
|
HIP_INIT_API(hipGraphExternalSemaphoresSignalNodeGetParams, hNode, params_out);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
if (!hip::GraphNode::isNodeValid(n) || params_out == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
reinterpret_cast<hip::hipGraphExternalSemSignalNode*>(n)->GetParams(params_out);
|
||||||
|
HIP_RETURN(hipSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExternalSemaphoresWaitNodeGetParams(hipGraphNode_t hNode,
|
||||||
|
hipExternalSemaphoreWaitNodeParams* params_out) {
|
||||||
|
HIP_INIT_API(hipGraphExternalSemaphoresWaitNodeGetParams, hNode, params_out);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
if (!hip::GraphNode::isNodeValid(n) || params_out == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
reinterpret_cast<hip::hipGraphExternalSemWaitNode*>(n)->GetParams(params_out);
|
||||||
|
HIP_RETURN(hipSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExecExternalSemaphoresSignalNodeSetParams(hipGraphExec_t hGraphExec,
|
||||||
|
hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreSignalNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphExecExternalSemaphoresSignalNodeSetParams, hGraphExec, hNode, nodeParams);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
hip::GraphExec* graphExec = reinterpret_cast<hip::GraphExec*>(hGraphExec);
|
||||||
|
if (hGraphExec == nullptr || hNode == nullptr || !hip::GraphExec::isGraphExecValid(graphExec) ||
|
||||||
|
!hip::GraphNode::isNodeValid(n) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
hip::GraphNode* clonedNode = graphExec->GetClonedNode(n);
|
||||||
|
if (clonedNode == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
HIP_RETURN(reinterpret_cast<hip::hipGraphExternalSemSignalNode*>(clonedNode)->SetParams(
|
||||||
|
nodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t hipGraphExecExternalSemaphoresWaitNodeSetParams(hipGraphExec_t hGraphExec,
|
||||||
|
hipGraphNode_t hNode,
|
||||||
|
const hipExternalSemaphoreWaitNodeParams* nodeParams) {
|
||||||
|
HIP_INIT_API(hipGraphExecExternalSemaphoresWaitNodeSetParams, hGraphExec, hNode, nodeParams);
|
||||||
|
hip::GraphNode* n = reinterpret_cast<hip::GraphNode*>(hNode);
|
||||||
|
hip::GraphExec* graphExec = reinterpret_cast<hip::GraphExec*>(hGraphExec);
|
||||||
|
if (hGraphExec == nullptr || hNode == nullptr || !hip::GraphExec::isGraphExecValid(graphExec) ||
|
||||||
|
!hip::GraphNode::isNodeValid(n) || nodeParams == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
hip::GraphNode* clonedNode = graphExec->GetClonedNode(n);
|
||||||
|
if (clonedNode == nullptr) {
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
}
|
||||||
|
HIP_RETURN(reinterpret_cast<hip::hipGraphExternalSemWaitNode*>(clonedNode)->SetParams(
|
||||||
|
nodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace hip
|
} // namespace hip
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2329,5 +2329,124 @@ class GraphDrvMemcpyNode : public GraphNode {
|
|||||||
}
|
}
|
||||||
return hipSuccess;
|
return hipSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class hipGraphExternalSemSignalNode : public GraphNode {
|
||||||
|
hipExternalSemaphoreSignalNodeParams externalSemaphorNodeParam_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
hipGraphExternalSemSignalNode(const hipExternalSemaphoreSignalNodeParams* pNodeParams)
|
||||||
|
: GraphNode(hipGraphNodeTypeExtSemaphoreSignal, "solid", "rectangle",
|
||||||
|
"EXTERNAL_SEMAPHORE_SIGNAL") {
|
||||||
|
externalSemaphorNodeParam_ = *pNodeParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
hipGraphExternalSemSignalNode(const hipGraphExternalSemSignalNode& rhs)
|
||||||
|
: GraphNode(rhs) {
|
||||||
|
externalSemaphorNodeParam_ = rhs.externalSemaphorNodeParam_;
|
||||||
|
}
|
||||||
|
|
||||||
|
~hipGraphExternalSemSignalNode() {}
|
||||||
|
|
||||||
|
GraphNode* clone() const {
|
||||||
|
return new hipGraphExternalSemSignalNode(
|
||||||
|
static_cast<hipGraphExternalSemSignalNode const&>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t CreateCommand(hip::Stream* stream) {
|
||||||
|
hipError_t status = GraphNode::CreateCommand(stream);
|
||||||
|
if (status != hipSuccess) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
unsigned int numExtSems = externalSemaphorNodeParam_.numExtSems;
|
||||||
|
commands_.reserve(numExtSems);
|
||||||
|
for (unsigned int i = 0; i < numExtSems; i++) {
|
||||||
|
if (externalSemaphorNodeParam_.extSemArray[i] != nullptr) {
|
||||||
|
amd::ExternalSemaphoreCmd* command = new amd::ExternalSemaphoreCmd(*stream,
|
||||||
|
externalSemaphorNodeParam_.extSemArray[i],
|
||||||
|
externalSemaphorNodeParam_.paramsArray[i].params.fence.value,
|
||||||
|
amd::ExternalSemaphoreCmd::COMMAND_SIGNAL_EXTSEMAPHORE);
|
||||||
|
if (command == nullptr) {
|
||||||
|
return hipErrorOutOfMemory;
|
||||||
|
}
|
||||||
|
commands_.emplace_back(command);
|
||||||
|
} else {
|
||||||
|
return hipErrorInvalidValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hipSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetParams(hipExternalSemaphoreSignalNodeParams* pNodeParams) const {
|
||||||
|
std::memcpy(pNodeParams, &externalSemaphorNodeParam_,
|
||||||
|
sizeof(hipExternalSemaphoreSignalNodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t SetParams(const hipExternalSemaphoreSignalNodeParams* pNodeParams) {
|
||||||
|
std::memcpy(&externalSemaphorNodeParam_, pNodeParams,
|
||||||
|
sizeof(hipExternalSemaphoreSignalNodeParams));
|
||||||
|
return hipSuccess;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class hipGraphExternalSemWaitNode : public GraphNode {
|
||||||
|
hipExternalSemaphoreWaitNodeParams externalSemaphorNodeParam_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
hipGraphExternalSemWaitNode(const hipExternalSemaphoreWaitNodeParams* pNodeParams)
|
||||||
|
: GraphNode(hipGraphNodeTypeExtSemaphoreWait, "solid",
|
||||||
|
"rectangle", "EXTERNAL_SEMAPHORE_WAIT") {
|
||||||
|
externalSemaphorNodeParam_ = *pNodeParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
hipGraphExternalSemWaitNode(const hipGraphExternalSemWaitNode& rhs) : GraphNode(rhs) {
|
||||||
|
externalSemaphorNodeParam_ = rhs.externalSemaphorNodeParam_;
|
||||||
|
}
|
||||||
|
~hipGraphExternalSemWaitNode() {}
|
||||||
|
|
||||||
|
GraphNode* clone() const {
|
||||||
|
return new hipGraphExternalSemWaitNode(static_cast<hipGraphExternalSemWaitNode const&>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t CreateCommand(hip::Stream* stream) {
|
||||||
|
hipError_t status = GraphNode::CreateCommand(stream);
|
||||||
|
if (status != hipSuccess) {
|
||||||
|
return status;
|
||||||
|
|
||||||
|
}
|
||||||
|
unsigned int numExtSems = externalSemaphorNodeParam_.numExtSems;
|
||||||
|
commands_.reserve(numExtSems);
|
||||||
|
for (unsigned int i = 0; i < numExtSems; i++) {
|
||||||
|
if (externalSemaphorNodeParam_.extSemArray[i] != nullptr) {
|
||||||
|
amd::ExternalSemaphoreCmd* command = new amd::ExternalSemaphoreCmd(*stream,
|
||||||
|
externalSemaphorNodeParam_.extSemArray[i],
|
||||||
|
externalSemaphorNodeParam_.paramsArray[i].params.fence.value,
|
||||||
|
amd::ExternalSemaphoreCmd::COMMAND_WAIT_EXTSEMAPHORE);
|
||||||
|
if (command == nullptr) {
|
||||||
|
return hipErrorOutOfMemory;
|
||||||
|
}
|
||||||
|
commands_.emplace_back(command);
|
||||||
|
} else {
|
||||||
|
return hipErrorInvalidValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hipSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetParams(hipExternalSemaphoreWaitNodeParams* pNodeParams) const {
|
||||||
|
std::memcpy(pNodeParams, &externalSemaphorNodeParam_,
|
||||||
|
sizeof(hipExternalSemaphoreWaitNodeParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
hipError_t SetParams(const hipExternalSemaphoreWaitNodeParams* pNodeParams) {
|
||||||
|
std::memcpy(&externalSemaphorNodeParam_, pNodeParams,
|
||||||
|
sizeof(hipExternalSemaphoreWaitNodeParams));
|
||||||
|
return hipSuccess;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace hip
|
} // namespace hip
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -504,6 +504,14 @@ global:
|
|||||||
hipGraphNodeGetEnabled;
|
hipGraphNodeGetEnabled;
|
||||||
hipGraphNodeSetEnabled;
|
hipGraphNodeSetEnabled;
|
||||||
hipGraphUpload;
|
hipGraphUpload;
|
||||||
|
hipGraphAddExternalSemaphoresSignalNode;
|
||||||
|
hipGraphAddExternalSemaphoresWaitNode;
|
||||||
|
hipGraphExternalSemaphoresSignalNodeSetParams;
|
||||||
|
hipGraphExternalSemaphoresSignalNodeGetParams;
|
||||||
|
hipGraphExternalSemaphoresWaitNodeSetParams;
|
||||||
|
hipGraphExternalSemaphoresWaitNodeGetParams;
|
||||||
|
hipGraphExecExternalSemaphoresSignalNodeSetParams;
|
||||||
|
hipGraphExecExternalSemaphoresWaitNodeSetParams;
|
||||||
local:
|
local:
|
||||||
*;
|
*;
|
||||||
} hip_5.2;
|
} hip_5.2;
|
||||||
|
|||||||
Reference in New Issue
Block a user