0eb2d36332
SWDEV-79445 - OCL generic changes and code clean-up
- Add devkerenle.cpp/hpp files for device::Kernel object
- Move generic code for the arguments setup from the device layer to the abstraction layer
- Update ROCr and PAL paths to utilize the generic logic for the arguments setup
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#226 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#313 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#328 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.hpp#130 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#61 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.hpp#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#40 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#24 edit
... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#51 edit
[ROCm/clr commit: 5cfeb120ed]
100 lines
3.4 KiB
C++
100 lines
3.4 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
|
|
|
|
class Kernel : public device::Kernel {
|
|
public:
|
|
Kernel(std::string name, Program* prog, const uint64_t& kernelCodeHandle,
|
|
const uint32_t workgroupGroupSegmentByteSize,
|
|
const uint32_t workitemPrivateSegmentByteSize, const uint32_t kernargSegmentByteSize,
|
|
const uint32_t kernargSegmentAlignment);
|
|
|
|
const uint64_t& KernelCodeHandle() { return kernelCodeHandle_; }
|
|
|
|
const uint32_t WorkgroupGroupSegmentByteSize() const { return workgroupGroupSegmentByteSize_; }
|
|
|
|
const uint32_t workitemPrivateSegmentByteSize() const { return workitemPrivateSegmentByteSize_; }
|
|
|
|
const uint32_t KernargSegmentByteSize() const { return kernargSegmentByteSize_; }
|
|
|
|
const uint8_t KernargSegmentAlignment() const { return kernargSegmentAlignment_; }
|
|
|
|
~Kernel();
|
|
|
|
//! Initializes the metadata required for this kernel
|
|
virtual bool init() = 0;
|
|
|
|
const Program* program() const { return static_cast<const Program*>(program_); }
|
|
|
|
//! Return printf info array
|
|
const std::vector<PrintfInfo>& printfInfo() const { return printf_; }
|
|
|
|
protected:
|
|
Program* program_; //!< The roc::Program context
|
|
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_;
|
|
std::vector<PrintfInfo> printf_;
|
|
};
|
|
|
|
#if defined(WITH_COMPILER_LIB)
|
|
class HSAILKernel : public roc::Kernel {
|
|
public:
|
|
HSAILKernel(std::string name, Program* prog, const uint64_t& kernelCodeHandle,
|
|
const uint32_t workgroupGroupSegmentByteSize,
|
|
const uint32_t workitemPrivateSegmentByteSize,
|
|
const uint32_t kernargSegmentByteSize,
|
|
const uint32_t kernargSegmentAlignment)
|
|
: roc::Kernel(name, prog, kernelCodeHandle, workgroupGroupSegmentByteSize,
|
|
workitemPrivateSegmentByteSize, kernargSegmentByteSize, kernargSegmentAlignment) {
|
|
}
|
|
|
|
//! Initializes the metadata required for this kernel
|
|
virtual bool init() final;
|
|
|
|
private:
|
|
//! Initializes HSAIL Printf metadata and info
|
|
void initPrintf(const aclPrintfFmt* aclPrintf);
|
|
};
|
|
#endif // defined(WITH_COMPILER_LIB)
|
|
|
|
#if defined(WITH_LIGHTNING_COMPILER)
|
|
class LightningKernel : public roc::Kernel {
|
|
public:
|
|
LightningKernel(std::string name, Program* prog, const uint64_t& kernelCodeHandle,
|
|
const uint32_t workgroupGroupSegmentByteSize,
|
|
const uint32_t workitemPrivateSegmentByteSize,
|
|
const uint32_t kernargSegmentByteSize,
|
|
const uint32_t kernargSegmentAlignment)
|
|
: roc::Kernel(name, prog, kernelCodeHandle, workgroupGroupSegmentByteSize,
|
|
workitemPrivateSegmentByteSize, kernargSegmentByteSize, kernargSegmentAlignment) {
|
|
}
|
|
//! Initializes the metadata required for this kernel
|
|
virtual bool init() final;
|
|
|
|
private:
|
|
//! Initializes HSAIL Printf metadata and info for LC
|
|
void initPrintf(const std::vector<std::string>& printfInfoStrings);
|
|
};
|
|
#endif // defined(WITH_LIGHTNING_COMPILER)
|
|
|
|
} // namespace roc
|
|
|
|
#endif // WITHOUT_HSA_BACKEND
|