SWDEV-318833 - Get and Set attribute for kernel nodes
Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: Ie51aa4b56661cbb8c5b4eb1dbaad327377084ffb Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Этот коммит содержится в:
коммит произвёл
Shadi Dashmiz
родитель
43c650cf48
Коммит
efd2d55e9d
@@ -1131,6 +1131,10 @@ typedef enum cudaStreamCaptureStatus hipStreamCaptureStatus;
|
||||
#define hipStreamCaptureStatusActive cudaStreamCaptureStatusActive
|
||||
#define hipStreamCaptureStatusInvalidated cudaStreamCaptureStatusInvalidated
|
||||
|
||||
typedef union cudaKernelNodeAttrValue hipKernelNodeAttrValue;
|
||||
typedef enum cudaKernelNodeAttrID hipKernelNodeAttrID;
|
||||
|
||||
|
||||
#if CUDA_VERSION >= CUDA_11030
|
||||
typedef enum cudaStreamUpdateCaptureDependenciesFlags hipStreamUpdateCaptureDependenciesFlags;
|
||||
#define hipStreamAddCaptureDependencies cudaStreamAddCaptureDependencies
|
||||
@@ -2677,6 +2681,16 @@ inline static hipError_t hipGraphKernelNodeSetParams(hipGraphNode_t node,
|
||||
return hipCUDAErrorTohipError(cudaGraphKernelNodeSetParams(node, pNodeParams));
|
||||
}
|
||||
|
||||
inline static hipError_t hipGraphKernelNodeSetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr,
|
||||
const hipKernelNodeAttrValue* value) {
|
||||
return hipCUDAErrorTohipError(cudaGraphKernelNodeSetAttribute(hNode, attr, value));
|
||||
}
|
||||
|
||||
inline static hipError_t hipGraphKernelNodeGetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr,
|
||||
hipKernelNodeAttrValue* value) {
|
||||
return hipCUDAErrorTohipError(cudaGraphKernelNodeGetAttribute(hNode, attr, value));
|
||||
}
|
||||
|
||||
inline static hipError_t hipGraphMemcpyNodeGetParams(hipGraphNode_t node,
|
||||
hipMemcpy3DParms* pNodeParams) {
|
||||
return hipCUDAErrorTohipError(cudaGraphMemcpyNodeGetParams(node, pNodeParams));
|
||||
|
||||
@@ -314,6 +314,8 @@ hipGraphGetNodes
|
||||
hipGraphGetRootNodes
|
||||
hipGraphKernelNodeGetParams
|
||||
hipGraphKernelNodeSetParams
|
||||
hipGraphKernelNodeSetAttribute
|
||||
hipGraphKernelNodeGetAttribute
|
||||
hipGraphMemcpyNodeGetParams
|
||||
hipGraphMemcpyNodeSetParams
|
||||
hipGraphMemsetNodeGetParams
|
||||
|
||||
@@ -1113,6 +1113,30 @@ hipError_t hipGraphMemcpyNodeGetParams(hipGraphNode_t node, hipMemcpy3DParms* pN
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
hipError_t hipGraphKernelNodeSetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr,
|
||||
const hipKernelNodeAttrValue* value) {
|
||||
HIP_INIT_API(hipGraphKernelNodeSetAttribute, hNode, attr, value);
|
||||
if (hNode == nullptr || value == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
if (attr != hipKernelNodeAttributeAccessPolicyWindow && attr != hipKernelNodeAttributeCooperative ) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
HIP_RETURN(reinterpret_cast<hipGraphKernelNode*>(hNode)->SetAttrParams(attr, value));
|
||||
}
|
||||
|
||||
hipError_t hipGraphKernelNodeGetAttribute(hipGraphNode_t hNode, hipKernelNodeAttrID attr,
|
||||
hipKernelNodeAttrValue* value) {
|
||||
HIP_INIT_API(hipGraphKernelNodeGetAttribute, hNode, attr, value);
|
||||
if (hNode == nullptr || value == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
if (attr != hipKernelNodeAttributeAccessPolicyWindow && attr != hipKernelNodeAttributeCooperative ) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
HIP_RETURN(reinterpret_cast<hipGraphKernelNode*>(hNode)->GetAttrParams(attr, value));
|
||||
}
|
||||
|
||||
hipError_t hipGraphMemcpyNodeSetParams(hipGraphNode_t node, const hipMemcpy3DParms* pNodeParams) {
|
||||
HIP_INIT_API(hipGraphMemcpyNodeSetParams, node, pNodeParams);
|
||||
if (node == nullptr || pNodeParams == nullptr) {
|
||||
|
||||
@@ -60,6 +60,7 @@ struct hipGraphNode {
|
||||
struct ihipGraph* parentGraph_;
|
||||
static std::unordered_set<hipGraphNode*> nodeSet_;
|
||||
static amd::Monitor nodeSetLock_;
|
||||
hipKernelNodeAttrValue kernelAttr_;
|
||||
|
||||
public:
|
||||
hipGraphNode(hipGraphNodeType type)
|
||||
@@ -72,6 +73,7 @@ struct hipGraphNode {
|
||||
parentGraph_(nullptr) {
|
||||
amd::ScopedLock lock(nodeSetLock_);
|
||||
nodeSet_.insert(this);
|
||||
memset(&kernelAttr_, 0, sizeof(kernelAttr_));
|
||||
}
|
||||
/// Copy Constructor
|
||||
hipGraphNode(const hipGraphNode& node) {
|
||||
@@ -453,7 +455,6 @@ struct hipChildGraphNode : public hipGraphNode {
|
||||
class hipGraphKernelNode : public hipGraphNode {
|
||||
hipKernelNodeParams* pKernelParams_;
|
||||
hipFunction_t func_;
|
||||
|
||||
public:
|
||||
static hipError_t getFunc(hipFunction_t* func, const hipKernelNodeParams& params, unsigned int device) {
|
||||
hipError_t status = PlatformState::instance().getStatFunc(func, params.func, device);
|
||||
@@ -515,6 +516,40 @@ class hipGraphKernelNode : public hipGraphNode {
|
||||
std::memcpy(pKernelParams_, params, sizeof(hipKernelNodeParams));
|
||||
return status;
|
||||
}
|
||||
hipError_t SetAttrParams(hipKernelNodeAttrID attr, const hipKernelNodeAttrValue* params) {
|
||||
// updates kernel attr params
|
||||
if (attr == hipKernelNodeAttributeAccessPolicyWindow) {
|
||||
if (params->accessPolicyWindow.base_ptr == NULL) {
|
||||
return hipErrorInvalidResourceHandle;
|
||||
}
|
||||
kernelAttr_.accessPolicyWindow.base_ptr = params->accessPolicyWindow.base_ptr;
|
||||
kernelAttr_.accessPolicyWindow.hitProp = params->accessPolicyWindow.hitProp;
|
||||
kernelAttr_.accessPolicyWindow.hitRatio = params->accessPolicyWindow.hitRatio;
|
||||
kernelAttr_.accessPolicyWindow.missProp = params->accessPolicyWindow.missProp;
|
||||
kernelAttr_.accessPolicyWindow.num_bytes = params->accessPolicyWindow.num_bytes;
|
||||
} else if (attr == hipKernelNodeAttributeCooperative)
|
||||
{
|
||||
kernelAttr_.cooperative = params->cooperative;
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
hipError_t GetAttrParams(hipKernelNodeAttrID attr, hipKernelNodeAttrValue* params) {
|
||||
// Get kernel attr params
|
||||
if (attr == hipKernelNodeAttributeAccessPolicyWindow) {
|
||||
if (kernelAttr_.accessPolicyWindow.base_ptr == NULL) {
|
||||
return hipErrorInvalidResourceHandle;
|
||||
}
|
||||
params->accessPolicyWindow.base_ptr = kernelAttr_.accessPolicyWindow.base_ptr;
|
||||
params->accessPolicyWindow.hitProp = kernelAttr_.accessPolicyWindow.hitProp;
|
||||
params->accessPolicyWindow.hitRatio = kernelAttr_.accessPolicyWindow.hitRatio;
|
||||
params->accessPolicyWindow.missProp = kernelAttr_.accessPolicyWindow.missProp;
|
||||
params->accessPolicyWindow.num_bytes = kernelAttr_.accessPolicyWindow.num_bytes;
|
||||
} else if (attr == hipKernelNodeAttributeCooperative)
|
||||
{
|
||||
params->cooperative = kernelAttr_.cooperative;
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
// ToDo: use this when commands are cloned and command params are to be updated
|
||||
hipError_t SetCommandParams(const hipKernelNodeParams* params) {
|
||||
if (params->func != pKernelParams_->func) {
|
||||
|
||||
@@ -328,6 +328,8 @@ hipGraphGetRootNodes
|
||||
hipGraphKernelNodeGetParams
|
||||
hipGraphKernelNodeSetParams
|
||||
hipGraphMemcpyNodeGetParams
|
||||
hipGraphKernelNodeSetAttribute
|
||||
hipGraphKernelNodeGetAttribute
|
||||
hipGraphMemcpyNodeSetParams
|
||||
hipGraphMemsetNodeGetParams
|
||||
hipGraphMemsetNodeSetParams
|
||||
|
||||
@@ -398,6 +398,8 @@ global:
|
||||
hipPointerGetAttribute;
|
||||
hipDrvPointerGetAttributes;
|
||||
hipThreadExchangeStreamCaptureMode;
|
||||
hipGraphKernelNodeSetAttribute;
|
||||
hipGraphKernelNodeGetAttribute;
|
||||
local:
|
||||
*;
|
||||
} hip_4.5;
|
||||
|
||||
Ссылка в новой задаче
Block a user