From 315082e5545cd02b15fabbed7a38d400e09206ea Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Thu, 31 Aug 2023 15:55:58 +0100 Subject: [PATCH] SWDEV-419996 - Allow both kernelParams and extra arguments to be set to null When kernel function expects no parameters no error should be returned if both kernelParams and extra arguments are set to null. Change-Id: I5941bcc400b6fb380e623bdae0233ae3e4f73815 --- hipamd/src/hip_graph.cpp | 6 ------ hipamd/src/hip_graph_internal.hpp | 2 +- hipamd/src/hip_module.cpp | 6 +++++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hipamd/src/hip_graph.cpp b/hipamd/src/hip_graph.cpp index 2706135163..0b578d373c 100644 --- a/hipamd/src/hip_graph.cpp +++ b/hipamd/src/hip_graph.cpp @@ -76,12 +76,6 @@ hipError_t ihipGraphAddKernelNode(hip::GraphNode** pGraphNode, hip::Graph* graph return hipErrorInvalidValue; } - // If neither 'kernelParams' or 'extra' are provided or if both are provided, return error - if ((pNodeParams->kernelParams == nullptr && pNodeParams->extra == nullptr) || - (pNodeParams->kernelParams != nullptr && pNodeParams->extra != nullptr)) { - return hipErrorInvalidValue; - } - hipError_t status = hip::GraphKernelNode::validateKernelParams(pNodeParams); if (hipSuccess != status) { return status; diff --git a/hipamd/src/hip_graph_internal.hpp b/hipamd/src/hip_graph_internal.hpp index 9038ce937e..0c079f058a 100644 --- a/hipamd/src/hip_graph_internal.hpp +++ b/hipamd/src/hip_graph_internal.hpp @@ -920,7 +920,7 @@ class GraphKernelNode : public GraphNode { kernelParams_.kernelParams = nullptr; } // Deallocate memory allocated for kernargs passed via 'extra' - else { + else if (kernelParams_.extra != nullptr) { free(kernelParams_.extra[1]); free(kernelParams_.extra[3]); memset(kernelParams_.extra, 0, 5 * sizeof(kernelParams_.extra[0])); // 5 items diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index 4dcebaee93..755a5594e2 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -234,6 +234,11 @@ hipError_t ihipLaunchKernel_validate(hipFunction_t f, uint32_t globalWorkSizeX, } hip::DeviceFunc* function = hip::DeviceFunc::asFunction(f); amd::Kernel* kernel = function->kernel(); + const amd::KernelSignature& signature = kernel->signature(); + if ((signature.numParameters() > 0) && (kernelParams == nullptr) && (extra == nullptr)) { + LogPrintfError("%s","At least one of kernelParams or extra Params should be provided"); + return hipErrorInvalidValue; + } if (!kernel->getDeviceKernel(*device)) { return hipErrorInvalidDevice; } @@ -285,7 +290,6 @@ hipError_t ihipLaunchKernel_validate(hipFunction_t f, uint32_t globalWorkSizeX, kernargs = reinterpret_cast
(extra[1]); } - const amd::KernelSignature& signature = kernel->signature(); for (size_t i = 0; i < signature.numParameters(); ++i) { const amd::KernelParameterDescriptor& desc = signature.at(i); if (kernelParams == nullptr) {