06056e3adc
SWDEV-94640 - [OCL-LC-ROCm] OpenCL Runtime Library Implements OpenCL runtime API. Add HSA virtual device to ORCA. - Rename hsa_foundation to ROCm Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#133 edit ... //depot/stg/opencl/drivers/opencl/runtime/Makefile#22 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#196 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#275 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/build/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/build/Makefile.oclhsa#7 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaappprofile.cpp#4 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaappprofile.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsabinary.cpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsabinary.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsablit.cpp#17 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsablit.hpp#5 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompiler.cpp#6 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompilerlib.cpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompilerlib.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadefs.hpp#6 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#65 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#31 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaglinterop.cpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaglinterop.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsakernel.cpp#18 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsakernel.hpp#12 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.cpp#27 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.hpp#13 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprintf.cpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprintf.hpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprogram.cpp#28 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprogram.hpp#11 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaregisters.hpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsasettings.cpp#13 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsasettings.hpp#8 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.cpp#67 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.hpp#28 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/mesa_glinterop.h#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/wNow64a/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/mesa_glinterop.h#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdefs.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocregisters.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#1 add
196 lines
5.2 KiB
C++
196 lines
5.2 KiB
C++
//
|
|
// Copyright (c) 2009 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include "acl.h"
|
|
#include "rocprogram.hpp"
|
|
#include "top.hpp"
|
|
#include "rocprintf.hpp"
|
|
|
|
#ifndef WITHOUT_HSA_BACKEND
|
|
|
|
namespace roc {
|
|
|
|
#define MAX_INFO_STRING_LEN 0x40
|
|
enum HSAIL_ADDRESS_QUALIFIER{
|
|
HSAIL_ADDRESS_ERROR=0,
|
|
HSAIL_ADDRESS_GLOBAL,
|
|
HSAIL_ADDRESS_LOCAL,
|
|
HSAIL_MAX_ADDRESS_QUALIFIERS
|
|
} ;
|
|
|
|
enum HSAIL_ARG_TYPE{
|
|
HSAIL_ARGTYPE_ERROR=0,
|
|
HSAIL_ARGTYPE_POINTER,
|
|
HSAIL_ARGTYPE_VALUE,
|
|
HSAIL_ARGTYPE_IMAGE,
|
|
HSAIL_ARGTYPE_SAMPLER,
|
|
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
|
|
};
|
|
|
|
struct HsailKernelArg
|
|
{
|
|
std::string name_; //!< Argument's name
|
|
std::string typeName_; //!< Argument's type name
|
|
uint size_; //!< Size in bytes
|
|
uint offset_; //!< Argument's offset
|
|
uint alignment_; //!< Argument's alignment
|
|
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
|
|
uint numElem_; //!< Number of elements
|
|
HSAIL_ACCESS_TYPE access_; //!< Access type for the argument
|
|
};
|
|
|
|
class KernelArg
|
|
{
|
|
public:
|
|
KernelArg(aclArgData* argInfo);
|
|
//! Return type of the argument
|
|
clk_value_type_t amdoclType();
|
|
//! Global, local etc - returns amdocl types
|
|
clk_address_space_t amdoclAddrQual();
|
|
//! Global,localetc - returns opencl type
|
|
cl_kernel_arg_address_qualifier oclAddrQual();
|
|
//! read , write etc - returns amdocl type
|
|
clk_arg_qualifier_t amdoclAccessQual();
|
|
//! read , write etc - returns opencl type type
|
|
cl_kernel_arg_access_qualifier oclAccessQual();
|
|
//! const,volatile,restrict etc - returns opencl type type
|
|
cl_kernel_arg_type_qualifier oclTypeQual();
|
|
|
|
//! Name of the argument
|
|
std::string& name();
|
|
//! Name of the argument
|
|
std::string& typeName();
|
|
//! reflection
|
|
std::string reflection(){ return name(); };
|
|
//! Returns the size of the argument
|
|
int size();
|
|
//! returns the offset
|
|
int offset();
|
|
|
|
void setOffset();
|
|
|
|
private:
|
|
aclArgData* argInfo_;
|
|
int offset_;
|
|
std::string name_;
|
|
std::string typeName_;
|
|
};
|
|
|
|
class Kernel : public device::Kernel
|
|
{
|
|
public:
|
|
Kernel(std::string name,
|
|
HSAILProgram* prog,
|
|
const uint64_t &kernelCodeHandle,
|
|
const uint32_t workgroupGroupSegmentByteSize,
|
|
const uint32_t workitemPrivateSegmentByteSize,
|
|
const uint32_t kernargSegmentByteSize,
|
|
const uint32_t kernargSegmentAlignment,
|
|
uint extraArgsNum);
|
|
|
|
const uint64_t& KernelCodeHandle() {
|
|
return kernelCodeHandle_;
|
|
}
|
|
|
|
const uint32_t WorkgroupGroupSegmentByteSize() const {
|
|
return workgroupGroupSegmentByteSize_;
|
|
}
|
|
|
|
const uint32_t workitemPrivateSegmentByteSize() const {
|
|
return workitemPrivateSegmentByteSize_;
|
|
}
|
|
|
|
const uint64_t KernargSegmentByteSize() const {
|
|
return kernargSegmentByteSize_;
|
|
}
|
|
|
|
const uint8_t KernargSegmentAlignment() const {
|
|
return kernargSegmentAlignment_;
|
|
}
|
|
|
|
~Kernel();
|
|
|
|
//! Initializes the metadata required for this kernel
|
|
bool init();
|
|
|
|
const HSAILProgram* program() {
|
|
return static_cast<const HSAILProgram*>(program_);
|
|
}
|
|
|
|
//! Returns a pointer to the hsail argument at the specified index
|
|
HsailKernelArg* hsailArgAt(size_t index) const {
|
|
return hsailArgList_[index];
|
|
}
|
|
|
|
//! Max number of possible extra (hidden) kernel arguments
|
|
static const uint MaxExtraArgumentsNum = 6;
|
|
|
|
uint extraArgumentsNum() const { return extraArgumentsNum_; }
|
|
|
|
//! Return printf info array
|
|
const std::vector<PrintfInfo>& printfInfo() const {return printf_;}
|
|
|
|
private:
|
|
//! Populates hsailArgList_
|
|
void initArgList(const aclArgData* aclArg);
|
|
|
|
//! Initializes Hsail Argument metadata and info ;
|
|
void initHsailArgs(const aclArgData* aclArg);
|
|
|
|
//! Initializes HSAIL Printf metadata and info
|
|
void initPrintf(const aclPrintfFmt* aclPrintf);
|
|
|
|
HSAILProgram *program_; //!< The roc::HSAILProgram context
|
|
std::vector<HsailKernelArg*> hsailArgList_; //!< Vector list of HSAIL Arguments
|
|
std::string compileOptions_; //!< compile used for finalizing this kernel
|
|
uint64_t kernelCodeHandle_; //!< Kernel code handle (aka amd_kernel_code_t)
|
|
const uint32_t workgroupGroupSegmentByteSize_;
|
|
const uint32_t workitemPrivateSegmentByteSize_;
|
|
const uint32_t kernargSegmentByteSize_;
|
|
const uint32_t kernargSegmentAlignment_;
|
|
size_t kernelDirectiveOffset_;
|
|
const uint extraArgumentsNum_; // Number of arguments in Kernenv
|
|
std::vector<PrintfInfo> printf_;
|
|
};
|
|
|
|
} // namespace roc
|
|
|
|
#endif // WITHOUT_HSA_BACKEND
|
|
|
|
|