diff --git a/hipamd/src/hip_hcc.cpp b/hipamd/src/hip_hcc.cpp index fd3292a6f4..7fa25334bc 100644 --- a/hipamd/src/hip_hcc.cpp +++ b/hipamd/src/hip_hcc.cpp @@ -1120,6 +1120,8 @@ void ihipInit() HIP_TRACE_API = 1; } + + READ_ENV_I(release, HIP_TRACE_API, 0, "Trace each HIP API call. Print function name and return code to stderr as program executes."); READ_ENV_S(release, HIP_TRACE_API_COLOR, 0, "Color to use for HIP_API. None/Red/Green/Yellow/Blue/Magenta/Cyan/White"); READ_ENV_I(release, HIP_ATP_MARKER, 0, "Add HIP function begin/end to ATP file generated with CodeXL"); @@ -1143,6 +1145,22 @@ void ihipInit() fprintf (stderr, "warning: env var HIP_ATP_MARKER=0x%x but COMPILE_HIP_ATP_MARKER=0. (perhaps enable COMPILE_HIP_DB in src code before compiling?)", HIP_ATP_MARKER); } + if (HIP_DB) { + fprintf (stderr, "HIP_DB=0x%x [", HIP_DB); + bool first=true; + for (int i=0; igetCtx(); if ((ctx == nullptr) || (ctx->getDevice() == nullptr)) { + tprintf (DB_COPY1, "locked_copyAsync bad ctx or device\n"); throw ihipException(hipErrorInvalidDevice); } if (kind == hipMemcpyHostToHost) { - tprintf (DB_COPY2, "Asyc: H2H with memcpy"); + tprintf (DB_COPY1, "locked_copyAsync: H2H with memcpy"); // TODO - consider if we want to perhaps use the GPU SDMA engines anyway, to avoid the host-side sync here and keep everything flowing on the GPU. /* As this is a CPU op, we need to wait until all @@ -1613,10 +1650,14 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes bool copyEngineCanSeeSrcAndDest = true; - if (kind == hipMemcpyDeviceToDevice) { + if ((kind == hipMemcpyDeviceToDevice) || + ((kind == hipMemcpyDefault) && srcTracked && dstTracked)) { copyEngineCanSeeSrcAndDest = canSeePeerMemory(ctx, ihipGetPrimaryCtx(dstPtrInfo._appId), ihipGetPrimaryCtx(srcPtrInfo._appId)); } + tprintf (DB_COPY1, "locked_copyAsync: async memcpy dstTracked=%d srcTracked=%d copyEngineCanSeeSrcAndDest=%d\n", + dstTracked, srcTracked, copyEngineCanSeeSrcAndDest); + // "tracked" really indicates if the pointer's virtual address is available in the GPU address space. // If both pointers are not tracked, we need to fall back to a sync copy. @@ -1637,6 +1678,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes } } else { + // TODO - call copy_ext directly here? locked_copySync(dst, src, sizeBytes, kind); } } diff --git a/hipamd/src/hip_hcc.h b/hipamd/src/hip_hcc.h index 4e05450b19..bb06e23c67 100644 --- a/hipamd/src/hip_hcc.h +++ b/hipamd/src/hip_hcc.h @@ -190,16 +190,23 @@ extern const char *API_COLOR_END; #define DB_COPY1 3 /* 0x08 - trace memory copy commands. . */ #define DB_SIGNAL 4 /* 0x10 - trace signal pool commands */ #define DB_COPY2 5 /* 0x20 - trace memory copy commands. Detailed. */ +#define DB_MAX_BITPOS 5 // When adding a new debug flag, also add to the char name table below. +// -static const char *dbName [] = +struct DbName { + const char *_color; + const char *_shortName; +}; + +static const DbName dbName [] = { - KNRM "hip-api", // not used, - KYEL "hip-sync", - KCYN "hip-mem", - KMAG "hip-copy1", - KRED "hip-signal", - KNRM "hip-copy2", + {KGRN, "api"}, // not used, + {KYEL, "sync"}, + {KCYN, "mem"}, + {KMAG, "copy1"}, + {KRED, "signal"}, + {KNRM, "copy2"}, }; @@ -210,7 +217,7 @@ static const char *dbName [] = char msgStr[1000];\ snprintf(msgStr, 2000, __VA_ARGS__);\ COMPUTE_TID_STR\ - fprintf (stderr, " %s%s:%s%s", dbName[trace_level], tid_ss.str().c_str(), msgStr, KNRM); \ + fprintf (stderr, " %ship-%s%s:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tid_ss.str().c_str(), msgStr, KNRM); \ }\ } #else