adding hipApiString (#1989)

This commit is contained in:
eshcherb
2020-04-01 01:40:33 -05:00
committad av GitHub
förälder 50ef250a3b
incheckning 8c4e8d6484
+23 -24
Visa fil
@@ -388,30 +388,29 @@ def generate_prof_header(f, api_map, opts_map):
f.write('#define INIT_CB_ARGS_DATA(cb_id, cb_data) INIT_##cb_id##_CB_ARGS_DATA(cb_data)\n') f.write('#define INIT_CB_ARGS_DATA(cb_id, cb_data) INIT_##cb_id##_CB_ARGS_DATA(cb_data)\n')
# Generating the method for the API string, name and parameters # Generating the method for the API string, name and parameters
if False: f.write('\n')
f.write('\n') f.write('#if ENABLE_HIP_API_STRING\n')
f.write('#if 0\n') f.write('#include <sstream>\n');
f.write('#include <sstream>\n'); f.write('#include <string>\n');
f.write('#include <string>\n'); f.write('// HIP API string method, method name and parameters\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('const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) {\n') f.write(' std::ostringstream oss;\n')
f.write(' std::ostringstream oss;\n') f.write(' switch (id) {\n')
f.write(' switch (id) {\n') for name, args in api_map.items():
for name, args in api_map.items(): f.write(' case HIP_API_ID_' + name + ':\n')
f.write(' case HIP_API_ID_' + name + ':\n') f.write(' oss << "' + name + '("')
f.write(' oss << "' + name + '("') for ind in range(0, len(args)):
for ind in range(0, len(args)): arg_tuple = args[ind]
arg_tuple = args[ind] arg_name = arg_tuple[1]
arg_name = arg_tuple[1] if ind != 0: f.write(' << ","')
if ind != 0: f.write(' << ","') f.write('\n << " ' + arg_name + '=" << data->args.' + name + '.' + arg_name)
f.write('\n << " ' + arg_name + '=" << data->args.' + name + '.' + arg_name) f.write('\n << ")";\n')
f.write('\n << ")";\n') f.write(' break;\n')
f.write(' break;\n') f.write(' default: oss << "unknown";\n')
f.write(' default: oss << "unknown";\n') f.write(' };\n')
f.write(' };\n') f.write(' return strdup(oss.str().c_str());\n')
f.write(' return strdup(oss.str().c_str());\n') f.write('};\n')
f.write('};\n') f.write('#endif // ENABLE_HIP_API_STRING\n')
f.write('#endif\n')
f.write('#endif // _HIP_PROF_STR_H\n'); f.write('#endif // _HIP_PROF_STR_H\n');