HIP: Heterogenous-computing Interface for Portability
What is HIP logging for?

HIP provides a logging mechanism, which is a convinient way of printing important information so as to trace HIP API and runtime codes during the execution of HIP application. It assists HIP development team in the development of HIP runtime, and is useful for HIP application developers as well. Depending on the setting of logging level and logging mask, HIP logging will print different kinds of information, for different types of functionalities such as HIP APIs, executed kernels, queue commands and queue contents, etc.

HIP Logging Level:

By Default, HIP logging is disabled, it can be enabled via environment setting,

The value of the setting controls different logging level,

1 enum LogLevel {
2 LOG_NONE = 0,
3 LOG_ERROR = 1,
4 LOG_WARNING = 2,
5 LOG_INFO = 3,
6 LOG_DEBUG = 4
7 };

HIP Logging Mask:

Logging mask is designed to print types of functionalities during the execution of HIP application. It can be set as one of the following values,

1 enum LogMask {
2  LOG_API = 0x00000001, //!< API call
3  LOG_CMD = 0x00000002, //!< Kernel and Copy Commands and Barriers
4  LOG_WAIT = 0x00000004, //!< Synchronization and waiting for commands to finish
5  LOG_AQL = 0x00000008, //!< Decode and display AQL packets
6  LOG_QUEUE = 0x00000010, //!< Queue commands and queue contents
7  LOG_SIG = 0x00000020, //!< Signal creation, allocation, pool
8  LOG_LOCK = 0x00000040, //!< Locks and thread-safety code.
9  LOG_KERN = 0x00000080, //!< kernel creations and arguments, etc.
10  LOG_COPY = 0x00000100, //!< Copy debug
11  LOG_COPY2 = 0x00000200, //!< Detailed copy debug
12  LOG_RESOURCE = 0x00000400, //!< Resource allocation, performance-impacting events.
13  LOG_INIT = 0x00000800, //!< Initialization and shutdown
14  LOG_MISC = 0x00001000, //!< misc debug, not yet classified
15  LOG_AQL2 = 0x00002000, //!< Show raw bytes of AQL packet
16  LOG_CODE = 0x00004000, //!< Show code creation debug
17  LOG_CMD2 = 0x00008000, //!< More detailed command info, including barrier commands
18  LOG_LOCATION = 0x00010000, //!< Log message location
19  LOG_ALWAYS = 0xFFFFFFFF, //!< Log always even mask flag is zero
20 };

Once AMD_LOG_LEVEL is set, logging mask is set as default with the value 0x7FFFFFFF. However, for different pupose of logging functionalities, logging mask can be defined as well via environment variable,

HIP Logging command:

To pring HIP logging information, the function is defined as

