71 #include <include/hpctoolkit-config.h> 85 #define CUDA_FATBIN_SECTION ".nvFatBinSegment" 86 #define CUDA_FATBIN_DATASECTION ".nv_fatbin" 88 #define CUDA_FATBIN_MAGIC 0x466243b1 89 #define CUDA_FATBIN_VERSION 1 100 const unsigned long long*
data;
121 #ifdef DYNINST_USE_CUDA 128 GElf_Ehdr *obj_ehdr = gelf_getehdr(elf, &ehdr_v);
131 return (obj_ehdr && (obj_ehdr->e_machine == EM_CUDA));
146 bool isFatbin = strcmp(elf_strptr(elf, ehdr->e_shstrndx, shdr->sh_name),
153 if (elfFile->
open((
char *) fatbin->
data, (
size_t) shdr->sh_size, empty)) {
178 std::string filename = loadModule->
getFileName() +
"@" +
184 if (elfFile->
open(sectionData, shdr->sh_size, filename)) {
188 if (isCubin(elfFile->
getElf())) {
189 elfFileVector->push_back(elfFile);
215 #ifdef DYNINST_USE_CUDA 217 GElf_Ehdr *ehdr = gelf_getehdr(elf, &ehdr_v);
220 for (
auto si = sections->begin(); si != sections->end(); si++) {
223 GElf_Shdr *shdr = gelf_getshdr(scn, &shdr_v);
226 if (recordIfNvFatbin(obj_ptr, elf, ehdr, scn, shdr)) {
228 }
else if (recordIfCubin(elfFile, obj_ptr, elf, ehdr, scn,
229 shdr, elfFileVector)) {
251 bool success =
false;
252 Elf *elf = elfFile->
getElf();
258 sections, elfFileVector);
276 std::string filename = elfFile->
getFileName() + suffix;
277 FILE *f = fopen(filename.c_str(),
"w");
283 #ifdef DYNINST_USE_CUDA 289 for(
unsigned int i = 0; i < elfFileVector->size(); i++) {
290 ElfFile *elfFile = (*elfFileVector)[i];
291 if (isCubin(elfFile->
getElf())) {
void writeElfFile(ElfFile *elfFile, const char *suffix)
string toStr(const int x, int base)
#define CUDA_FATBIN_DATASECTION
static bool findCubinSections(ElfFile *elfFile, char *obj_ptr, Elf *elf, ElfSectionVector *sections, ElfFileVector *elfFileVector)
bool open(char *_memPtr, size_t _memLen, std::string _fileName)
std::string getFileName()
struct NvidiaFatBinHeader_s NvidiaFatBinHeader_t
std::vector< NvidiaFatBinHeader_t * > FatbinSectionVector
bool findCubins(ElfFile *elfFile, ElfFileVector *elfFileVector)
ElfSectionVector * elfGetSectionVector(Elf *elf)
static FatbinSectionVector fatbinSectionVector
size_t MONITOR_EXT_WRAP_NAME() fwrite(const void *ptr, size_t size, size_t count, FILE *stream)
char * elfSectionGetData(char *obj_ptr, GElf_Shdr *shdr)