From acd38f5eaac594670f88e5a0d1f94c601c7ca7e8 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Fri, 29 Jul 2022 14:44:01 -0700 Subject: [PATCH] SWDEV-351980 - Fix hip_prof_str.h generation Fixed an error in the CMakeLists.txt USE_PERF_API option declaration that was making it always disabled. Fixing this exposed an issue with the hip_prof_gen.py script's handling of function variants (for example, _spt functions) and new HIP_INIT_API_* macros. Also switched the python interpreter to python3 as python2 may not be available by default on the build system. Change-Id: I971fc9edcc746ca63a2bdf4f540e755f9a80fe69 [ROCm/clr commit: 8ac20e5e385856c97f2be7db82dc25e4bba151c6] --- .../include/hip/amd_detail/hip_prof_str.h | 225 +++++++----------- projects/clr/hipamd/src/CMakeLists.txt | 18 +- projects/clr/hipamd/src/hip_prof_gen.py | 6 +- 3 files changed, 102 insertions(+), 147 deletions(-) diff --git a/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h b/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h index f592a64a81..02a92e32bb 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h +++ b/projects/clr/hipamd/include/hip/amd_detail/hip_prof_str.h @@ -6,6 +6,7 @@ #ifndef _HIP_PROF_STR_H #define _HIP_PROF_STR_H #define HIP_PROF_VER 1 + // HIP API callbacks ID enumeration enum hip_api_id_t { HIP_API_ID_NONE = 0, @@ -369,41 +370,22 @@ enum hip_api_id_t { HIP_API_ID_hipCreateTextureObject = HIP_API_ID_NONE, HIP_API_ID_hipDestroyTextureObject = HIP_API_ID_NONE, HIP_API_ID_hipDeviceGetCount = HIP_API_ID_NONE, - HIP_API_ID_hipEventRecord_spt = HIP_API_ID_NONE, HIP_API_ID_hipGetTextureAlignmentOffset = HIP_API_ID_NONE, HIP_API_ID_hipGetTextureObjectResourceDesc = HIP_API_ID_NONE, HIP_API_ID_hipGetTextureObjectResourceViewDesc = HIP_API_ID_NONE, HIP_API_ID_hipGetTextureObjectTextureDesc = HIP_API_ID_NONE, HIP_API_ID_hipGetTextureReference = HIP_API_ID_NONE, - HIP_API_ID_hipLaunchCooperativeKernel_spt = HIP_API_ID_NONE, - HIP_API_ID_hipLaunchKernel_spt = HIP_API_ID_NONE, HIP_API_ID_hipMemcpy2DArrayToArray = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpy2DFromArray_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpy2DToArray_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpy2D_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpy3D_spt = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyArrayToArray = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpyAsync_spt = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyAtoA = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyAtoD = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyAtoHAsync = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyDtoA = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyFromArrayAsync = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpyFromSymbol_spt = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyHtoAAsync = HIP_API_ID_NONE, HIP_API_ID_hipMemcpyToArrayAsync = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpyToSymbol_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemcpy_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemset2D_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemset3D_spt = HIP_API_ID_NONE, - HIP_API_ID_hipMemset_spt = HIP_API_ID_NONE, HIP_API_ID_hipModuleLaunchKernelExt = HIP_API_ID_NONE, HIP_API_ID_hipSetValidDevices = HIP_API_ID_NONE, - HIP_API_ID_hipStreamGetFlags_spt = HIP_API_ID_NONE, - HIP_API_ID_hipStreamGetPriority_spt = HIP_API_ID_NONE, - HIP_API_ID_hipStreamQuery_spt = HIP_API_ID_NONE, - HIP_API_ID_hipStreamSynchronize_spt = HIP_API_ID_NONE, - HIP_API_ID_hipStreamWaitEvent_spt = HIP_API_ID_NONE, HIP_API_ID_hipTexObjectCreate = HIP_API_ID_NONE, HIP_API_ID_hipTexObjectDestroy = HIP_API_ID_NONE, HIP_API_ID_hipTexObjectGetResourceDesc = HIP_API_ID_NONE, @@ -581,7 +563,9 @@ static inline const char* hip_api_name(const uint32_t id) { case HIP_API_ID_hipGraphNodeGetDependencies: return "hipGraphNodeGetDependencies"; case HIP_API_ID_hipGraphNodeGetDependentNodes: return "hipGraphNodeGetDependentNodes"; case HIP_API_ID_hipGraphNodeGetType: return "hipGraphNodeGetType"; + case HIP_API_ID_hipGraphReleaseUserObject: return "hipGraphReleaseUserObject"; case HIP_API_ID_hipGraphRemoveDependencies: return "hipGraphRemoveDependencies"; + case HIP_API_ID_hipGraphRetainUserObject: return "hipGraphRetainUserObject"; case HIP_API_ID_hipGraphUpload: return "hipGraphUpload"; case HIP_API_ID_hipGraphicsGLRegisterBuffer: return "hipGraphicsGLRegisterBuffer"; case HIP_API_ID_hipGraphicsGLRegisterImage: return "hipGraphicsGLRegisterImage"; @@ -763,12 +747,10 @@ static inline const char* hip_api_name(const uint32_t id) { case HIP_API_ID_hipTexRefSetMipmapLevelClamp: return "hipTexRefSetMipmapLevelClamp"; case HIP_API_ID_hipTexRefSetMipmappedArray: return "hipTexRefSetMipmappedArray"; case HIP_API_ID_hipThreadExchangeStreamCaptureMode: return "hipThreadExchangeStreamCaptureMode"; - case HIP_API_ID_hipWaitExternalSemaphoresAsync: return "hipWaitExternalSemaphoresAsync"; case HIP_API_ID_hipUserObjectCreate: return "hipUserObjectCreate"; case HIP_API_ID_hipUserObjectRelease: return "hipUserObjectRelease"; case HIP_API_ID_hipUserObjectRetain: return "hipUserObjectRetain"; - case HIP_API_ID_hipGraphRetainUserObject: return "hipGraphRetainUserObject"; - case HIP_API_ID_hipGraphReleaseUserObject: return "hipGraphReleaseUserObject"; + case HIP_API_ID_hipWaitExternalSemaphoresAsync: return "hipWaitExternalSemaphoresAsync"; }; return "unknown"; }; @@ -932,7 +914,9 @@ static inline uint32_t hipApiIdByName(const char* name) { if (strcmp("hipGraphNodeGetDependencies", name) == 0) return HIP_API_ID_hipGraphNodeGetDependencies; if (strcmp("hipGraphNodeGetDependentNodes", name) == 0) return HIP_API_ID_hipGraphNodeGetDependentNodes; if (strcmp("hipGraphNodeGetType", name) == 0) return HIP_API_ID_hipGraphNodeGetType; + if (strcmp("hipGraphReleaseUserObject", name) == 0) return HIP_API_ID_hipGraphReleaseUserObject; if (strcmp("hipGraphRemoveDependencies", name) == 0) return HIP_API_ID_hipGraphRemoveDependencies; + if (strcmp("hipGraphRetainUserObject", name) == 0) return HIP_API_ID_hipGraphRetainUserObject; if (strcmp("hipGraphUpload", name) == 0) return HIP_API_ID_hipGraphUpload; if (strcmp("hipGraphicsGLRegisterBuffer", name) == 0) return HIP_API_ID_hipGraphicsGLRegisterBuffer; if (strcmp("hipGraphicsGLRegisterImage", name) == 0) return HIP_API_ID_hipGraphicsGLRegisterImage; @@ -1114,12 +1098,10 @@ static inline uint32_t hipApiIdByName(const char* name) { if (strcmp("hipTexRefSetMipmapLevelClamp", name) == 0) return HIP_API_ID_hipTexRefSetMipmapLevelClamp; if (strcmp("hipTexRefSetMipmappedArray", name) == 0) return HIP_API_ID_hipTexRefSetMipmappedArray; if (strcmp("hipThreadExchangeStreamCaptureMode", name) == 0) return HIP_API_ID_hipThreadExchangeStreamCaptureMode; - if (strcmp("hipWaitExternalSemaphoresAsync", name) == 0) return HIP_API_ID_hipWaitExternalSemaphoresAsync; if (strcmp("hipUserObjectCreate", name) == 0) return HIP_API_ID_hipUserObjectCreate; if (strcmp("hipUserObjectRelease", name) == 0) return HIP_API_ID_hipUserObjectRelease; if (strcmp("hipUserObjectRetain", name) == 0) return HIP_API_ID_hipUserObjectRetain; - if (strcmp("hipGraphRetainUserObject", name) == 0) return HIP_API_ID_hipGraphRetainUserObject; - if (strcmp("hipGraphReleaseUserObject", name) == 0) return HIP_API_ID_hipGraphReleaseUserObject; + if (strcmp("hipWaitExternalSemaphoresAsync", name) == 0) return HIP_API_ID_hipWaitExternalSemaphoresAsync; return HIP_API_ID_NONE; } @@ -1977,6 +1959,11 @@ typedef struct hip_api_data_s { hipGraphNodeType* pType; hipGraphNodeType pType__val; } hipGraphNodeGetType; + struct { + hipGraph_t graph; + hipUserObject_t object; + unsigned int count; + } hipGraphReleaseUserObject; struct { hipGraph_t graph; const hipGraphNode_t* from; @@ -1985,6 +1972,12 @@ typedef struct hip_api_data_s { hipGraphNode_t to__val; size_t numDependencies; } hipGraphRemoveDependencies; + struct { + hipGraph_t graph; + hipUserObject_t object; + unsigned int count; + unsigned int flags; + } hipGraphRetainUserObject; struct { hipGraphExec_t graphExec; hipStream_t stream; @@ -3106,17 +3099,9 @@ typedef struct hip_api_data_s { hipStreamCaptureMode* mode; hipStreamCaptureMode mode__val; } hipThreadExchangeStreamCaptureMode; - struct { - const hipExternalSemaphore_t* extSemArray; - hipExternalSemaphore_t extSemArray__val; - const hipExternalSemaphoreWaitParams* paramsArray; - hipExternalSemaphoreWaitParams paramsArray__val; - unsigned int numExtSems; - hipStream_t stream; - } hipWaitExternalSemaphoresAsync; struct { hipUserObject_t* object_out; - hipUserObject_t object_out__val; + hipUserObject_t object_out__val; void* ptr; hipHostFn_t destroy; unsigned int initialRefcount; @@ -3130,18 +3115,14 @@ typedef struct hip_api_data_s { hipUserObject_t object; unsigned int count; } hipUserObjectRetain; - struct { - hipGraph_t graph; - hipUserObject_t object; - unsigned int count; - unsigned int flags; - } hipGraphRetainUserObject; - struct { - hipGraph_t graph; - hipUserObject_t object; - unsigned int count; - } hipGraphReleaseUserObject; + const hipExternalSemaphore_t* extSemArray; + hipExternalSemaphore_t extSemArray__val; + const hipExternalSemaphoreWaitParams* paramsArray; + hipExternalSemaphoreWaitParams paramsArray__val; + unsigned int numExtSems; + hipStream_t stream; + } hipWaitExternalSemaphoresAsync; } args; } hip_api_data_t; @@ -4018,6 +3999,12 @@ typedef struct hip_api_data_s { cb_data.args.hipGraphNodeGetType.node = (hipGraphNode_t)node; \ cb_data.args.hipGraphNodeGetType.pType = (hipGraphNodeType*)pType; \ }; +// hipGraphReleaseUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count')] +#define INIT_hipGraphReleaseUserObject_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipGraphReleaseUserObject.graph = (hipGraph_t)graph; \ + cb_data.args.hipGraphReleaseUserObject.object = (hipUserObject_t)object; \ + cb_data.args.hipGraphReleaseUserObject.count = (unsigned int)count; \ +}; // hipGraphRemoveDependencies[('hipGraph_t', 'graph'), ('const hipGraphNode_t*', 'from'), ('const hipGraphNode_t*', 'to'), ('size_t', 'numDependencies')] #define INIT_hipGraphRemoveDependencies_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipGraphRemoveDependencies.graph = (hipGraph_t)graph; \ @@ -4025,6 +4012,13 @@ typedef struct hip_api_data_s { cb_data.args.hipGraphRemoveDependencies.to = (const hipGraphNode_t*)to; \ cb_data.args.hipGraphRemoveDependencies.numDependencies = (size_t)numDependencies; \ }; +// hipGraphRetainUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count'), ('unsigned int', 'flags')] +#define INIT_hipGraphRetainUserObject_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipGraphRetainUserObject.graph = (hipGraph_t)graph; \ + cb_data.args.hipGraphRetainUserObject.object = (hipUserObject_t)object; \ + cb_data.args.hipGraphRetainUserObject.count = (unsigned int)count; \ + cb_data.args.hipGraphRetainUserObject.flags = (unsigned int)flags; \ +}; // hipGraphUpload[('hipGraphExec_t', 'graphExec'), ('hipStream_t', 'stream')] #define INIT_hipGraphUpload_CB_ARGS_DATA(cb_data) { \ }; @@ -5169,13 +5163,6 @@ typedef struct hip_api_data_s { #define INIT_hipThreadExchangeStreamCaptureMode_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipThreadExchangeStreamCaptureMode.mode = (hipStreamCaptureMode*)mode; \ }; -// hipWaitExternalSemaphoresAsync[('const hipExternalSemaphore_t*', 'extSemArray'), ('const hipExternalSemaphoreWaitParams*', 'paramsArray'), ('unsigned int', 'numExtSems'), ('hipStream_t', 'stream')] -#define INIT_hipWaitExternalSemaphoresAsync_CB_ARGS_DATA(cb_data) { \ - cb_data.args.hipWaitExternalSemaphoresAsync.extSemArray = (const hipExternalSemaphore_t*)extSemArray; \ - cb_data.args.hipWaitExternalSemaphoresAsync.paramsArray = (const hipExternalSemaphoreWaitParams*)paramsArray; \ - cb_data.args.hipWaitExternalSemaphoresAsync.numExtSems = (unsigned int)numExtSems; \ - cb_data.args.hipWaitExternalSemaphoresAsync.stream = (hipStream_t)stream; \ -}; // hipUserObjectCreate[('hipUserObject_t*', 'object_out'), ('void*', 'ptr'), ('hipHostFn_t', 'destroy'), ('unsigned int', 'initialRefcount'), ('unsigned int', 'flags')] #define INIT_hipUserObjectCreate_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipUserObjectCreate.object_out = (hipUserObject_t*)object_out; \ @@ -5194,18 +5181,12 @@ typedef struct hip_api_data_s { cb_data.args.hipUserObjectRetain.object = (hipUserObject_t)object; \ cb_data.args.hipUserObjectRetain.count = (unsigned int)count; \ }; -// hipGraphRetainUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count'), ('unsigned int', 'flags')] -#define INIT_hipGraphRetainUserObject_CB_ARGS_DATA(cb_data) { \ - cb_data.args.hipGraphRetainUserObject.graph = (hipGraph_t)graph; \ - cb_data.args.hipGraphRetainUserObject.object = (hipUserObject_t)object; \ - cb_data.args.hipGraphRetainUserObject.count = (unsigned int)count; \ - cb_data.args.hipGraphRetainUserObject.flags = (unsigned int)flags; \ -}; -// hipGraphReleaseUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count')] -#define INIT_hipGraphReleaseUserObject_CB_ARGS_DATA(cb_data) { \ - cb_data.args.hipGraphReleaseUserObject.graph = (hipGraph_t)graph; \ - cb_data.args.hipGraphReleaseUserObject.object = (hipUserObject_t)object; \ - cb_data.args.hipGraphReleaseUserObject.count = (unsigned int)count; \ +// hipWaitExternalSemaphoresAsync[('const hipExternalSemaphore_t*', 'extSemArray'), ('const hipExternalSemaphoreWaitParams*', 'paramsArray'), ('unsigned int', 'numExtSems'), ('hipStream_t', 'stream')] +#define INIT_hipWaitExternalSemaphoresAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipWaitExternalSemaphoresAsync.extSemArray = (const hipExternalSemaphore_t*)extSemArray; \ + cb_data.args.hipWaitExternalSemaphoresAsync.paramsArray = (const hipExternalSemaphoreWaitParams*)paramsArray; \ + cb_data.args.hipWaitExternalSemaphoresAsync.numExtSems = (unsigned int)numExtSems; \ + cb_data.args.hipWaitExternalSemaphoresAsync.stream = (hipStream_t)stream; \ }; #define INIT_CB_ARGS_DATA(cb_id, cb_data) INIT_##cb_id##_CB_ARGS_DATA(cb_data) @@ -5228,8 +5209,6 @@ typedef struct hip_api_data_s { #define INIT_hipDestroyTextureObject_CB_ARGS_DATA(cb_data) {}; // hipDeviceGetCount() #define INIT_hipDeviceGetCount_CB_ARGS_DATA(cb_data) {}; -// hipEventRecord_spt() -#define INIT_hipEventRecord_spt_CB_ARGS_DATA(cb_data) {}; // hipGetTextureAlignmentOffset() #define INIT_hipGetTextureAlignmentOffset_CB_ARGS_DATA(cb_data) {}; // hipGetTextureObjectResourceDesc() @@ -5240,24 +5219,10 @@ typedef struct hip_api_data_s { #define INIT_hipGetTextureObjectTextureDesc_CB_ARGS_DATA(cb_data) {}; // hipGetTextureReference() #define INIT_hipGetTextureReference_CB_ARGS_DATA(cb_data) {}; -// hipLaunchCooperativeKernel_spt() -#define INIT_hipLaunchCooperativeKernel_spt_CB_ARGS_DATA(cb_data) {}; -// hipLaunchKernel_spt() -#define INIT_hipLaunchKernel_spt_CB_ARGS_DATA(cb_data) {}; // hipMemcpy2DArrayToArray() #define INIT_hipMemcpy2DArrayToArray_CB_ARGS_DATA(cb_data) {}; -// hipMemcpy2DFromArray_spt() -#define INIT_hipMemcpy2DFromArray_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemcpy2DToArray_spt() -#define INIT_hipMemcpy2DToArray_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemcpy2D_spt() -#define INIT_hipMemcpy2D_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemcpy3D_spt() -#define INIT_hipMemcpy3D_spt_CB_ARGS_DATA(cb_data) {}; // hipMemcpyArrayToArray() #define INIT_hipMemcpyArrayToArray_CB_ARGS_DATA(cb_data) {}; -// hipMemcpyAsync_spt() -#define INIT_hipMemcpyAsync_spt_CB_ARGS_DATA(cb_data) {}; // hipMemcpyAtoA() #define INIT_hipMemcpyAtoA_CB_ARGS_DATA(cb_data) {}; // hipMemcpyAtoD() @@ -5268,36 +5233,14 @@ typedef struct hip_api_data_s { #define INIT_hipMemcpyDtoA_CB_ARGS_DATA(cb_data) {}; // hipMemcpyFromArrayAsync() #define INIT_hipMemcpyFromArrayAsync_CB_ARGS_DATA(cb_data) {}; -// hipMemcpyFromSymbol_spt() -#define INIT_hipMemcpyFromSymbol_spt_CB_ARGS_DATA(cb_data) {}; // hipMemcpyHtoAAsync() #define INIT_hipMemcpyHtoAAsync_CB_ARGS_DATA(cb_data) {}; // hipMemcpyToArrayAsync() #define INIT_hipMemcpyToArrayAsync_CB_ARGS_DATA(cb_data) {}; -// hipMemcpyToSymbol_spt() -#define INIT_hipMemcpyToSymbol_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemcpy_spt() -#define INIT_hipMemcpy_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemset2D_spt() -#define INIT_hipMemset2D_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemset3D_spt() -#define INIT_hipMemset3D_spt_CB_ARGS_DATA(cb_data) {}; -// hipMemset_spt() -#define INIT_hipMemset_spt_CB_ARGS_DATA(cb_data) {}; // hipModuleLaunchKernelExt() #define INIT_hipModuleLaunchKernelExt_CB_ARGS_DATA(cb_data) {}; // hipSetValidDevices() #define INIT_hipSetValidDevices_CB_ARGS_DATA(cb_data) {}; -// hipStreamGetFlags_spt() -#define INIT_hipStreamGetFlags_spt_CB_ARGS_DATA(cb_data) {}; -// hipStreamGetPriority_spt() -#define INIT_hipStreamGetPriority_spt_CB_ARGS_DATA(cb_data) {}; -// hipStreamQuery_spt() -#define INIT_hipStreamQuery_spt_CB_ARGS_DATA(cb_data) {}; -// hipStreamSynchronize_spt() -#define INIT_hipStreamSynchronize_spt_CB_ARGS_DATA(cb_data) {}; -// hipStreamWaitEvent_spt() -#define INIT_hipStreamWaitEvent_spt_CB_ARGS_DATA(cb_data) {}; // hipTexObjectCreate() #define INIT_hipTexObjectCreate_CB_ARGS_DATA(cb_data) {}; // hipTexObjectDestroy() @@ -5948,11 +5891,17 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) { case HIP_API_ID_hipGraphNodeGetType: if (data->args.hipGraphNodeGetType.pType) data->args.hipGraphNodeGetType.pType__val = *(data->args.hipGraphNodeGetType.pType); break; +// hipGraphReleaseUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count')] + case HIP_API_ID_hipGraphReleaseUserObject: + break; // hipGraphRemoveDependencies[('hipGraph_t', 'graph'), ('const hipGraphNode_t*', 'from'), ('const hipGraphNode_t*', 'to'), ('size_t', 'numDependencies')] case HIP_API_ID_hipGraphRemoveDependencies: if (data->args.hipGraphRemoveDependencies.from) data->args.hipGraphRemoveDependencies.from__val = *(data->args.hipGraphRemoveDependencies.from); if (data->args.hipGraphRemoveDependencies.to) data->args.hipGraphRemoveDependencies.to__val = *(data->args.hipGraphRemoveDependencies.to); break; +// hipGraphRetainUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count'), ('unsigned int', 'flags')] + case HIP_API_ID_hipGraphRetainUserObject: + break; // hipGraphUpload[('hipGraphExec_t', 'graphExec'), ('hipStream_t', 'stream')] case HIP_API_ID_hipGraphUpload: break; @@ -6653,27 +6602,21 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) { case HIP_API_ID_hipThreadExchangeStreamCaptureMode: if (data->args.hipThreadExchangeStreamCaptureMode.mode) data->args.hipThreadExchangeStreamCaptureMode.mode__val = *(data->args.hipThreadExchangeStreamCaptureMode.mode); break; +// hipUserObjectCreate[('hipUserObject_t*', 'object_out'), ('void*', 'ptr'), ('hipHostFn_t', 'destroy'), ('unsigned int', 'initialRefcount'), ('unsigned int', 'flags')] + case HIP_API_ID_hipUserObjectCreate: + if (data->args.hipUserObjectCreate.object_out) data->args.hipUserObjectCreate.object_out__val = *(data->args.hipUserObjectCreate.object_out); + break; +// hipUserObjectRelease[('hipUserObject_t', 'object'), ('unsigned int', 'count')] + case HIP_API_ID_hipUserObjectRelease: + break; +// hipUserObjectRetain[('hipUserObject_t', 'object'), ('unsigned int', 'count')] + case HIP_API_ID_hipUserObjectRetain: + break; // hipWaitExternalSemaphoresAsync[('const hipExternalSemaphore_t*', 'extSemArray'), ('const hipExternalSemaphoreWaitParams*', 'paramsArray'), ('unsigned int', 'numExtSems'), ('hipStream_t', 'stream')] case HIP_API_ID_hipWaitExternalSemaphoresAsync: if (data->args.hipWaitExternalSemaphoresAsync.extSemArray) data->args.hipWaitExternalSemaphoresAsync.extSemArray__val = *(data->args.hipWaitExternalSemaphoresAsync.extSemArray); if (data->args.hipWaitExternalSemaphoresAsync.paramsArray) data->args.hipWaitExternalSemaphoresAsync.paramsArray__val = *(data->args.hipWaitExternalSemaphoresAsync.paramsArray); break; -// hipUserObjectCreate[('hipUserObject_t*', 'object_out'), ('void*', 'ptr')] - case HIP_API_ID_hipUserObjectCreate: - if (data->args.hipUserObjectCreate.object_out) data->args.hipUserObjectCreate.object_out__val = *(data->args.hipUserObjectCreate.object_out); - break; -// hipUserObjectRelease[('hipUserObject_t', 'object')] - case HIP_API_ID_hipUserObjectRelease: - break; -// hipUserObjectRetain[('hipUserObject_t', 'object')] - case HIP_API_ID_hipUserObjectRetain: - break; -// hipGraphRetainUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count'), ('unsigned int', 'flags')] - case HIP_API_ID_hipGraphRetainUserObject: - break; -// hipGraphReleaseUserObject[('hipGraph_t', 'graph'), ('hipUserObject_t', 'object'), ('unsigned int', 'count')] - case HIP_API_ID_hipGraphReleaseUserObject: - break; default: break; }; } @@ -7855,6 +7798,13 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da else oss << ", pType=" << data->args.hipGraphNodeGetType.pType__val; oss << ")"; break; + case HIP_API_ID_hipGraphReleaseUserObject: + oss << "hipGraphReleaseUserObject("; + oss << "graph=" << data->args.hipGraphReleaseUserObject.graph; + oss << ", object=" << data->args.hipGraphReleaseUserObject.object; + oss << ", count=" << data->args.hipGraphReleaseUserObject.count; + oss << ")"; + break; case HIP_API_ID_hipGraphRemoveDependencies: oss << "hipGraphRemoveDependencies("; oss << "graph=" << data->args.hipGraphRemoveDependencies.graph; @@ -7865,6 +7815,14 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da oss << ", numDependencies=" << data->args.hipGraphRemoveDependencies.numDependencies; oss << ")"; break; + case HIP_API_ID_hipGraphRetainUserObject: + oss << "hipGraphRetainUserObject("; + oss << "graph=" << data->args.hipGraphRetainUserObject.graph; + oss << ", object=" << data->args.hipGraphRetainUserObject.object; + oss << ", count=" << data->args.hipGraphRetainUserObject.count; + oss << ", flags=" << data->args.hipGraphRetainUserObject.flags; + oss << ")"; + break; case HIP_API_ID_hipGraphUpload: oss << "hipGraphUpload("; oss << "graphExec=" << data->args.hipGraphUpload.graphExec; @@ -9354,16 +9312,6 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da else oss << "mode=" << data->args.hipThreadExchangeStreamCaptureMode.mode__val; oss << ")"; break; - case HIP_API_ID_hipWaitExternalSemaphoresAsync: - oss << "hipWaitExternalSemaphoresAsync("; - if (data->args.hipWaitExternalSemaphoresAsync.extSemArray == NULL) oss << "extSemArray=NULL"; - else oss << "extSemArray=" << data->args.hipWaitExternalSemaphoresAsync.extSemArray__val; - if (data->args.hipWaitExternalSemaphoresAsync.paramsArray == NULL) oss << ", paramsArray=NULL"; - else oss << ", paramsArray=" << data->args.hipWaitExternalSemaphoresAsync.paramsArray__val; - oss << ", numExtSems=" << data->args.hipWaitExternalSemaphoresAsync.numExtSems; - oss << ", stream=" << data->args.hipWaitExternalSemaphoresAsync.stream; - oss << ")"; - break; case HIP_API_ID_hipUserObjectCreate: oss << "hipUserObjectCreate("; if (data->args.hipUserObjectCreate.object_out == NULL) oss << "object_out=NULL"; @@ -9386,19 +9334,14 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da oss << ", count=" << data->args.hipUserObjectRetain.count; oss << ")"; break; - case HIP_API_ID_hipGraphRetainUserObject: - oss << "hipGraphRetainUserObject("; - oss << "graph=" << data->args.hipGraphRetainUserObject.graph; - oss << ", object=" << data->args.hipGraphRetainUserObject.object; - oss << ", count=" << data->args.hipGraphRetainUserObject.count; - oss << ", flags=" << data->args.hipGraphRetainUserObject.flags; - oss << ")"; - break; - case HIP_API_ID_hipGraphReleaseUserObject: - oss << "hipGraphReleaseUserObject("; - oss << "graph=" << data->args.hipGraphReleaseUserObject.graph; - oss << ", object=" << data->args.hipGraphReleaseUserObject.object; - oss << ", count=" << data->args.hipGraphReleaseUserObject.count; + case HIP_API_ID_hipWaitExternalSemaphoresAsync: + oss << "hipWaitExternalSemaphoresAsync("; + if (data->args.hipWaitExternalSemaphoresAsync.extSemArray == NULL) oss << "extSemArray=NULL"; + else oss << "extSemArray=" << data->args.hipWaitExternalSemaphoresAsync.extSemArray__val; + if (data->args.hipWaitExternalSemaphoresAsync.paramsArray == NULL) oss << ", paramsArray=NULL"; + else oss << ", paramsArray=" << data->args.hipWaitExternalSemaphoresAsync.paramsArray__val; + oss << ", numExtSems=" << data->args.hipWaitExternalSemaphoresAsync.numExtSems; + oss << ", stream=" << data->args.hipWaitExternalSemaphoresAsync.stream; oss << ")"; break; default: oss << "unknown"; diff --git a/projects/clr/hipamd/src/CMakeLists.txt b/projects/clr/hipamd/src/CMakeLists.txt index 83866d83f0..cc1733b626 100644 --- a/projects/clr/hipamd/src/CMakeLists.txt +++ b/projects/clr/hipamd/src/CMakeLists.txt @@ -210,7 +210,7 @@ endif() # Profiling API support ############################# # Generate profiling API macros/structures header -option(USE_PROF_API ON "Enable roctracer integration") +option(USE_PROF_API "Enable roctracer integration" ON) # Enable profiling API if(USE_PROF_API) set(PROF_API_STR "${PROJECT_BINARY_DIR}/include/hip/amd_detail/hip_prof_str.h") @@ -220,9 +220,21 @@ if(USE_PROF_API) set(PROF_API_GEN "${CMAKE_CURRENT_SOURCE_DIR}/hip_prof_gen.py") set(PROF_API_LOG "${PROJECT_BINARY_DIR}/hip_prof_gen.log.txt") - find_package(PythonInterp REQUIRED) + find_package(Python3 COMPONENTS Interpreter REQUIRED) + + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import CppHeaderParser" + RESULT_VARIABLE CPP_HEADER_PARSER + OUTPUT_QUIET) + + if(NOT ${CPP_HEADER_PARSER} EQUAL 0) + message(FATAL_ERROR "\ +The \"CppHeaderParser\" Python3 package is not installed. \ +Please install it using the following command: \"pip3 install CppHeaderParser\".\ +") + endif() + add_custom_command(OUTPUT ${PROF_API_STR} - COMMAND ${PYTHON_EXECUTABLE} ${PROF_API_GEN} -v -t --priv ${PROF_API_HDR} ${PROF_API_SRC} ${PROF_API_STR_IN} ${PROF_API_STR} + COMMAND ${Python3_EXECUTABLE} ${PROF_API_GEN} -v -t --priv ${PROF_API_HDR} ${PROF_API_SRC} ${PROF_API_STR_IN} ${PROF_API_STR} DEPENDS ${PROF_API_STR_IN} ${PROF_API_HDR} ${PROF_API_GEN} COMMENT "Generating profiling primitives: ${PROF_API_STR}") diff --git a/projects/clr/hipamd/src/hip_prof_gen.py b/projects/clr/hipamd/src/hip_prof_gen.py index a3071a75b0..aec10394a4 100755 --- a/projects/clr/hipamd/src/hip_prof_gen.py +++ b/projects/clr/hipamd/src/hip_prof_gen.py @@ -221,7 +221,7 @@ def parse_content(inp_file_p, api_map, out): # API definition pattern api_pattern = re.compile("^(hipError_t|const char\s*\*)\s+([^\(]+)\(([^\)]*)\)\s*{"); # API init macro pattern - init_pattern = re.compile("(^\s*HIP_INIT_API\s*)\((([^,]+)(,.*|)|)(\);|,)\s*$"); + init_pattern = re.compile("(^\s*HIP_INIT_API[^\s]*\s*)\((([^,]+)(,.*|)|)(\);|,)\s*$"); # Open input file inp = open(inp_file, 'r') @@ -323,8 +323,8 @@ def parse_content(inp_file_p, api_map, out): init_name = m.group(3) if init_name != 'NONE': # Check if init name matching API name - if init_name != api_name: - fatal("init name mismatch: '" + init_name + "' <> '" + api_name + "'") + # if init_name != api_name: + # fatal("init name mismatch: '" + init_name + "' <> '" + api_name + "'") # Registering dummy API for non public API if the name in INIT is not NONE if api_valid == 0: # If init name is not in public API map then it is private API