2016-01-22 18:18:55 -05:00
|
|
|
//
|
|
|
|
|
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
|
|
|
|
|
//
|
2016-04-15 15:48:36 -04:00
|
|
|
#pragma once
|
2016-01-22 18:18:55 -05:00
|
|
|
|
|
|
|
|
#include "device/device.hpp"
|
|
|
|
|
#include "utils/macros.hpp"
|
|
|
|
|
#include "platform/command.hpp"
|
|
|
|
|
#include "platform/program.hpp"
|
|
|
|
|
#include "platform/kernel.hpp"
|
|
|
|
|
#include "platform/sampler.hpp"
|
|
|
|
|
#include "device/pal/paldevice.hpp"
|
|
|
|
|
#include "device/pal/palvirtual.hpp"
|
|
|
|
|
#include "amd_hsa_kernel_code.h"
|
|
|
|
|
#include "device/pal/palprintf.hpp"
|
2018-08-29 18:54:19 -04:00
|
|
|
#include "device/devwavelimiter.hpp"
|
2016-01-22 18:18:55 -05:00
|
|
|
#include "hsa.h"
|
|
|
|
|
|
|
|
|
|
namespace amd {
|
|
|
|
|
namespace hsa {
|
|
|
|
|
namespace loader {
|
|
|
|
|
class Symbol;
|
2017-04-13 13:56:38 -04:00
|
|
|
} // loader
|
2016-10-21 13:18:35 -04:00
|
|
|
namespace code {
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
class Metadata;
|
2017-04-13 13:56:38 -04:00
|
|
|
} // Kernel
|
|
|
|
|
} // code
|
|
|
|
|
} // hsa
|
|
|
|
|
} // amd
|
2016-01-22 18:18:55 -05:00
|
|
|
|
|
|
|
|
//! \namespace pal PAL Device Implementation
|
|
|
|
|
namespace pal {
|
|
|
|
|
|
|
|
|
|
class VirtualGPU;
|
|
|
|
|
class Device;
|
|
|
|
|
class NullDevice;
|
|
|
|
|
class HSAILProgram;
|
2016-10-21 13:18:35 -04:00
|
|
|
class LightningProgram;
|
2016-01-22 18:18:55 -05:00
|
|
|
|
|
|
|
|
/*! \addtogroup pal PAL Device Implementation
|
|
|
|
|
* @{
|
|
|
|
|
*/
|
2017-04-13 13:56:38 -04:00
|
|
|
class HSAILKernel : public device::Kernel {
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
HSAILKernel(std::string name, HSAILProgram* prog, std::string compileOptions);
|
|
|
|
|
|
|
|
|
|
virtual ~HSAILKernel();
|
|
|
|
|
|
|
|
|
|
//! Initializes the metadata required for this kernel,
|
|
|
|
|
//! finalizes the kernel if needed
|
|
|
|
|
bool init(amd::hsa::loader::Symbol* sym, bool finalize = false);
|
|
|
|
|
|
|
|
|
|
//! Returns GPU device object, associated with this kernel
|
|
|
|
|
const Device& dev() const;
|
|
|
|
|
|
|
|
|
|
//! Returns HSA program associated with this kernel
|
|
|
|
|
const HSAILProgram& prog() const;
|
|
|
|
|
|
|
|
|
|
//! Returns LDS size used in this kernel
|
2018-09-10 11:57:07 -04:00
|
|
|
uint32_t ldsSize() const { return akc_.workgroup_group_segment_byte_size; }
|
2017-04-13 13:56:38 -04:00
|
|
|
|
|
|
|
|
//! Returns pointer on CPU to AQL code info
|
2018-09-10 11:57:07 -04:00
|
|
|
const amd_kernel_code_t* cpuAqlCode() const { return &akc_; }
|
2017-04-13 13:56:38 -04:00
|
|
|
|
|
|
|
|
//! Returns memory object with AQL code
|
|
|
|
|
uint64_t gpuAqlCode() const { return code_; }
|
|
|
|
|
|
|
|
|
|
//! Returns size of AQL code
|
|
|
|
|
size_t aqlCodeSize() const { return codeSize_; }
|
|
|
|
|
|
|
|
|
|
//! Returns the size of argument buffer
|
2018-09-10 11:57:07 -04:00
|
|
|
size_t argsBufferSize() const { return akc_.kernarg_segment_byte_size; }
|
2017-04-13 13:56:38 -04:00
|
|
|
|
|
|
|
|
//! Returns spill reg size per workitem
|
2018-11-16 11:57:05 -05:00
|
|
|
uint32_t spillSegSize() const { return amd::alignUp(akc_.workitem_private_segment_byte_size, sizeof(uint32_t)); }
|
2017-04-13 13:56:38 -04:00
|
|
|
|
|
|
|
|
//! Returns AQL packet in CPU memory
|
|
|
|
|
//! if the kernel arguments were successfully loaded, otherwise NULL
|
|
|
|
|
hsa_kernel_dispatch_packet_t* loadArguments(
|
|
|
|
|
VirtualGPU& gpu, //!< Running GPU context
|
|
|
|
|
const amd::Kernel& kernel, //!< AMD kernel object
|
|
|
|
|
const amd::NDRangeContainer& sizes, //!< NDrange container
|
|
|
|
|
const_address parameters, //!< Application arguments for the kernel
|
2018-06-12 18:57:20 -04:00
|
|
|
size_t ldsAddress, //!< LDS address that includes all arguments.
|
2017-04-13 13:56:38 -04:00
|
|
|
uint64_t vmDefQueue, //!< GPU VM default queue pointer
|
2017-08-24 13:51:55 -04:00
|
|
|
uint64_t* vmParentWrap //!< GPU VM parent aql wrap object
|
2017-04-13 13:56:38 -04:00
|
|
|
) const;
|
|
|
|
|
|
|
|
|
|
//! Returns the kernel index in the program
|
|
|
|
|
uint index() const { return index_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
//! Disable copy constructor
|
|
|
|
|
HSAILKernel(const HSAILKernel&);
|
|
|
|
|
|
|
|
|
|
//! Disable operator=
|
|
|
|
|
HSAILKernel& operator=(const HSAILKernel&);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
//! Creates AQL kernel HW info
|
|
|
|
|
bool aqlCreateHWInfo(amd::hsa::loader::Symbol* sym);
|
2016-01-22 18:18:55 -05:00
|
|
|
|
2018-09-10 11:57:07 -04:00
|
|
|
std::string compileOptions_; //!< compile used for finalizing this kernel
|
|
|
|
|
amd_kernel_code_t akc_; //!< AQL kernel code on CPU
|
|
|
|
|
const HSAILProgram& prog_; //!< Reference to the parent program
|
|
|
|
|
uint index_; //!< Kernel index in the program
|
2017-04-13 13:56:38 -04:00
|
|
|
|
2018-09-10 11:57:07 -04:00
|
|
|
uint64_t code_; //!< GPU memory pointer to the kernel
|
|
|
|
|
size_t codeSize_; //!< Size of ISA code
|
2016-01-22 18:18:55 -05:00
|
|
|
};
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
class LightningKernel : public HSAILKernel {
|
|
|
|
|
public:
|
|
|
|
|
LightningKernel(const std::string& name, HSAILProgram* prog, const std::string& compileOptions)
|
|
|
|
|
: HSAILKernel(name, prog, compileOptions) {}
|
|
|
|
|
|
|
|
|
|
//! Returns Lightning program associated with this kernel
|
|
|
|
|
const LightningProgram& prog() const;
|
|
|
|
|
|
|
|
|
|
//! Initializes the metadata required for this kernel,
|
|
|
|
|
bool init(amd::hsa::loader::Symbol* symbol);
|
2016-10-21 13:18:35 -04:00
|
|
|
};
|
|
|
|
|
|
2016-01-22 18:18:55 -05:00
|
|
|
/*@}*/} // namespace pal
|