8cc3f47661
ECR #333753 - ORCA RT/Compiler Lib: HSA Code Object/RT independent loader introducing/integration into OpenCL. Changes by Evgeniy Mankov. Purpose: Use the same Finalizer & loader for both HSA & ORCA RT. AMDIL path is not affected. Changes: 1. The whole BRIG is finalized now instead of per kernel finalization (both in gpuprogram & hsail_be). 2. HSALoader is changed in order to work with CodeObject and new HSA Loader's API <96> Context. Now it is in ORCA<92>s gpuprogram instead of Compiler Lib. 3. brig_loader.cpp is removed from compiler lib, as well as __aclHSALoader function exports from the whole stack. 4. BIF .text section now contains the whole finalized HSA CodeObject instead of separate symbols for finalized kernels. 5. ORCA RT now works directly with amd_kernel_code_t and doesn't need any SC metadata anymore. 6. aoc2 is supplemented with fake offline loader correspondingly. 7. amdocl/complib make sytem changes. 8. test_driver.pl update. ToDo: 1. Implement disassemble() & BuildLog() functions to support ISA dumping & SC error handling (Konstantin). 2. Global variables initialization by pragma reference (Konstantin). Test to verify: test_basic progvar_prog_scope_init. 3. Code Object without kernels support (Nikolay - ready). Test to verify: test_generic_address_space.exe library_function testing: windows smoke, pre check-in, ocl conformance 2.0, ocl SDK 2.9 Reviewers: Nikolay Haustov, German Andryeyev Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.def.in#13 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.map.in#15 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#116 edit ... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/amdoclcl.def.in#2 edit ... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/amdoclcl.map.in#2 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.def.in#12 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/amdoclcl.map.in#11 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#70 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/build/Makefile.gpu#32 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/hsail_be.cpp#44 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/build/Makefile.complib#85 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.cpp#9 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.h#18 edit ... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/aoc2.cpp#70 edit ... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/build/Makefile.aoc2#24 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#248 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudefs.hpp#121 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#288 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.hpp#112 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#194 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#59 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuscsi.cpp#33 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#368 edit ... //depot/stg/opencl/drivers/opencl/tests/hsa/bin/test_driver.pl#12 edit
222 خطوط
5.4 KiB
C++
222 خطوط
5.4 KiB
C++
//
|
|
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
#ifndef _CL_LIB_UTILS_0_8_H_
|
|
#define _CL_LIB_UTILS_0_8_H_
|
|
#include "v0_8/aclTypes.h"
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <iterator>
|
|
#include "library.hpp"
|
|
// Utility function to set a flag in option structure
|
|
// of the aclDevCaps.
|
|
void
|
|
setFlag(aclDevCaps *elf, compDeviceCaps option);
|
|
|
|
// Utility function to flip a flag in option structure
|
|
// of the aclDevCaps.
|
|
void
|
|
flipFlag(aclDevCaps *elf, compDeviceCaps option);
|
|
|
|
// Utility function to clear a flag in option structure
|
|
// of the aclDevCaps.
|
|
void
|
|
clearFlag(aclDevCaps *elf, compDeviceCaps option);
|
|
|
|
// Utility function to check that a flag in option structure
|
|
// of the aclDevCaps is set.
|
|
bool
|
|
checkFlag(aclDevCaps *elf, compDeviceCaps option);
|
|
|
|
// Utility function to initialize and elf device capabilities
|
|
void
|
|
initElfDeviceCaps(aclBinary *elf);
|
|
|
|
// Append the string to the aclCompiler log string.
|
|
void
|
|
appendLogToCL(aclCompiler *cl, const std::string &logStr);
|
|
|
|
const char *getDeviceName(const aclTargetInfo &target);
|
|
|
|
// Select the correct library from the target information.
|
|
amd::LibrarySelector getLibraryType(const aclTargetInfo *target);
|
|
|
|
// get family_enum from the target information.
|
|
unsigned getFamilyEnum(const aclTargetInfo *target);
|
|
|
|
// get chip_enum from the target information.
|
|
unsigned getChipEnum(const aclTargetInfo *target);
|
|
|
|
// get isa type name (compute capability) from the target information.
|
|
const std::string &getIsaTypeName(const aclTargetInfo *target);
|
|
|
|
// Create a copy of an ELF and duplicate all sections/symbols
|
|
aclBinary*
|
|
createELFCopy(aclBinary *src);
|
|
|
|
// Create a BIF2.1 elf from a BIF 2.0 elf
|
|
aclBinary*
|
|
convertBIF20ToBIF21(aclBinary *src);
|
|
|
|
// Create a BIF3.0 elf from a BIF 2.0 elf
|
|
aclBinary*
|
|
convertBIF20ToBIF30(aclBinary *src);
|
|
|
|
// Create a BIF2.0 elf from a BIF 2.1 elf
|
|
aclBinary*
|
|
convertBIF21ToBIF20(aclBinary *src);
|
|
|
|
// Create a BIF3.0 elf from a BIF 2.1 elf
|
|
aclBinary*
|
|
convertBIF21ToBIF30(aclBinary *src);
|
|
|
|
// Create a BIF2.0 elf from a BIF 3.0 elf
|
|
aclBinary*
|
|
convertBIF30ToBIF20(aclBinary *src);
|
|
|
|
// Create a BIF2.1 elf from a BIF 3.0 elf
|
|
aclBinary*
|
|
convertBIF30ToBIF21(aclBinary *src);
|
|
|
|
// get a pointer to the aclBIF irrespective of the
|
|
// binary version.
|
|
aclBIF*
|
|
aclutGetBIF(aclBinary*);
|
|
|
|
// Get a pointer to the aclOptions irrespective of
|
|
// the binary version.
|
|
aclOptions*
|
|
aclutGetOptions(aclBinary*);
|
|
|
|
// Get a pointer to the aclBinaryOptions struct
|
|
// irrespective of the binary version.
|
|
aclBinaryOptions*
|
|
aclutGetBinOpts(aclBinary*);
|
|
|
|
// Get a pointer to the target info struct
|
|
// irrespective of the binary version.
|
|
aclTargetInfo*
|
|
aclutGetTargetInfo(aclBinary*);
|
|
|
|
// Get a pointer to the device caps
|
|
// irrespective of the binary version.
|
|
aclDevCaps*
|
|
aclutGetCaps(aclBinary*);
|
|
|
|
// Copy two binary option structures irrespective
|
|
// of the binary version and uses defaults when
|
|
// things don't match up.
|
|
void
|
|
aclutCopyBinOpts(aclBinaryOptions *dst,
|
|
const aclBinaryOptions *src,
|
|
bool is64bit);
|
|
|
|
// Retrieve kernel statistics from binary
|
|
// and insert to elf as symbol
|
|
acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*);
|
|
|
|
// Returns target chip name.
|
|
std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo);
|
|
|
|
// Helper function that returns the
|
|
// allocation function from the binary.
|
|
AllocFunc
|
|
aclutAlloc(const aclBinary *bin);
|
|
|
|
// Helper function that returns the
|
|
// de-allocation function from the binary.
|
|
FreeFunc
|
|
aclutFree(const aclBinary *bin);
|
|
|
|
|
|
// Helper function that returns the
|
|
// allocation function from the compiler.
|
|
AllocFunc
|
|
aclutAlloc(const aclCompiler *bin);
|
|
|
|
// Helper function that returns the
|
|
// de-allocation function from the compiler.
|
|
FreeFunc
|
|
aclutFree(const aclCompiler *bin);
|
|
|
|
// Helper function that returns the
|
|
// allocation function from the compiler options.
|
|
AllocFunc
|
|
aclutAlloc(const aclCompilerOptions *bin);
|
|
|
|
// Helper function that returns the
|
|
// de-allocation function from the compiler options.
|
|
FreeFunc
|
|
aclutFree(const aclCompilerOptions *bin);
|
|
|
|
inline bool is64BitTarget(const aclTargetInfo& target)
|
|
{
|
|
return (target.arch_id == aclX64 ||
|
|
target.arch_id == aclAMDIL64 ||
|
|
target.arch_id == aclHSAIL64);
|
|
}
|
|
|
|
inline bool isCpuTarget(const aclTargetInfo& target)
|
|
{
|
|
return (target.arch_id == aclX64 || target.arch_id == aclX86);
|
|
}
|
|
|
|
inline bool isGpuTarget(const aclTargetInfo& target)
|
|
{
|
|
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64 ||
|
|
target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
|
}
|
|
|
|
inline bool isAMDILTarget(const aclTargetInfo& target)
|
|
{
|
|
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64);
|
|
}
|
|
|
|
inline bool isHSAILTarget(const aclTargetInfo& target)
|
|
{
|
|
return (target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
|
}
|
|
|
|
enum scId {
|
|
SC_AMDIL = 0,
|
|
SC_HSAIL = 0,
|
|
SC_LAST,
|
|
};
|
|
|
|
inline std::vector<std::string> splitSpaceSeparatedString(char *str)
|
|
{
|
|
std::string s(str);
|
|
std::stringstream ss(s);
|
|
std::istream_iterator<std::string> beg(ss), end;
|
|
std::vector<std::string> vec(beg, end);
|
|
return vec;
|
|
}
|
|
|
|
// Helper function that allocates an aligned memory.
|
|
inline void*
|
|
alignedMalloc(size_t size, size_t alignment)
|
|
{
|
|
#if defined(_WIN32)
|
|
return ::_aligned_malloc(size, alignment);
|
|
#else
|
|
void * ptr = NULL;
|
|
if (0 == ::posix_memalign(&ptr, alignment, size)) {
|
|
return ptr;
|
|
}
|
|
return NULL;
|
|
#endif
|
|
}
|
|
|
|
// Helper function that frees an aligned memory.
|
|
inline void
|
|
alignedFree(void *ptr)
|
|
{
|
|
#if defined(_WIN32)
|
|
::_aligned_free(ptr);
|
|
#else
|
|
free(ptr);
|
|
#endif
|
|
}
|
|
|
|
#endif // _CL_LIB_UTILS_0_8_H_
|