SWDEV-417075 - add hipDrvAddMemCpyNode
Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: Ie631d7b1788f10171a29d463759a3cba3b2b2007 SWDEV-417075 - add hipDrvGraphAddMemcpyNode Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: I6bab3310919643e119cd0004276907e223641cfb
This commit is contained in:
@@ -1173,7 +1173,8 @@ class GraphMemcpyNode : public GraphNode {
|
||||
}
|
||||
|
||||
virtual hipError_t CreateCommand(hip::Stream* stream) {
|
||||
if (IsHtoHMemcpy(copyParams_.dstPtr.ptr, copyParams_.srcPtr.ptr, copyParams_.kind)) {
|
||||
if ((copyParams_.kind == hipMemcpyHostToHost || copyParams_.kind == hipMemcpyDefault)
|
||||
&& IsHtoHMemcpy(copyParams_.dstPtr.ptr, copyParams_.srcPtr.ptr)) {
|
||||
return hipSuccess;
|
||||
}
|
||||
hipError_t status = GraphNode::CreateCommand(stream);
|
||||
@@ -1188,7 +1189,8 @@ class GraphMemcpyNode : public GraphNode {
|
||||
}
|
||||
|
||||
virtual void EnqueueCommands(hipStream_t stream) override {
|
||||
if (isEnabled_ && IsHtoHMemcpy(copyParams_.dstPtr.ptr, copyParams_.srcPtr.ptr, copyParams_.kind)) {
|
||||
if ( (copyParams_.kind == hipMemcpyHostToHost || copyParams_.kind == hipMemcpyDefault) &&
|
||||
isEnabled_ && IsHtoHMemcpy(copyParams_.dstPtr.ptr, copyParams_.srcPtr.ptr)) {
|
||||
ihipHtoHMemcpy(copyParams_.dstPtr.ptr, copyParams_.srcPtr.ptr,
|
||||
copyParams_.extent.width * copyParams_.extent.height *
|
||||
copyParams_.extent.depth, *hip::getStream(stream));
|
||||
@@ -1326,7 +1328,7 @@ class GraphMemcpyNode1D : public GraphMemcpyNode {
|
||||
}
|
||||
|
||||
virtual hipError_t CreateCommand(hip::Stream* stream) {
|
||||
if (IsHtoHMemcpy(dst_, src_, kind_)) {
|
||||
if ((kind_ == hipMemcpyHostToHost || kind_ == hipMemcpyDefault) && IsHtoHMemcpy(dst_, src_)) {
|
||||
return hipSuccess;
|
||||
}
|
||||
hipError_t status = GraphNode::CreateCommand(stream);
|
||||
@@ -1341,7 +1343,10 @@ class GraphMemcpyNode1D : public GraphMemcpyNode {
|
||||
}
|
||||
|
||||
virtual void EnqueueCommands(hipStream_t stream) {
|
||||
bool isH2H = IsHtoHMemcpy(dst_, src_, kind_);
|
||||
bool isH2H = false;
|
||||
if ((kind_ == hipMemcpyHostToHost || kind_ == hipMemcpyDefault) && IsHtoHMemcpy(dst_, src_)) {
|
||||
isH2H = true;
|
||||
}
|
||||
if (!isH2H) {
|
||||
if (commands_.empty()) return;
|
||||
// commands_ should have just 1 item
|
||||
@@ -2233,4 +2238,80 @@ class GraphMemFreeNode : public GraphNode {
|
||||
*params = device_ptr_;
|
||||
}
|
||||
};
|
||||
|
||||
class GraphDrvMemcpyNode : public GraphNode {
|
||||
HIP_MEMCPY3D copyParams_;
|
||||
|
||||
public:
|
||||
GraphDrvMemcpyNode(const HIP_MEMCPY3D* pCopyParams)
|
||||
: GraphNode(hipGraphNodeTypeMemcpy, "solid", "trapezium", "MEMCPY") {
|
||||
copyParams_ = *pCopyParams;
|
||||
}
|
||||
~GraphDrvMemcpyNode() {}
|
||||
|
||||
GraphDrvMemcpyNode(const GraphDrvMemcpyNode& rhs) : GraphNode(rhs) {
|
||||
copyParams_ = rhs.copyParams_;
|
||||
}
|
||||
|
||||
GraphNode* clone() const {
|
||||
return new GraphDrvMemcpyNode(static_cast<GraphDrvMemcpyNode const&>(*this));
|
||||
}
|
||||
|
||||
hipError_t CreateCommand(hip::Stream* stream) {
|
||||
if(copyParams_.srcMemoryType == hipMemoryTypeHost &&
|
||||
copyParams_.dstMemoryType == hipMemoryTypeHost &&
|
||||
IsHtoHMemcpy(copyParams_.dstHost, copyParams_.srcHost)) {
|
||||
return hipSuccess;
|
||||
}
|
||||
hipError_t status = GraphNode::CreateCommand(stream);
|
||||
if (status != hipSuccess) {
|
||||
return status;
|
||||
}
|
||||
commands_.reserve(1);
|
||||
amd::Command* command;
|
||||
status = ihipGetMemcpyParam3DCommand(command, ©Params_, stream);
|
||||
commands_.emplace_back(command);
|
||||
return status;
|
||||
}
|
||||
|
||||
void EnqueueCommands(hipStream_t stream) override {
|
||||
bool isHtoH = false;
|
||||
if(copyParams_.srcMemoryType == hipMemoryTypeHost &&
|
||||
copyParams_.dstMemoryType == hipMemoryTypeHost &&
|
||||
IsHtoHMemcpy(copyParams_.dstHost, copyParams_.srcHost)) {
|
||||
isHtoH = true;
|
||||
}
|
||||
if (isEnabled_ && isHtoH) {
|
||||
ihipHtoHMemcpy(copyParams_.dstHost, copyParams_.srcHost,
|
||||
copyParams_.WidthInBytes * copyParams_.Height *
|
||||
copyParams_.Depth, *hip::getStream(stream));
|
||||
return;
|
||||
}
|
||||
GraphNode::EnqueueCommands(stream);
|
||||
}
|
||||
|
||||
void GetParams(HIP_MEMCPY3D* params) {
|
||||
std::memcpy(params, ©Params_, sizeof(HIP_MEMCPY3D));
|
||||
}
|
||||
hipError_t SetParams(const HIP_MEMCPY3D* params) {
|
||||
hipError_t status = ValidateParams(params);
|
||||
if (status != hipSuccess) {
|
||||
return status;
|
||||
}
|
||||
std::memcpy(©Params_, params, sizeof(HIP_MEMCPY3D));
|
||||
return hipSuccess;
|
||||
}
|
||||
hipError_t SetParams(GraphNode* node) {
|
||||
const GraphDrvMemcpyNode* memcpyNode = static_cast<GraphDrvMemcpyNode const*>(node);
|
||||
return SetParams(&memcpyNode->copyParams_);
|
||||
}
|
||||
// ToDo: use this when commands are cloned and command params are to be updated
|
||||
hipError_t ValidateParams(const HIP_MEMCPY3D* pNodeParams) {
|
||||
hipError_t status = ihipDrvMemcpy3D_validate(pNodeParams);
|
||||
if (status != hipSuccess) {
|
||||
return status;
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
};
|
||||
} // namespace hip
|
||||
|
||||
Reference in New Issue
Block a user