SWDEV-198415 - Implement Target ID Proposal
Changes from Jatin Chaudhary, Tony Tye
Change-Id: I14904920ad2356ae2098cf827b83613089d33962
[ROCm/hip commit: c4beefe00b]
This commit is contained in:
@@ -1,8 +1,31 @@
|
||||
/*
|
||||
Copyright (c) 2015-2020 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HIP_CODE_OBJECT_HPP
|
||||
#define HIP_CODE_OBJECT_HPP
|
||||
|
||||
#include "hip_global.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "hip/hip_runtime.h"
|
||||
@@ -18,28 +41,13 @@ namespace hip {
|
||||
|
||||
//Code Object base class
|
||||
class CodeObject {
|
||||
public:
|
||||
public:
|
||||
virtual ~CodeObject() {}
|
||||
|
||||
//ClangOFFLOADBundle info
|
||||
#define CLANG_OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
|
||||
#define HIP_AMDGCN_AMDHSA_TRIPLE "hip-amdgcn-amd-amdhsa"
|
||||
#define HCC_AMDGCN_AMDHSA_TRIPLE "hcc-amdgcn-amd-amdhsa-"
|
||||
|
||||
//Clang Offload bundler description & Header
|
||||
struct __ClangOffloadBundleDesc {
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
uint64_t tripleSize;
|
||||
const char triple[1];
|
||||
};
|
||||
|
||||
struct __ClangOffloadBundleHeader {
|
||||
const char magic[sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC_STR) - 1];
|
||||
uint64_t numBundles;
|
||||
__ClangOffloadBundleDesc desc[1];
|
||||
};
|
||||
|
||||
// Functions to add_dev_prog and build
|
||||
static hipError_t add_program(int deviceId, hipModule_t hmod, const void* binary_ptr,
|
||||
size_t binary_size);
|
||||
static hipError_t build_module(hipModule_t hmod, const std::vector<amd::Device*>& devices);
|
||||
|
||||
// Given an file desc and file size, extracts to code object for corresponding devices,
|
||||
// return code_objs{binary_ptr, binary_size}, which could be used to determine foffset
|
||||
@@ -57,15 +65,14 @@ public:
|
||||
static uint64_t ElfSize(const void* emi);
|
||||
|
||||
protected:
|
||||
//Given an ptr to image or file, extracts to code object
|
||||
//for corresponding devices
|
||||
static hipError_t extractCodeObjectFromFatBinary(const void*,
|
||||
const std::vector<const char*>&,
|
||||
std::vector<std::pair<const void*, size_t>>&);
|
||||
|
||||
CodeObject() {}
|
||||
private:
|
||||
static bool isCompatibleCodeObject(const std::string& codeobj_target_id,
|
||||
const char* device_name);
|
||||
|
||||
friend const std::vector<hipModule_t>& modules();
|
||||
};
|
||||
|
||||
@@ -137,6 +144,6 @@ private:
|
||||
std::unordered_map<const void*, Var*> vars_;
|
||||
};
|
||||
|
||||
}; //namespace: hip
|
||||
}; // namespace hip
|
||||
|
||||
#endif /* HIP_CODE_OBJECT_HPP */
|
||||
|
||||
Verwijs in nieuw issue
Block a user