From 024774c58ab1dd7d62001c4e91bb3cbf948f2e3d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 8 Dec 2020 13:57:44 -0500 Subject: [PATCH] SWDEV-259683 : hipprof: adding hipApiIdByName() method Change-Id: I1ad2be76efc9fb690ed7c9c2b1091f7eb0c04a31 [ROCm/clr commit: e54f2a1af13a946fc4f519f1ef53fcc2ad4d586f] --- projects/clr/hipamd/rocclr/hip_prof_gen.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/projects/clr/hipamd/rocclr/hip_prof_gen.py b/projects/clr/hipamd/rocclr/hip_prof_gen.py index defab5f254..3e0a657f3c 100755 --- a/projects/clr/hipamd/rocclr/hip_prof_gen.py +++ b/projects/clr/hipamd/rocclr/hip_prof_gen.py @@ -413,9 +413,9 @@ def generate_prof_header(f, api_map, opts_map): f.write(' HIP_API_ID_' + name + ' = HIP_API_ID_NUMBER,\n') f.write('};\n') - # Generating the callbacks ID enumaration - f.write('\n// Return HIP API string\n') - f.write('inline const char* hip_api_name(const uint32_t id) {\n') + # Generating the method to return API name by ID + f.write('\n// Return HIP API string by given ID\n') + f.write('static inline const char* hip_api_name(const uint32_t id) {\n') f.write(' switch(id) {\n') for name in api_map.keys(): f.write(' case HIP_API_ID_' + name + ': return "' + name + '";\n') @@ -423,6 +423,16 @@ def generate_prof_header(f, api_map, opts_map): f.write(' return "unknown";\n') f.write('};\n') + # Generating the method for querying API ID by name + f.write('\n') + f.write('#include \n'); + f.write('// Return HIP API ID by given name\n') + f.write('static inline uint32_t hipApiIdByName(const char* name) {\n') + for name, args in api_map.items(): + f.write(' if (strcmp("' + name + '", name) == 0) return HIP_API_ID_' + name + ';\n') + f.write(' return HIP_API_ID_NUMBER;\n') + f.write('}\n') + # Generating the callbacks data structure f.write('\n// HIP API callbacks data structure\n') f.write( @@ -479,7 +489,7 @@ def generate_prof_header(f, api_map, opts_map): # Generating the method for the API args filling f.write('\n') f.write('// HIP API args filling method\n') - f.write('void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) {\n') + f.write('static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) {\n') f.write(' switch (id) {\n') for name, args in api_map.items(): f.write('// ' + name + str(args) + '\n') @@ -505,7 +515,7 @@ def generate_prof_header(f, api_map, opts_map): f.write('#include \n'); f.write('#include \n'); f.write('// HIP API string method, method name and parameters\n') - f.write('const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) {\n') + f.write('static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) {\n') f.write(' std::ostringstream oss;\n') f.write(' switch (id) {\n') for name, args in api_map.items():