From b7b121fa2739b2ccff7737d28f4c9bb489ea6b1a Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 13 Jun 2018 17:09:22 -0400
Subject: [PATCH] P4 to Git Change 1567935 by gandryey@gera-w8 on 2018/06/13
16:49:10
SWDEV-79445 - OCL generic changes and code clean-up
- Remove array of hidden parameters. Hidden parameters will be placed together with OCL kernel arguments.
http://ocltc.amd.com/reviews/r/15178/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#222 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#308 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#326 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#55 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/kernel.cpp#33 edit
---
rocclr/runtime/device/device.cpp | 4 ++--
rocclr/runtime/device/device.hpp | 2 +-
rocclr/runtime/device/gpu/gpukernel.cpp | 9 +++------
rocclr/runtime/device/pal/palkernel.cpp | 23 ++++++++++++++++++-----
rocclr/runtime/device/rocm/rockernel.cpp | 6 ++----
rocclr/runtime/platform/kernel.cpp | 16 +++-------------
6 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp
index 718afc078a..d880f07b17 100644
--- a/rocclr/runtime/device/device.cpp
+++ b/rocclr/runtime/device/device.cpp
@@ -601,7 +601,7 @@ Settings::Settings() {
}
bool Kernel::createSignature(
- const parameters_t& params, const parameters_t& hiddenParams,
+ const parameters_t& params, uint32_t numParameters,
uint32_t version) {
std::stringstream attribs;
if (workGroupInfo_.compileSize_[0] != 0) {
@@ -634,7 +634,7 @@ bool Kernel::createSignature(
// Destroy old signature if it was allocated before
// (offline devices path)
delete signature_;
- signature_ = new amd::KernelSignature(params, attribs.str(), hiddenParams, version);
+ signature_ = new amd::KernelSignature(params, attribs.str(), numParameters, version);
if (NULL != signature_) {
return true;
}
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index 4c32821207..757ade8224 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -853,7 +853,7 @@ class Kernel : public amd::HeapObject {
//! Initializes the kernel parameters for the abstraction layer
bool createSignature(
- const parameters_t& params, const parameters_t& hiddenParams,
+ const parameters_t& params, uint32_t numParameters,
uint32_t version);
//! Returns TRUE if it's a HSA kernel
diff --git a/rocclr/runtime/device/gpu/gpukernel.cpp b/rocclr/runtime/device/gpu/gpukernel.cpp
index 09c911022e..f1fbae14e1 100644
--- a/rocclr/runtime/device/gpu/gpukernel.cpp
+++ b/rocclr/runtime/device/gpu/gpukernel.cpp
@@ -752,8 +752,7 @@ bool NullKernel::create(const std::string& code, const std::string& metadata,
workGroupInfo_.usedStackSize_ = calFuncInfo.stackSizeUsed;
device::Kernel::parameters_t params;
- device::Kernel::parameters_t hiddenParams;
- if (!createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_0)) {
+ if (!createSignature(params, params.size(), amd::KernelSignature::ABIVersion_0)) {
return false;
}
@@ -1338,8 +1337,7 @@ bool Kernel::initParameters() {
workGroupInfo_.localMemSize_ = hwLocalSize_;
}
- device::Kernel::parameters_t hiddenParams;
- if (!createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_0)) {
+ if (!createSignature(params, params.size(), amd::KernelSignature::ABIVersion_0)) {
return false;
}
@@ -3019,8 +3017,7 @@ void HSAILKernel::initArgList(const aclArgData* aclArg) {
}
}
- device::Kernel::parameters_t hiddenParams;
- createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_0);
+ createSignature(params, params.size(), amd::KernelSignature::ABIVersion_0);
}
void HSAILKernel::initHsailArgs(const aclArgData* aclArg) {
diff --git a/rocclr/runtime/device/pal/palkernel.cpp b/rocclr/runtime/device/pal/palkernel.cpp
index a800bf2839..a52bceda98 100644
--- a/rocclr/runtime/device/pal/palkernel.cpp
+++ b/rocclr/runtime/device/pal/palkernel.cpp
@@ -529,8 +529,11 @@ void HSAILKernel::initArgList(const aclArgData* aclArg) {
}
}
}
-
- createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_1);
+ // Save the number of OCL arguments
+ uint32_t numParams = params.size();
+ // Append the hidden arguments to the OCL arguments
+ params.insert(params.end(), hiddenParams.begin(), hiddenParams.end());
+ createSignature(params, numParams, amd::KernelSignature::ABIVersion_1);
}
void HSAILKernel::initHsailArgs(const aclArgData* aclArg) {
@@ -954,7 +957,8 @@ hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(
const amd::KernelSignature& signature = kernel.signature();
// Check if runtime has to setup hidden arguments
- for (const auto& it : signature.hiddenParameters()) {
+ for (uint32_t i = signature.numParameters(); i < signature.numParametersAll(); ++i) {
+ const auto it = signature.at(i);
size_t offset;
switch (it.info_.oclObject_) {
case amd::KernelParameterDescriptor::HiddenNone:
@@ -1387,10 +1391,19 @@ void LightningKernel::initArgList(const KernelMD& kernelMD) {
// Update read only flag
desc.info_.readOnly_ = (arguments_[i]->access_ == HSAIL_ACCESS_TYPE_RO) ? true : false;
+ if (arguments_[i]->type_ == HSAIL_ARGTYPE_IMAGE) {
+ flags_.imageEna_ = true;
+ if (desc.accessQualifier_ != CL_KERNEL_ARG_ACCESS_READ_ONLY) {
+ flags_.imageWriteEna_ = true;
+ }
+ }
params.push_back(desc);
}
-
- createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_1);
+ // Save the number of OCL arguments
+ uint32_t numParams = params.size();
+ // Append the hidden arguments to the OCL arguments
+ params.insert(params.end(), hiddenParams.begin(), hiddenParams.end());
+ createSignature(params, numParams, amd::KernelSignature::ABIVersion_1);
}
static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const std::string& name) {
diff --git a/rocclr/runtime/device/rocm/rockernel.cpp b/rocclr/runtime/device/rocm/rockernel.cpp
index b7cf1ed1c3..7cf8fb9534 100644
--- a/rocclr/runtime/device/rocm/rockernel.cpp
+++ b/rocclr/runtime/device/rocm/rockernel.cpp
@@ -581,8 +581,7 @@ void HSAILKernel::initArguments(const aclArgData* aclArg) {
params.push_back(desc);
}
- device::Kernel::parameters_t hiddenParams;
- createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_0);
+ createSignature(params, params.size(), amd::KernelSignature::ABIVersion_0);
}
#endif // defined(WITH_COMPILER_LIB)
@@ -661,8 +660,7 @@ void LightningKernel::initArguments(const KernelMD& kernelMD) {
params.push_back(desc);
}
- device::Kernel::parameters_t hiddenParams;
- createSignature(params, hiddenParams, amd::KernelSignature::ABIVersion_0);
+ createSignature(params, params.size(), amd::KernelSignature::ABIVersion_0);
}
#endif // defined(WITH_LIGHTNING_COMPILER)
diff --git a/rocclr/runtime/platform/kernel.cpp b/rocclr/runtime/platform/kernel.cpp
index a272a176e0..845266efc6 100644
--- a/rocclr/runtime/platform/kernel.cpp
+++ b/rocclr/runtime/platform/kernel.cpp
@@ -244,11 +244,11 @@ void KernelParameters::release(address mem, const amd::Device& device) const {
KernelSignature::KernelSignature(const std::vector& params,
const std::string& attrib,
- const std::vector& hiddenParams,
- uint32_t version)
+ uint32_t numParameters,
+ uint32_t version)
: params_(params)
- , hiddenParams_(hiddenParams)
, attributes_(attrib)
+ , numParameters_(numParameters)
, paramsSize_(0)
, numMemories_(0)
, numSamplers_(0)
@@ -298,15 +298,5 @@ KernelSignature::KernelSignature(const std::vector& p
// 16 bytes is the current HW alignment for the arguments
paramsSize_ = alignUp(paramsSize_, 16);
}
-
- if (hiddenParams.size() > 0) {
- uint32_t lastArg = hiddenParams.size() - 1;
- // Check if it's LC path and the hidden arguments are placed at the end
- if (hiddenParams[lastArg].offset_ >= paramsSize_) {
- paramsSize_ = hiddenParams[lastArg].offset_ + hiddenParams[lastArg].size_;
- // 16 bytes is the current HW alignment for the arguments
- paramsSize_ = alignUp(paramsSize_, 16);
- }
- }
}
} // namespace amd