Files
rocm-systems/rocclr/runtime/device/rocm/rockernel.hpp
T
foreman 5ba83829e2 P4 to Git Change 1294024 by lmoriche@lmoriche_opencl_dev on 2016/07/21 12:33:32
SWDEV-94640 - Re-submit CL#1292110 after integration from fsa_foundation:
	      - [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/runtime/device/rocm/Makefile#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.rocm#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/mesa_glinterop.h#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.cpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdefs.hpp#4 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#4 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roclib.cpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roclib.h#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocregisters.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#3 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#3 add
2016-07-21 12:41:26 -04:00

196 خطوط
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