From 86b18a66efe0276e9aecd2d159483ee7fcca2fa3 Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Fri, 17 Aug 2018 11:33:11 -0400 Subject: [PATCH] Add HIP_DB=fatbin for debugging fat binary issues [ROCm/hip commit: 1299b65e15935b48f3a46eb429ce2d902bf8c976] --- projects/hip/src/hip_clang.cpp | 2 ++ projects/hip/src/hip_hcc.cpp | 2 +- projects/hip/src/hip_hcc_internal.h | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_clang.cpp b/projects/hip/src/hip_clang.cpp index f7573e2819..15a96d298a 100644 --- a/projects/hip/src/hip_clang.cpp +++ b/projects/hip/src/hip_clang.cpp @@ -58,6 +58,7 @@ __hipRegisterFatBinary(const void* data) { HIP_INIT(); + tprintf(DB_FB, "Enter __hipRegisterFatBinary(%p)\n", data); const __CudaFatBinaryWrapper* fbwrapper = reinterpret_cast(data); if (fbwrapper->magic != __hipFatMAGIC2 || fbwrapper->version != 1) { return nullptr; @@ -113,6 +114,7 @@ __hipRegisterFatBinary(const void* data) } } + tprintf(DB_FB, "__hipRegisterFatBinary succeeds and returns %p\n", modules); return modules; } diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index aecf75b717..eff93da847 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1228,7 +1228,7 @@ void HipReadEnv() { READ_ENV_C(release, HIP_DB, 0, "Print debug info. Bitmask (HIP_DB=0xff) or flags separated by '+' " - "(HIP_DB=api+sync+mem+copy)", + "(HIP_DB=api+sync+mem+copy+fatbin)", HIP_DB_callback); if ((HIP_DB & (1 << DB_API)) && (HIP_TRACE_API == 0)) { // Set HIP_TRACE_API default before we read it, so it is printed correctly. diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h index be257aff4f..d64a4a4cbe 100644 --- a/projects/hip/src/hip_hcc_internal.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -223,7 +223,8 @@ extern const char* API_COLOR_END; #define DB_MEM 2 /* 0x04 - trace memory allocation / deallocation */ #define DB_COPY 3 /* 0x08 - trace memory copy and peer commands. . */ #define DB_WARN 4 /* 0x10 - warn about sub-optimal or shady behavior */ -#define DB_MAX_FLAG 5 +#define DB_FB 5 /* 0x20 - trace loading fat binary */ +#define DB_MAX_FLAG 6 // When adding a new debug flag, also add to the char name table below. // // @@ -237,6 +238,7 @@ struct DbName { static const DbName dbName[] = { {KGRN, "api"}, // not used, {KYEL, "sync"}, {KCYN, "mem"}, {KMAG, "copy"}, {KRED, "warn"}, + {KBLU, "fatbin"}, };