b607f5194c
ECR #333753 - Compiler Lib/ORCA RT: JIT refactoring Purpose: Make JIT work with different LLVMs - LLVM 3.6 pre-merge task. Synopsis: After splitting of Compiler Lib, JIT appeared to be apart from Compiler Lib's infrastructure and without any wrapping, hence working only with statically linked LLVM from amdocl library (HSAIL), which is unacceptable in the light of 2 LLVMs after upcoming LLVM 3.6 merge. CPU should work on LLVM 3.2. Finally JIT folder is totally removed from the Compiler Lib sources and make system as unneeded laterally from the Compiler Libs infrastructure solution. Testing: pre check-in, smoke, ocl_conformance 1.2 CPU (selectively) Reviewers: Stanislav Mekhanoshin, Brian Sumner, Jan Sjodin, Artem Tamazov, Daniil Fukalov Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#109 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/Makefile#33 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#29 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclLoaders.cpp#12 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/Disassembler.cpp#1 move/add ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/Disassembler.h#1 move/add ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/build/Makefile.common#29 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/codegen.cpp#61 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/codegen.hpp#3 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#66 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.h#3 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/cpu/x86_be.cpp#29 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/build/Makefile.complib#80 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/acl.h#9 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclFunctors.h#5 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclStructs.h#16 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclTypes.h#6 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/include/jit.h#3 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/Disassembler.cpp#4 move/delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/Disassembler.h#2 move/delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/build/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/build/Makefile.src#5 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/jit.cpp#15 delete ... //depot/stg/opencl/drivers/opencl/compiler/lib/jit/src/jit.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/compiler/llvm/linux/include/llvm/Config/config.h#27 edit ... //depot/stg/opencl/drivers/opencl/compiler/llvm32/linux/include/llvm/Config/config.h#2 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpubinary.cpp#10 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpuprogram.cpp#64 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpuprogram.hpp#12 edit ... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/CLAssumptionCheck.cpp#41 edit
120 рядки
3.3 KiB
C++
120 рядки
3.3 KiB
C++
//
|
|
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
|
|
#ifndef CPUPROGRAM_HPP_
|
|
#define CPUPROGRAM_HPP_
|
|
|
|
#include "top.hpp"
|
|
#include "device/device.hpp"
|
|
#include "device/cpu/cpubinary.hpp"
|
|
#include <string>
|
|
|
|
// forward declaration
|
|
namespace amd {
|
|
namespace option {
|
|
class Options;
|
|
} // option
|
|
} // amd
|
|
|
|
//! \namespace cpu CPU Device Implementation
|
|
namespace cpu {
|
|
|
|
//! \class CPU program
|
|
class Program : public device::Program
|
|
{
|
|
private:
|
|
aclJITObjectImage JITBinary;
|
|
std::string sourceFileName_; //!< The source image.
|
|
void* handle_; // @todo: remove me
|
|
|
|
public:
|
|
//! Default constructor
|
|
Program(Device& cpuDev)
|
|
: device::Program(cpuDev), JITBinary(NULL), handle_(NULL) {}
|
|
|
|
//! Default destructor
|
|
~Program();
|
|
|
|
//! pre-compile setup for CPU
|
|
virtual bool initBuild(amd::option::Options* options);
|
|
|
|
//! post-compile setup for CPU
|
|
virtual bool finiBuild(bool isBuildGood);
|
|
|
|
//! Compiles CPU program
|
|
virtual bool compileImpl(
|
|
const std::string& sourceCode,
|
|
const std::vector<const std::string*>& headers,
|
|
const char** headerIncludeNames,
|
|
amd::option::Options* options );
|
|
|
|
//! Links CPU program
|
|
virtual bool linkImpl(amd::option::Options* options = NULL);
|
|
|
|
//! Links CPU programs
|
|
virtual bool linkImpl(
|
|
const std::vector<device::Program*>& inputPrograms,
|
|
amd::option::Options* options = NULL,
|
|
bool createLibrary = false);
|
|
|
|
virtual bool createBinary(amd::option::Options* options);
|
|
|
|
//! Returns the device object, associated with this program.
|
|
const Device& device() {
|
|
return static_cast<const Device&>(device::Program::device());
|
|
}
|
|
|
|
/*! \brief Invokes the LLC compiler for the LLVM binary compilation
|
|
* to x86 ASM text source code and ISA binary
|
|
*
|
|
* \return True if we successefully compiled a CPU program
|
|
*/
|
|
bool compileBinaryToISA(
|
|
amd::option::Options* options //!< options for compilation
|
|
);
|
|
|
|
//! Load the library into memory
|
|
bool loadDllCode(amd::option::Options* options, bool addElfSymbols=false);
|
|
|
|
//! Initialize binary for CPU
|
|
virtual bool initClBinary();
|
|
|
|
//! Release binary for CPU
|
|
virtual void releaseClBinary();
|
|
|
|
ClBinary* clBinary() {
|
|
return static_cast<ClBinary*>(device::Program::clBinary());
|
|
}
|
|
const ClBinary* clBinary() const {
|
|
return static_cast<const ClBinary*>(device::Program::clBinary());
|
|
}
|
|
|
|
aclJITObjectImage getJITBinary() { return this->JITBinary; }
|
|
void setJITBinary(aclJITObjectImage JITBinary) { this->JITBinary = JITBinary; }
|
|
|
|
//! Returns the pointer to the Compiler struct
|
|
//! Became public (prev. private) due to use in cpubinary for aclJIT functionality
|
|
aclCompiler* compiler() { return static_cast<const Device&>(device()).compiler(); }
|
|
|
|
private:
|
|
|
|
//! Disable default copy constructor
|
|
Program(const Program&);
|
|
|
|
//! Disable operator=
|
|
Program& operator=(const Program&);
|
|
|
|
std::string dllFileName_; //!< File name of the dll with kernels
|
|
protected:
|
|
virtual bool isElf(const char* bin) const {
|
|
return amd::isElfHeader(bin, LP64_SWITCH(ELFCLASS32, ELFCLASS64));
|
|
}
|
|
|
|
virtual const aclTargetInfo & info(const char * str = "");
|
|
};
|
|
|
|
} // namespace cpu
|
|
|
|
#endif // CPUPROGRAM_HPP_
|