1 #define ClPrint(level, mask, format, ...)
2  do {
3  if (AMD_LOG_LEVEL >= level) {
4  if (AMD_LOG_MASK & mask || mask == amd::LOG_ALWAYS) {
5  if (AMD_LOG_MASK & amd::LOG_LOCATION) {
6  amd::log_printf(level, __FILENAME__, __LINE__, format, ##__VA_ARGS__);
7  } else {
8  amd::log_printf(level, "", 0, format, ##__VA_ARGS__);
9  }
10  }
11  }
12  } while (false)

So in HIP code, call ClPrint() function with proper input varibles as needed, for example,

1 ClPrint(amd::LOG_INFO, amd::LOG_INIT, "Initializing HSA stack.");

HIP Logging Example:

Below is an example to enable HIP logging and get logging information during execution of hipinfo,

1 user@user-test:~/hip/bin$ export AMD_LOG_LEVEL=4
2 user@user-test:~/hip/bin$ ./hipinfo
3 
4 :3:rocdevice.cpp :453 : 23647210092: Initializing HSA stack.
5 :3:comgrctx.cpp :33 : 23647639336: Loading COMGR library.
6 :3:rocdevice.cpp :203 : 23647687108: Numa select cpu agent[0]=0x13407c0(fine=0x13409a0,coarse=0x1340ad0) for gpu agent=0x1346150
7 :4:runtime.cpp :82 : 23647698669: init
8 :3:hip_device_runtime.cpp :473 : 23647698869: 5617 : [7fad295dd840] hipGetDeviceCount: Returned hipSuccess
9 :3:hip_device_runtime.cpp :502 : 23647698990: 5617 : [7fad295dd840] hipSetDevice ( 0 )
10 :3:hip_device_runtime.cpp :507 : 23647699042: 5617 : [7fad295dd840] hipSetDevice: Returned hipSuccess
11 --------------------------------------------------------------------------------
12 device# 0
13 :3:hip_device.cpp :150 : 23647699276: 5617 : [7fad295dd840] hipGetDeviceProperties ( 0x7ffdbe7db730, 0 )
14 :3:hip_device.cpp :237 : 23647699335: 5617 : [7fad295dd840] hipGetDeviceProperties: Returned hipSuccess
15 Name: Device 7341
16 pciBusID: 3
17 pciDeviceID: 0
18 pciDomainID: 0
19 multiProcessorCount: 11
20 maxThreadsPerMultiProcessor: 2560
21 isMultiGpuBoard: 0
22 clockRate: 1900 Mhz
23 memoryClockRate: 875 Mhz
24 memoryBusWidth: 0
25 clockInstructionRate: 1000 Mhz
26 totalGlobalMem: 7.98 GB
27 maxSharedMemoryPerMultiProcessor: 64.00 KB
28 totalConstMem: 8573157376
29 sharedMemPerBlock: 64.00 KB
30 canMapHostMemory: 1
31 regsPerBlock: 0
32 warpSize: 32
33 l2CacheSize: 0
34 computeMode: 0
35 maxThreadsPerBlock: 1024
36 maxThreadsDim.x: 1024
37 maxThreadsDim.y: 1024
38 maxThreadsDim.z: 1024
39 maxGridSize.x: 2147483647
40 maxGridSize.y: 2147483647
41 maxGridSize.z: 2147483647
42 major: 10
43 minor: 12
44 concurrentKernels: 1
45 cooperativeLaunch: 0
46 cooperativeMultiDeviceLaunch: 0
47 arch.hasGlobalInt32Atomics: 1
48 arch.hasGlobalFloatAtomicExch: 1
49 arch.hasSharedInt32Atomics: 1
50 arch.hasSharedFloatAtomicExch: 1
51 arch.hasFloatAtomicAdd: 1
52 arch.hasGlobalInt64Atomics: 1
53 arch.hasSharedInt64Atomics: 1
54 arch.hasDoubles: 1
55 arch.hasWarpVote: 1
56 arch.hasWarpBallot: 1
57 arch.hasWarpShuffle: 1
58 arch.hasFunnelShift: 0
59 arch.hasThreadFenceSystem: 1
60 arch.hasSyncThreadsExt: 0
61 arch.hasSurfaceFuncs: 0
62 arch.has3dGrid: 1
63 arch.hasDynamicParallelism: 0
64 gcnArch: 1012
65 isIntegrated: 0
66 maxTexture1D: 65536
67 maxTexture2D.width: 16384
68 maxTexture2D.height: 16384
69 maxTexture3D.width: 2048
70 maxTexture3D.height: 2048
71 maxTexture3D.depth: 2048
72 isLargeBar: 0
73 :3:hip_device_runtime.cpp :471 : 23647701557: 5617 : [7fad295dd840] hipGetDeviceCount ( 0x7ffdbe7db714 )
74 :3:hip_device_runtime.cpp :473 : 23647701608: 5617 : [7fad295dd840] hipGetDeviceCount: Returned hipSuccess
75 :3:hip_peer.cpp :76 : 23647701731: 5617 : [7fad295dd840] hipDeviceCanAccessPeer ( 0x7ffdbe7db728, 0, 0 )
76 :3:hip_peer.cpp :60 : 23647701784: 5617 : [7fad295dd840] canAccessPeer: Returned hipSuccess
77 :3:hip_peer.cpp :77 : 23647701831: 5617 : [7fad295dd840] hipDeviceCanAccessPeer: Returned hipSuccess
78 peers:
79 :3:hip_peer.cpp :76 : 23647701921: 5617 : [7fad295dd840] hipDeviceCanAccessPeer ( 0x7ffdbe7db728, 0, 0 )
80 :3:hip_peer.cpp :60 : 23647701965: 5617 : [7fad295dd840] canAccessPeer: Returned hipSuccess
81 :3:hip_peer.cpp :77 : 23647701998: 5617 : [7fad295dd840] hipDeviceCanAccessPeer: Returned hipSuccess
82 non-peers: device#0
83 
84 :3:hip_memory.cpp :345 : 23647702191: 5617 : [7fad295dd840] hipMemGetInfo ( 0x7ffdbe7db718, 0x7ffdbe7db720 )
85 :3:hip_memory.cpp :360 : 23647702243: 5617 : [7fad295dd840] hipMemGetInfo: Returned hipSuccess
86 memInfo.total: 7.98 GB
87 memInfo.free: 7.98 GB (100%)

HIP Logging Tips:

1 user@user-test:~/hip/bin$ ./hipinfo > ~/hip_log.txt