diff --git a/hipamd/src/hip_graph.cpp b/hipamd/src/hip_graph.cpp index 9be59fe76c..2725d59f37 100644 --- a/hipamd/src/hip_graph.cpp +++ b/hipamd/src/hip_graph.cpp @@ -1932,8 +1932,9 @@ hipError_t hipGraphExecMemcpyNodeSetParamsFromSymbol(hipGraphExec_t hGraphExec, if (clonedNode == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + constexpr bool kCheckDeviceIsSame = true; HIP_RETURN(reinterpret_cast(clonedNode) - ->SetParams(dst, symbol, count, offset, kind)); + ->SetParams(dst, symbol, count, offset, kind, kCheckDeviceIsSame)); } hipError_t hipGraphAddMemcpyNodeToSymbol(hipGraphNode_t* pGraphNode, hipGraph_t graph, @@ -1994,8 +1995,9 @@ hipError_t hipGraphExecMemcpyNodeSetParamsToSymbol(hipGraphExec_t hGraphExec, hi if (clonedNode == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + constexpr bool kCheckDeviceIsSame = true; HIP_RETURN(reinterpret_cast(clonedNode) - ->SetParams(symbol, src, count, offset, kind)); + ->SetParams(symbol, src, count, offset, kind, kCheckDeviceIsSame)); } hipError_t hipGraphAddEventRecordNode(hipGraphNode_t* pGraphNode, hipGraph_t graph, diff --git a/hipamd/src/hip_graph_internal.hpp b/hipamd/src/hip_graph_internal.hpp index 3fde7af59f..02c425397a 100644 --- a/hipamd/src/hip_graph_internal.hpp +++ b/hipamd/src/hip_graph_internal.hpp @@ -1441,7 +1441,19 @@ class hipGraphMemcpyNodeFromSymbol : public hipGraphMemcpyNode1D { } hipError_t SetParams(void* dst, const void* symbol, size_t count, size_t offset, - hipMemcpyKind kind) { + hipMemcpyKind kind, bool isExec = false) { + if (isExec) { + size_t discardOffset = 0; + amd::Memory *memObj = getMemoryObject(dst, discardOffset); + if (memObj != nullptr) { + amd::Memory *memObjOri = getMemoryObject(dst_, discardOffset); + if (memObjOri != nullptr) { + if (memObjOri->getUserData().deviceId != memObj->getUserData().deviceId) { + return hipErrorInvalidValue; + } + } + } + } size_t sym_size = 0; hipDeviceptr_t device_ptr = nullptr; // check to see if dst is also a symbol (hip negative test case) @@ -1520,7 +1532,19 @@ class hipGraphMemcpyNodeToSymbol : public hipGraphMemcpyNode1D { } hipError_t SetParams(const void* symbol, const void* src, size_t count, size_t offset, - hipMemcpyKind kind) { + hipMemcpyKind kind, bool isExec = false) { + if (isExec) { + size_t discardOffset = 0; + amd::Memory *memObj = getMemoryObject(src, discardOffset); + if (memObj != nullptr) { + amd::Memory *memObjOri = getMemoryObject(src_, discardOffset); + if (memObjOri != nullptr) { + if (memObjOri->getUserData().deviceId != memObj->getUserData().deviceId) { + return hipErrorInvalidValue; + } + } + } + } size_t sym_size = 0; hipDeviceptr_t device_ptr = nullptr; // check to see if src is also a symbol (hip negative test case)