Files
rocm-systems/rocclr/runtime/device/rocm/rocprogram.hpp
T
foreman 06056e3adc P4 to Git Change 1293210 by gandryey@gera-rcf-lnx on 2016/07/19 17:08:07
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
2016-07-19 17:42:51 -04:00

157 строки
5.5 KiB
C++

//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#pragma once
#ifndef WITHOUT_HSA_BACKEND
#include "rocbinary.hpp"
#include "roccompilerlib.hpp"
#include "acl.h"
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include "rocdevice.hpp"
#include "HSAILItems.h"
using namespace HSAIL_ASM;
//! \namespace roc HSA Device Implementation
namespace roc {
//! \class empty program
class HSAILProgram : public device::Program
{
friend class ClBinary;
public:
//! Default constructor
HSAILProgram(roc::NullDevice& device);
//! Default destructor
~HSAILProgram();
// Initialize Binary for GPU (used only for clCreateProgramWithBinary()).
virtual bool initClBinary(char *binaryIn, size_t size);
//! Returns the aclBinary associated with the progrm
const aclBinary* binaryElf() const {
return static_cast<const aclBinary*>(binaryElf_); }
const std::string& HsailText() {
return hsailProgram_;
}
const NullDevice& dev() const { return device_; }
//! Returns the hsaBinary associated with the progrm
hsa_agent_t hsaDevice() const {
return dev().getBackendDevice();
}
protected:
//! log and append to build log an error from runtime
void hsaError(const char *msg, hsa_status_t status = HSA_STATUS_SUCCESS);
//! pre-compile setup for GPU
virtual bool initBuild(amd::option::Options* options);
//! post-compile setup for GPU
virtual bool finiBuild(bool isBuildGood);
/*! \brief Compiles GPU CL program to LLVM binary (compiler frontend)
*
* \return True if we successefully compiled a GPU program
*/
virtual bool compileImpl(
const std::string& sourceCode, //!< the program's source code
const std::vector<const std::string*>& headers,
const char** headerIncludeNames,
amd::option::Options* options //!< compile options's object
);
/*! \brief Compiles LLVM binary to HSAIL code (compiler backend: link+opt+codegen)
*
* \return The build error code
*/
int compileBinaryToHSAIL(
amd::option::Options* options //!< options for compilation
);
virtual bool linkImpl(amd::option::Options* options);
//! Link the device programs.
virtual bool linkImpl (const std::vector<Program*>& inputPrograms,
amd::option::Options* options,
bool createLibrary);
virtual bool createBinary(amd::option::Options* options);
//! Initialize Binary
virtual bool initClBinary();
//! Release the Binary
virtual void releaseClBinary();
virtual const aclTargetInfo & info(const char * str = ""){
return info_;
}
virtual bool isElf(const char* bin) const {
return amd::isElfMagic(bin);
//return false;
}
//! Returns the binary
// This should ensure that the binary is updated with all the kernels
// ClBinary& clBinary() { return binary_; }
ClBinary* clBinary() {
return static_cast<ClBinary*>(device::Program::clBinary());
}
const ClBinary* clBinary() const {
return static_cast<const ClBinary*>(device::Program::clBinary());
}
private:
/* \brief Returns the next stage to compile from, based on sections in binary,
* also returns completeStages in a vector, which contains at least ACL_TYPE_DEFAULT,
* sets needOptionsCheck to true if options check is needed to decide whether or not to recompile
*/
aclType getCompilationStagesFromBinary(std::vector<aclType>& completeStages, bool& needOptionsCheck);
/* \brief Returns the next stage to compile from, based on sections and options in binary
*/
aclType getNextCompilationStageFromBinary(amd::option::Options* options);
bool saveBinaryAndSetType(type_t type);
bool initBrigContainer();
void destroyBrigContainer();
//Initializes BRIG module
bool initBrigModule();
void destroyBrigModule();
//! Disable default copy constructor
HSAILProgram(const HSAILProgram&);
//! Disable operator=
HSAILProgram& operator=(const HSAILProgram&);
//! Returns all the options to be appended while passing to the
//compiler library
std::string hsailOptions();
std::string openCLSource_; //!< Original OpenCL source
std::string hsailProgram_; //!< HSAIL program after compilation.
std::string llvmBinary_; //!< LLVM IR binary code
//!< aclBinary and aclCompiler - for the compiler libray
aclBinary* binaryElf_; //!<Binary for the new compiler library - shreyas edit
aclBinaryOptions binOpts_; //!<Binary options to create aclBinary
roc::NullDevice& device_; //!< Device related to the program
/* Brig and Brig modules */
BrigModule_t brigModule_; //!< Brig that should be used in the HSA runtime
BrigContainer* hsaBrigContainer_; //!< Container for the BRIG;
hsa_ext_program_t hsaProgramHandle_; //!< Handle to HSA runtime program
hsa_code_object_t hsaProgramCodeObject_; //!< Handle to HSA code object
hsa_executable_t hsaExecutable_; //!< Handle to HSA executable
};
/*@}*/} // namespace roc
#endif /*WITHOUT_HSA_BACKEND*/