P4 to Git Change 1598525 by gandryey@gera-ocl-lc on 2018/08/27 14:28:05
SWDEV-79445 - OCL generic changes and code clean-up - Setup KernelParameterDescriptor directly from the binary's metadata without any intermediate arguments presentation. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#50 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#312 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#60 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.hpp#19 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#122 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#66 edit
Dieser Commit ist enthalten in:
@@ -1632,17 +1632,9 @@ struct KernelParameterDescriptor {
|
||||
SamplerObject = 12,
|
||||
QueueObject = 13
|
||||
};
|
||||
const char* name_; //!< The parameter's name in the source
|
||||
clk_value_type_t type_; //!< The parameter's type
|
||||
size_t offset_; //!< Its offset in the parameter's stack
|
||||
size_t size_; //!< Its size in bytes
|
||||
//! Argument's address qualifier
|
||||
cl_kernel_arg_address_qualifier addressQualifier_;
|
||||
//! Argument's access qualifier
|
||||
cl_kernel_arg_access_qualifier accessQualifier_;
|
||||
//! Argument's type qualifier
|
||||
cl_kernel_arg_type_qualifier typeQualifier_;
|
||||
const char* typeName_; //!< Argument's type name
|
||||
union InfoData {
|
||||
struct {
|
||||
uint32_t oclObject_ : 4; //!< OCL object type
|
||||
@@ -1655,6 +1647,13 @@ struct KernelParameterDescriptor {
|
||||
uint32_t allValues_;
|
||||
InfoData() : allValues_(0) {}
|
||||
} info_;
|
||||
|
||||
cl_kernel_arg_address_qualifier addressQualifier_; //!< Argument's address qualifier
|
||||
cl_kernel_arg_access_qualifier accessQualifier_; //!< Argument's access qualifier
|
||||
cl_kernel_arg_type_qualifier typeQualifier_; //!< Argument's type qualifier
|
||||
|
||||
std::string name_; //!< The parameter's name in the source
|
||||
std::string typeName_; //!< Argument's type name
|
||||
};
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@@ -48,77 +48,8 @@ class LightningProgram;
|
||||
/*! \addtogroup pal PAL Device Implementation
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum HSAIL_ADDRESS_QUALIFIER {
|
||||
HSAIL_ADDRESS_ERROR = 0,
|
||||
HSAIL_ADDRESS_GLOBAL,
|
||||
HSAIL_ADDRESS_LOCAL,
|
||||
HSAIL_ADDRESS_CONSTANT,
|
||||
HSAIL_MAX_ADDRESS_QUALIFIERS
|
||||
};
|
||||
|
||||
enum HSAIL_ARG_TYPE {
|
||||
HSAIL_ARGTYPE_ERROR = 0,
|
||||
HSAIL_ARGTYPE_POINTER,
|
||||
HSAIL_ARGTYPE_VALUE,
|
||||
HSAIL_ARGTYPE_REFERENCE,
|
||||
HSAIL_ARGTYPE_IMAGE,
|
||||
HSAIL_ARGTYPE_SAMPLER,
|
||||
HSAIL_ARGTYPE_QUEUE,
|
||||
HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_X,
|
||||
HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_Y,
|
||||
HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_Z,
|
||||
HSAIL_ARGTYPE_HIDDEN_PRINTF_BUFFER,
|
||||
HSAIL_ARGTYPE_HIDDEN_DEFAULT_QUEUE,
|
||||
HSAIL_ARGTYPE_HIDDEN_COMPLETION_ACTION,
|
||||
HSAIL_ARGTYPE_HIDDEN_NONE,
|
||||
HSAIL_ARGMAX_ARG_TYPES
|
||||
};
|
||||
|
||||
enum HSAIL_DATA_TYPE {
|
||||
HSAIL_DATATYPE_ERROR = 0,
|
||||
HSAIL_DATATYPE_B1,
|
||||
HSAIL_DATATYPE_B8,
|
||||
HSAIL_DATATYPE_B16,
|
||||
HSAIL_DATATYPE_B32,
|
||||
HSAIL_DATATYPE_B64,
|
||||
HSAIL_DATATYPE_S8,
|
||||
HSAIL_DATATYPE_S16,
|
||||
HSAIL_DATATYPE_S32,
|
||||
HSAIL_DATATYPE_S64,
|
||||
HSAIL_DATATYPE_U8,
|
||||
HSAIL_DATATYPE_U16,
|
||||
HSAIL_DATATYPE_U32,
|
||||
HSAIL_DATATYPE_U64,
|
||||
HSAIL_DATATYPE_F16,
|
||||
HSAIL_DATATYPE_F32,
|
||||
HSAIL_DATATYPE_F64,
|
||||
HSAIL_DATATYPE_STRUCT,
|
||||
HSAIL_DATATYPE_OPAQUE,
|
||||
HSAIL_DATATYPE_MAX_TYPES
|
||||
};
|
||||
|
||||
enum HSAIL_ACCESS_TYPE {
|
||||
HSAIL_ACCESS_TYPE_NONE = 0,
|
||||
HSAIL_ACCESS_TYPE_RO,
|
||||
HSAIL_ACCESS_TYPE_WO,
|
||||
HSAIL_ACCESS_TYPE_RW
|
||||
};
|
||||
|
||||
class HSAILKernel : public device::Kernel {
|
||||
public:
|
||||
struct Argument {
|
||||
uint index_; //!< Argument's index in the OCL signature
|
||||
std::string name_; //!< Argument's name
|
||||
std::string typeName_; //!< Argument's type name
|
||||
uint size_; //!< Size in bytes
|
||||
uint alignment_; //!< Argument's alignment
|
||||
uint pointeeAlignment_; //!< Alignment of the data pointed to
|
||||
HSAIL_ARG_TYPE type_; //!< Type of the argument
|
||||
HSAIL_ADDRESS_QUALIFIER addrQual_; //!< Address qualifier of the argument
|
||||
HSAIL_DATA_TYPE dataType_; //!< The type of data
|
||||
HSAIL_ACCESS_TYPE access_; //!< Access type for the argument
|
||||
};
|
||||
|
||||
HSAILKernel(std::string name, HSAILProgram* prog, std::string compileOptions);
|
||||
|
||||
@@ -128,17 +59,6 @@ class HSAILKernel : public device::Kernel {
|
||||
//! finalizes the kernel if needed
|
||||
bool init(amd::hsa::loader::Symbol* sym, bool finalize = false);
|
||||
|
||||
//! Returns the kernel argument list
|
||||
const std::vector<Argument*>& arguments() const { return arguments_; }
|
||||
|
||||
//! Returns a pointer to the hsail argument at the specified index
|
||||
Argument* argumentAt(size_t index) const {
|
||||
for (auto arg : arguments_)
|
||||
if (arg->index_ == index) return arg;
|
||||
assert(!"Should not reach here");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//! Returns GPU device object, associated with this kernel
|
||||
const Device& dev() const;
|
||||
|
||||
@@ -217,19 +137,14 @@ class HSAILKernel : public device::Kernel {
|
||||
//! Creates AQL kernel HW info
|
||||
bool aqlCreateHWInfo(amd::hsa::loader::Symbol* sym);
|
||||
|
||||
//! Initializes arguments_ and the abstraction layer kernel parameters
|
||||
//! Initializes the abstraction layer kernel parameters
|
||||
void initArgList(const aclArgData* aclArg //!< List of ACL arguments
|
||||
);
|
||||
|
||||
//! Initializes Hsail Argument metadata and info
|
||||
void initHsailArgs(const aclArgData* aclArg //!< List of ACL arguments
|
||||
);
|
||||
|
||||
//! Initializes Hsail Printf metadata and info
|
||||
void initPrintf(const aclPrintfFmt* aclPrintf //!< List of ACL printfs
|
||||
);
|
||||
|
||||
std::vector<Argument*> arguments_; //!< Vector list of HSAIL Arguments
|
||||
std::string compileOptions_; //!< compile used for finalizing this kernel
|
||||
amd_kernel_code_t* cpuAqlCode_; //!< AQL kernel code on CPU
|
||||
const NullDevice& dev_; //!< GPU device object
|
||||
|
||||
@@ -1918,46 +1918,50 @@ void VirtualGPU::PrintChildren(const HSAILKernel& hsaKernel, VirtualGPU* gpuDefQ
|
||||
uint offsArg = kernarg_address - gpuDefQueue->virtualQueue_->vmAddress();
|
||||
address argum = gpuDefQueue->virtualQueue_->data() + offsArg;
|
||||
print << "Kernel: " << child->name() << "\n";
|
||||
for (auto arg : child->arguments()) {
|
||||
const amd::KernelSignature& signature = child->signature();
|
||||
|
||||
// Check if runtime has to setup hidden arguments
|
||||
for (const auto it : signature.parameters()) {
|
||||
const char* extraArgName = nullptr;
|
||||
switch (arg->type_) {
|
||||
case HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_X:
|
||||
switch (it.info_.oclObject_) {
|
||||
case amd::KernelParameterDescriptor::HiddenNone:
|
||||
// void* zero = 0;
|
||||
// WriteAqlArgAt(const_cast<address>(parameters), &zero, it.size_, it.offset_);
|
||||
break;
|
||||
case amd::KernelParameterDescriptor::HiddenGlobalOffsetX:
|
||||
extraArgName = "Offset0: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_Y:
|
||||
case amd::KernelParameterDescriptor::HiddenGlobalOffsetY:
|
||||
extraArgName = "Offset1: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_GLOBAL_OFFSET_Z:
|
||||
case amd::KernelParameterDescriptor::HiddenGlobalOffsetZ:
|
||||
extraArgName = "Offset2: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_PRINTF_BUFFER:
|
||||
case amd::KernelParameterDescriptor::HiddenPrintfBuffer:
|
||||
extraArgName = "PrintfBuf: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_DEFAULT_QUEUE:
|
||||
case amd::KernelParameterDescriptor::HiddenDefaultQueue:
|
||||
extraArgName = "VqueuePtr: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_COMPLETION_ACTION:
|
||||
case amd::KernelParameterDescriptor::HiddenCompletionAction:
|
||||
extraArgName = "AqlWrap: ";
|
||||
break;
|
||||
case HSAIL_ARGTYPE_HIDDEN_NONE:
|
||||
extraArgName = "Unknown: ";
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (extraArgName) {
|
||||
print << "\t" << extraArgName << *(size_t*)argum;
|
||||
print << "\n";
|
||||
argum += sizeof(size_t);
|
||||
continue;
|
||||
print << "\t" << extraArgName << *reinterpret_cast<size_t*>(argum);
|
||||
print << "\n";
|
||||
argum += sizeof(size_t);
|
||||
continue;
|
||||
}
|
||||
print << "\t" << arg->name_ << ": ";
|
||||
for (int s = arg->size_ - 1; s >= 0; --s) {
|
||||
print.width(2);
|
||||
print.fill('0');
|
||||
print << (uint32_t)(argum[s]);
|
||||
print << "\t" << it.name_ << ": ";
|
||||
for (int s = it.size_- 1; s >= 0; --s) {
|
||||
print.width(2);
|
||||
print.fill('0');
|
||||
print << static_cast<uint32_t>(argum[s]);
|
||||
}
|
||||
argum += arg->size_;
|
||||
argum += it.offset_;
|
||||
print << "\n";
|
||||
}
|
||||
printf("%s", print.str().c_str());
|
||||
@@ -3141,10 +3145,12 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
|
||||
gpuMem->wait(*this, WaitOnBusyEngine);
|
||||
|
||||
addVmMemory(gpuMem);
|
||||
void* globalAddress = *(void**)(const_cast<address>(params) + desc.offset_);
|
||||
LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index, desc.typeName_, desc.name_,
|
||||
globalAddress, (void*)gpuMem->vmAddress(),
|
||||
(void*)((intptr_t)gpuMem->vmAddress() + gpuMem->size()), std::this_thread::get_id());
|
||||
const void* globalAddress = *reinterpret_cast<const void* const*>(params + desc.offset_);
|
||||
LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index,
|
||||
desc.typeName_.c_str(), desc.name_.c_str(),
|
||||
globalAddress, reinterpret_cast<void*>(gpuMem->vmAddress()),
|
||||
reinterpret_cast<void*>(gpuMem->vmAddress() + gpuMem->size()),
|
||||
std::this_thread::get_id());
|
||||
|
||||
//! Check if compiler expects read/write.
|
||||
//! Note: SVM with subbuffers has an issue with tracking.
|
||||
|
||||
@@ -332,11 +332,13 @@ bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address para
|
||||
// Synchronize data with other memory instances if necessary
|
||||
gpuMem->syncCacheFromHost(*this);
|
||||
}
|
||||
void* globalAddress = *(void**)(const_cast<address>(params) + desc.offset_);
|
||||
LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index, desc.typeName_,
|
||||
desc.name_, globalAddress, gpuMem->getDeviceMemory(),
|
||||
(void*)((intptr_t)gpuMem->getDeviceMemory() + mem->getSize()),
|
||||
std::this_thread::get_id());
|
||||
const void* globalAddress = *reinterpret_cast<const void* const*>(params + desc.offset_);
|
||||
LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index,
|
||||
desc.typeName_.c_str(), desc.name_.c_str(),
|
||||
globalAddress, gpuMem->getDeviceMemory(),
|
||||
reinterpret_cast<address>(gpuMem->getDeviceMemory()) + mem->getSize(),
|
||||
std::this_thread::get_id());
|
||||
|
||||
// Validate memory for a dependency in the queue
|
||||
memoryDependency().validate(*this, gpuMem, (desc.info_.readOnly_ == 1));
|
||||
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren