P4 to Git Change 1303140 by lmoriche@lmoriche_opencl_dev on 2016/08/15 17:04:37
SWDEV-94610 - Code provided by Wilkin - Implement the roc Program Manager to call the Lightning Compiler instead of the compiler library. - Embed and use the pre-compiled header generated by the built-in library build - If LLVM_BIN is not set, try to find Clang from the libamdocl path Testing: http://ocltc.amd.com:8111/viewModification.html?modId=75068&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf.cpp#35 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf.hpp#24 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/blitcl.cpp#9 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#200 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#4 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmetadata.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmetadata.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#8 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#81 edit
Этот коммит содержится в:
@@ -5,6 +5,9 @@
|
||||
#include "rockernel.hpp"
|
||||
#include "SCHSAInterface.h"
|
||||
#include "amd_hsa_kernel_code.h"
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
#include "rocmetadata.hpp"
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -12,6 +15,25 @@
|
||||
|
||||
namespace roc {
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static HSAIL_ARG_TYPE
|
||||
GetHSAILArgType(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
switch (lcArg->TypeKind()) {
|
||||
case AMDGPU::RuntimeMD::KernelArg::Pointer:
|
||||
return HSAIL_ARGTYPE_POINTER;
|
||||
case AMDGPU::RuntimeMD::KernelArg::Value:
|
||||
return HSAIL_ARGTYPE_VALUE;
|
||||
case AMDGPU::RuntimeMD::KernelArg::Image:
|
||||
return HSAIL_ARGTYPE_IMAGE;
|
||||
case AMDGPU::RuntimeMD::KernelArg::Sampler:
|
||||
return HSAIL_ARGTYPE_SAMPLER;
|
||||
default:
|
||||
return HSAIL_ARGTYPE_ERROR;
|
||||
}
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static HSAIL_ARG_TYPE
|
||||
GetHSAILArgType(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -30,6 +52,17 @@ GetHSAILArgType(const aclArgData* argInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static size_t
|
||||
GetHSAILArgAlignment(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer)
|
||||
return lcArg->Align();
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static size_t
|
||||
GetHSAILArgAlignment(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -41,6 +74,25 @@ GetHSAILArgAlignment(const aclArgData* argInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static HSAIL_ACCESS_TYPE
|
||||
GetHSAILArgAccessType(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer) {
|
||||
switch (lcArg->AccQual()) {
|
||||
case AMDGPU::RuntimeMD::KernelArg::ReadOnly:
|
||||
return HSAIL_ACCESS_TYPE_RO;
|
||||
case AMDGPU::RuntimeMD::KernelArg::WriteOnly:
|
||||
return HSAIL_ACCESS_TYPE_WO;
|
||||
case AMDGPU::RuntimeMD::KernelArg::ReadWrite:
|
||||
default:
|
||||
return HSAIL_ACCESS_TYPE_RW;
|
||||
}
|
||||
}
|
||||
return HSAIL_ACCESS_TYPE_NONE;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static HSAIL_ACCESS_TYPE
|
||||
GetHSAILArgAccessType(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -58,6 +110,30 @@ GetHSAILArgAccessType(const aclArgData* argInfo)
|
||||
return HSAIL_ACCESS_TYPE_NONE;
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static HSAIL_ADDRESS_QUALIFIER
|
||||
GetHSAILAddrQual(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer) {
|
||||
switch (lcArg->AddrQual()) {
|
||||
case AMDGPUAS::GLOBAL_ADDRESS:
|
||||
case AMDGPUAS::CONSTANT_ADDRESS:
|
||||
return HSAIL_ADDRESS_GLOBAL;
|
||||
case AMDGPUAS::LOCAL_ADDRESS:
|
||||
return HSAIL_ADDRESS_LOCAL;
|
||||
default:
|
||||
LogError("Unsupported address type");
|
||||
return HSAIL_ADDRESS_ERROR;
|
||||
}
|
||||
}
|
||||
else if ((lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Image) ||
|
||||
(lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Sampler)) {
|
||||
return HSAIL_ADDRESS_GLOBAL;
|
||||
}
|
||||
return HSAIL_ADDRESS_ERROR;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static HSAIL_ADDRESS_QUALIFIER
|
||||
GetHSAILAddrQual(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -84,6 +160,50 @@ GetHSAILAddrQual(const aclArgData* argInfo)
|
||||
return HSAIL_ADDRESS_ERROR;
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
/* f16 returns f32 - workaround due to comp lib */
|
||||
inline static HSAIL_DATA_TYPE
|
||||
GetHSAILDataType(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
aclArgDataType dataType;
|
||||
|
||||
if ((lcArg->TypeKind() != AMDGPU::RuntimeMD::KernelArg::Pointer) ||
|
||||
(lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Value))
|
||||
{
|
||||
return HSAIL_DATATYPE_ERROR;
|
||||
}
|
||||
|
||||
switch (lcArg->ValueType()) {
|
||||
case AMDGPU::RuntimeMD::KernelArg::I8:
|
||||
return HSAIL_DATATYPE_S8;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I16:
|
||||
return HSAIL_DATATYPE_S16;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I32:
|
||||
return HSAIL_DATATYPE_S32;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I64:
|
||||
return HSAIL_DATATYPE_S64;
|
||||
case AMDGPU::RuntimeMD::KernelArg::U8:
|
||||
return HSAIL_DATATYPE_U8;
|
||||
case AMDGPU::RuntimeMD::KernelArg::U16:
|
||||
return HSAIL_DATATYPE_U16;
|
||||
case AMDGPU::RuntimeMD::KernelArg::U32:
|
||||
return HSAIL_DATATYPE_U32;
|
||||
case AMDGPU::RuntimeMD::KernelArg::U64:
|
||||
return HSAIL_DATATYPE_U64;
|
||||
case AMDGPU::RuntimeMD::KernelArg::F16:
|
||||
return HSAIL_DATATYPE_F32;
|
||||
case AMDGPU::RuntimeMD::KernelArg::F32:
|
||||
return HSAIL_DATATYPE_F32;
|
||||
case AMDGPU::RuntimeMD::KernelArg::F64:
|
||||
return HSAIL_DATATYPE_F64;
|
||||
case AMDGPU::RuntimeMD::KernelArg::Struct:
|
||||
return HSAIL_DATATYPE_STRUCT;
|
||||
default:
|
||||
return HSAIL_DATATYPE_ERROR;
|
||||
}
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
/* f16 returns f32 - workaround due to comp lib */
|
||||
inline static HSAIL_DATA_TYPE
|
||||
GetHSAILDataType(const aclArgData* argInfo)
|
||||
@@ -176,6 +296,79 @@ GetHSAILArgSize(const aclArgData *argInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static clk_value_type_t
|
||||
GetOclType(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
static const clk_value_type_t ClkValueMapType[6][6] = {
|
||||
{ T_CHAR, T_CHAR2, T_CHAR3, T_CHAR4, T_CHAR8, T_CHAR16 },
|
||||
{ T_SHORT, T_SHORT2, T_SHORT3, T_SHORT4, T_SHORT8, T_SHORT16 },
|
||||
{ T_INT, T_INT2, T_INT3, T_INT4, T_INT8, T_INT16 },
|
||||
{ T_LONG, T_LONG2, T_LONG3, T_LONG4, T_LONG8, T_LONG16 },
|
||||
{ T_FLOAT, T_FLOAT2, T_FLOAT3, T_FLOAT4, T_FLOAT8, T_FLOAT16 },
|
||||
{ T_DOUBLE, T_DOUBLE2, T_DOUBLE3, T_DOUBLE4, T_DOUBLE8, T_DOUBLE16 },
|
||||
};
|
||||
|
||||
uint sizeType;
|
||||
uint numElements;
|
||||
if ((lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer) ||
|
||||
(lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Image)) {
|
||||
return T_POINTER;
|
||||
}
|
||||
else if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Value) {
|
||||
switch (lcArg->ValueType()) {
|
||||
case AMDGPU::RuntimeMD::KernelArg::I8:
|
||||
case AMDGPU::RuntimeMD::KernelArg::U8:
|
||||
sizeType = 0;
|
||||
numElements = lcArg->Size();
|
||||
break;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I16:
|
||||
case AMDGPU::RuntimeMD::KernelArg::U16:
|
||||
case AMDGPU::RuntimeMD::KernelArg::F16:
|
||||
sizeType = 1;
|
||||
numElements = lcArg->Size() / 2;
|
||||
break;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I32:
|
||||
case AMDGPU::RuntimeMD::KernelArg::U32:
|
||||
sizeType = 2;
|
||||
numElements = lcArg->Size() / 4;
|
||||
break;
|
||||
case AMDGPU::RuntimeMD::KernelArg::I64:
|
||||
case AMDGPU::RuntimeMD::KernelArg::U64:
|
||||
sizeType = 3;
|
||||
numElements = lcArg->Size() / 8;
|
||||
break;
|
||||
case AMDGPU::RuntimeMD::KernelArg::F32:
|
||||
sizeType = 4;
|
||||
numElements = lcArg->Size() / 4;
|
||||
break;
|
||||
case AMDGPU::RuntimeMD::KernelArg::F64:
|
||||
sizeType = 5;
|
||||
numElements = lcArg->Size() / 8;
|
||||
break;
|
||||
default:
|
||||
return T_VOID;
|
||||
}
|
||||
|
||||
switch (numElements) {
|
||||
case 1: return ClkValueMapType[sizeType][0];
|
||||
case 2: return ClkValueMapType[sizeType][1];
|
||||
case 3: return ClkValueMapType[sizeType][2];
|
||||
case 4: return ClkValueMapType[sizeType][3];
|
||||
case 8: return ClkValueMapType[sizeType][4];
|
||||
case 16: return ClkValueMapType[sizeType][5];
|
||||
default: return T_VOID;
|
||||
}
|
||||
}
|
||||
else if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Sampler) {
|
||||
return T_SAMPLER;
|
||||
}
|
||||
else {
|
||||
return T_VOID;
|
||||
}
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static clk_value_type_t
|
||||
GetOclType(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -238,6 +431,30 @@ GetOclType(const aclArgData* argInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static cl_kernel_arg_address_qualifier
|
||||
GetOclAddrQual(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer) {
|
||||
switch (lcArg->AddrQual()) {
|
||||
case AMDGPUAS::GLOBAL_ADDRESS:
|
||||
return CL_KERNEL_ARG_ADDRESS_GLOBAL;
|
||||
case AMDGPUAS::CONSTANT_ADDRESS:
|
||||
return CL_KERNEL_ARG_ADDRESS_CONSTANT;
|
||||
case AMDGPUAS::LOCAL_ADDRESS:
|
||||
return CL_KERNEL_ARG_ADDRESS_LOCAL;
|
||||
default:
|
||||
return CL_KERNEL_ARG_ADDRESS_PRIVATE;
|
||||
}
|
||||
}
|
||||
else if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Image) {
|
||||
return CL_KERNEL_ARG_ADDRESS_GLOBAL;
|
||||
}
|
||||
//default for all other cases
|
||||
return CL_KERNEL_ARG_ADDRESS_PRIVATE;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static cl_kernel_arg_address_qualifier
|
||||
GetOclAddrQual(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -264,6 +481,26 @@ GetOclAddrQual(const aclArgData* argInfo)
|
||||
return CL_KERNEL_ARG_ADDRESS_PRIVATE;
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static cl_kernel_arg_access_qualifier
|
||||
GetOclAccessQual(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Image) {
|
||||
switch (lcArg->AccQual()) {
|
||||
case AMDGPU::RuntimeMD::KernelArg::ReadOnly:
|
||||
return CL_KERNEL_ARG_ACCESS_READ_ONLY;
|
||||
case AMDGPU::RuntimeMD::KernelArg::WriteOnly:
|
||||
return CL_KERNEL_ARG_ACCESS_WRITE_ONLY;
|
||||
case AMDGPU::RuntimeMD::KernelArg::ReadWrite:
|
||||
return CL_KERNEL_ARG_ACCESS_READ_WRITE;
|
||||
default:
|
||||
return CL_KERNEL_ARG_ACCESS_NONE;
|
||||
}
|
||||
}
|
||||
return CL_KERNEL_ARG_ACCESS_NONE;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static cl_kernel_arg_access_qualifier
|
||||
GetOclAccessQual(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -282,6 +519,26 @@ GetOclAccessQual(const aclArgData* argInfo)
|
||||
return CL_KERNEL_ARG_ACCESS_NONE;
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
inline static cl_kernel_arg_type_qualifier
|
||||
GetOclTypeQual(const RuntimeMD::KernelArg::Metadata* lcArg)
|
||||
{
|
||||
cl_kernel_arg_type_qualifier rv = CL_KERNEL_ARG_TYPE_NONE;
|
||||
if (lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Pointer) {
|
||||
if (lcArg->IsVolatile()) {
|
||||
rv |= CL_KERNEL_ARG_TYPE_VOLATILE;
|
||||
}
|
||||
if (lcArg->IsRestrict()) {
|
||||
rv |= CL_KERNEL_ARG_TYPE_RESTRICT;
|
||||
}
|
||||
if (lcArg->IsConst()) {
|
||||
rv |= CL_KERNEL_ARG_TYPE_CONST;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
inline static cl_kernel_arg_type_qualifier
|
||||
GetOclTypeQual(const aclArgData* argInfo)
|
||||
{
|
||||
@@ -446,6 +703,66 @@ Kernel::initArgList(const aclArgData* aclArg)
|
||||
createSignature(params);
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
void
|
||||
Kernel::initArgsParams( const RuntimeMD::KernelArg::Metadata* lcArg, size_t* kOffset,
|
||||
device::Kernel::parameters_t& params, size_t* pOffset )
|
||||
{
|
||||
HsailKernelArg* arg = new HsailKernelArg;
|
||||
|
||||
// Initialize HSAIL kernel argument
|
||||
arg->name_ = lcArg->Name();
|
||||
arg->typeName_ = lcArg->TypeName();
|
||||
arg->size_ = lcArg->Size(); // LC doesn't distinguish vector or single element
|
||||
arg->offset_ = *kOffset;
|
||||
arg->type_ = GetHSAILArgType(lcArg);
|
||||
arg->addrQual_ = GetHSAILAddrQual(lcArg);
|
||||
arg->dataType_ = GetHSAILDataType(lcArg);
|
||||
// If vector of args we add additional arguments to flatten it out
|
||||
arg->numElem_ = ((lcArg->TypeKind() == AMDGPU::RuntimeMD::KernelArg::Value) &&
|
||||
(lcArg->ValueType() != AMDGPU::RuntimeMD::KernelArg::Struct)) ?
|
||||
(lcArg->Size() / arg->size_) : 1;
|
||||
arg->alignment_ = GetHSAILArgAlignment(lcArg);
|
||||
arg->access_ = GetHSAILArgAccessType(lcArg);
|
||||
|
||||
hsailArgList_.push_back(arg);
|
||||
|
||||
*kOffset += lcArg->Size();
|
||||
|
||||
// Initialize Device kernel parameters
|
||||
amd::KernelParameterDescriptor desc;
|
||||
|
||||
desc.name_ = lcArg->Name().c_str();
|
||||
desc.type_ = GetOclType(lcArg);
|
||||
desc.addressQualifier_ = GetOclAddrQual(lcArg);
|
||||
desc.accessQualifier_ = GetOclAccessQual(lcArg);
|
||||
desc.typeQualifier_ = GetOclTypeQual(lcArg);
|
||||
desc.typeName_ = lcArg->TypeName().c_str();
|
||||
|
||||
// Make a check if it is local or global
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
desc.size_ = 0;
|
||||
}
|
||||
else {
|
||||
desc.size_ = lcArg->Size();
|
||||
}
|
||||
|
||||
// Make offset alignment to match CPU metadata, since
|
||||
// in multidevice config abstraction layer has a single signature
|
||||
// and CPU sends the paramaters as they are allocated in memory
|
||||
size_t size = desc.size_;
|
||||
if (size == 0) {
|
||||
// Local memory for CPU
|
||||
size = sizeof(cl_mem);
|
||||
}
|
||||
*pOffset = (size_t) amd::alignUp(*pOffset, std::min(size, size_t(16)));
|
||||
desc.offset_ = *pOffset;
|
||||
*pOffset += amd::alignUp(size, sizeof(uint32_t));
|
||||
|
||||
params.push_back(desc);
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
void
|
||||
Kernel::initHsailArgs(const aclArgData* aclArg)
|
||||
{
|
||||
@@ -492,9 +809,80 @@ Kernel::Kernel(std::string name, HSAILProgram* prog,
|
||||
kernargSegmentAlignment_(kernargSegmentAlignment),
|
||||
extraArgumentsNum_(extraArgsNum) {}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
bool Kernel::init_LC(){
|
||||
hsa_agent_t hsaDevice = program_->hsaDevice();
|
||||
|
||||
// Pull out metadata from the ELF
|
||||
const CodeObjBinary* codeObj = program_->codeObjBinary();
|
||||
const RuntimeMD::Program::Metadata* runtimeMD = codeObj->GetProgramMetadata();
|
||||
|
||||
if (!runtimeMD) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t idx = runtimeMD->KernelIndexByName(name());
|
||||
const RuntimeMD::Kernel::Metadata* kernelMD = runtimeMD->GetKernelMetadata(idx);
|
||||
|
||||
size_t sizeOfArgList = kernelMD->KernelArgCount();
|
||||
|
||||
size_t kOffset = 0;
|
||||
size_t pOffset = 0;
|
||||
device::Kernel::parameters_t params;
|
||||
for (uint32_t i=0; i < sizeOfArgList; i++) {
|
||||
const RuntimeMD::KernelArg::Metadata* kernelArg = kernelMD->GetKernelArgMetadata(i);
|
||||
initArgsParams(kernelArg, &kOffset, params, &pOffset);
|
||||
}
|
||||
createSignature(params);
|
||||
|
||||
//Set the workgroup information for the kernel
|
||||
memset(&workGroupInfo_, 0, sizeof(workGroupInfo_));
|
||||
workGroupInfo_.availableLDSSize_ = program_->dev().info().localMemSizePerCU_;
|
||||
assert(workGroupInfo_.availableLDSSize_ > 0);
|
||||
workGroupInfo_.availableSGPRs_ = 0;
|
||||
workGroupInfo_.availableVGPRs_ = 0;
|
||||
|
||||
const uint32_t* workGroupSizeHint = kernelMD->WorkgroupSizeHint();
|
||||
size_t sizeOfWorkGroupSize = (workGroupSizeHint) ? *workGroupSizeHint : 0;
|
||||
|
||||
uint32_t wavefront_size = 0;
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_agent_get_info(
|
||||
program_->hsaDevice(), HSA_AGENT_INFO_WAVEFRONT_SIZE,
|
||||
&wavefront_size)) {
|
||||
return false;
|
||||
}
|
||||
assert(wavefront_size > 0);
|
||||
|
||||
// Setting it the same as used LDS.
|
||||
workGroupInfo_.localMemSize_ = workgroupGroupSegmentByteSize_;
|
||||
workGroupInfo_.privateMemSize_ = workitemPrivateSegmentByteSize_;
|
||||
workGroupInfo_.usedLDSSize_ = workgroupGroupSegmentByteSize_;
|
||||
workGroupInfo_.preferredSizeMultiple_ = wavefront_size;
|
||||
workGroupInfo_.usedSGPRs_ = 0;
|
||||
workGroupInfo_.usedStackSize_ = 0;
|
||||
workGroupInfo_.usedVGPRs_ = 0;
|
||||
workGroupInfo_.wavefrontPerSIMD_ =
|
||||
program_->dev().info().maxWorkItemSizes_[0] / wavefront_size;
|
||||
workGroupInfo_.wavefrontSize_ = wavefront_size;
|
||||
if (workGroupInfo_.compileSize_[0] != 0) {
|
||||
workGroupInfo_.size_ =
|
||||
workGroupInfo_.compileSize_[0] *
|
||||
workGroupInfo_.compileSize_[1] *
|
||||
workGroupInfo_.compileSize_[2];
|
||||
}
|
||||
else {
|
||||
workGroupInfo_.size_ = program_->dev().info().maxWorkGroupSize_;
|
||||
}
|
||||
|
||||
//TODO: WC - handle printf
|
||||
return true;
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
bool Kernel::init(){
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
assert(!"FIXME_Wilkin");
|
||||
return init_LC();
|
||||
#else // !defined(WITH_LIGHTNING_COMPILER)
|
||||
acl_error errorCode;
|
||||
//compile kernel down to ISA
|
||||
@@ -604,8 +992,8 @@ bool Kernel::init(){
|
||||
// Set the Printf List
|
||||
initPrintf(reinterpret_cast<aclPrintfFmt*>(aclPrintfList.get()));
|
||||
}
|
||||
#endif // !defined(WITH_LIGHTNING_COMPILER)
|
||||
return true;
|
||||
#endif // !defined(WITH_LIGHTNING_COMPILER)
|
||||
}
|
||||
|
||||
void Kernel::initPrintf(const aclPrintfFmt* aclPrintf) {
|
||||
|
||||
Ссылка в новой задаче
Block a user