diff --git a/hipamd/src/hip_device_runtime.cpp b/hipamd/src/hip_device_runtime.cpp index f93adc18b6..19a045dba4 100644 --- a/hipamd/src/hip_device_runtime.cpp +++ b/hipamd/src/hip_device_runtime.cpp @@ -442,6 +442,9 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) case hipDeviceAttributeVirtualMemoryManagementSupported: *pi = static_cast(g_devices[device]->devices()[0]->info().virtualMemoryManagement_); break; + case hipDeviceAttributeAccessPolicyMaxWindowSize: + *pi = prop.accessPolicyMaxWindowSize; + break; default: HIP_RETURN(hipErrorInvalidValue); } diff --git a/hipamd/src/hip_graph.cpp b/hipamd/src/hip_graph.cpp index 417b515b09..5f261ddd79 100644 --- a/hipamd/src/hip_graph.cpp +++ b/hipamd/src/hip_graph.cpp @@ -1422,6 +1422,9 @@ hipError_t hipGraphKernelNodeGetParams(hipGraphNode_t node, hipKernelNodeParams* pNodeParams == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (reinterpret_cast(node)->GetType() != hipGraphNodeTypeKernel){ + HIP_RETURN(hipErrorInvalidValue); + } reinterpret_cast(node)->GetParams(pNodeParams); HIP_RETURN(hipSuccess); } @@ -1433,6 +1436,9 @@ hipError_t hipGraphKernelNodeSetParams(hipGraphNode_t node, pNodeParams == nullptr || pNodeParams->func == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (reinterpret_cast(node)->GetType() != hipGraphNodeTypeKernel){ + HIP_RETURN(hipErrorInvalidValue); + } HIP_RETURN(reinterpret_cast(node)->SetParams(pNodeParams)); } @@ -1457,6 +1463,11 @@ hipError_t hipGraphKernelNodeSetAttribute(hipGraphNode_t hNode, hipKernelNodeAtt attr != hipLaunchAttributePriority) { HIP_RETURN(hipErrorInvalidValue); } + + if (reinterpret_cast(hNode)->GetType() != hipGraphNodeTypeKernel){ + HIP_RETURN(hipErrorInvalidValue); + } + HIP_RETURN(reinterpret_cast(hNode)->SetAttrParams(attr, value)); } @@ -1471,6 +1482,11 @@ hipError_t hipGraphKernelNodeGetAttribute(hipGraphNode_t hNode, hipKernelNodeAtt attr != hipLaunchAttributePriority) { HIP_RETURN(hipErrorInvalidValue); } + + if (reinterpret_cast(hNode)->GetType() != hipGraphNodeTypeKernel){ + HIP_RETURN(hipErrorInvalidValue); + } + HIP_RETURN(reinterpret_cast(hNode)->GetAttrParams(attr, value)); } diff --git a/hipamd/src/hip_graph_internal.hpp b/hipamd/src/hip_graph_internal.hpp index 61ae180fa6..fb62acc06f 100644 --- a/hipamd/src/hip_graph_internal.hpp +++ b/hipamd/src/hip_graph_internal.hpp @@ -1070,7 +1070,12 @@ class GraphKernelNode : public GraphNode { } hipError_t SetAttrParams(hipKernelNodeAttrID attr, const hipKernelNodeAttrValue* params) { - constexpr int accessPolicyMaxWindowSize = 1024; + hipDeviceProp_t prop = {0}; + hipError_t status = ihipGetDeviceProperties(&prop, ihipGetDevice()); + if (hipSuccess != status){ + return status; + } + int accessPolicyMaxWindowSize = prop.accessPolicyMaxWindowSize; // updates kernel attr params if (attr == hipKernelNodeAttributeAccessPolicyWindow) { if (params->accessPolicyWindow.hitRatio > 1 || @@ -1087,7 +1092,7 @@ class GraphKernelNode : public GraphNode { // need to check against accessPolicyMaxWindowSize from device // accessPolicyMaxWindowSize not implemented on the device side yet - if (params->accessPolicyWindow.num_bytes >= accessPolicyMaxWindowSize) { + if (params->accessPolicyWindow.num_bytes > accessPolicyMaxWindowSize) { return hipErrorInvalidValue; } @@ -1099,6 +1104,10 @@ class GraphKernelNode : public GraphNode { } else if (attr == hipKernelNodeAttributeCooperative) { kernelAttr_.cooperative = params->cooperative; } else if (attr == hipLaunchAttributePriority) { + if (params->priority < hip::Stream::Priority::Low || + params->priority > hip::Stream::Priority::High){ + return hipErrorInvalidValue; + } kernelAttr_.priority = params->priority; }