From f6d8fa548760b861ed9d9cdcb5eaa11d85cf4988 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 11 Nov 2018 23:44:16 -0600 Subject: [PATCH] specialized spawner object [ROCm/clr commit: 1e49cff87afe7749b763a517cc0e098567744f01] --- .../include/hip/hcc_detail/hip_prof_api.h | 17 ++++++++++------- .../include/hip/hcc_detail/hip_prof_str.h | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_api.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_api.h index 8589bc0ee6..dd3c3efec9 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_api.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_api.h @@ -127,21 +127,19 @@ typedef activity_sync_callback_t hip_act_callback_t; // HIP API callbacks spawner object macro #define HIP_CB_SPAWNER_OBJECT(CB_ID) \ - if (HIP_API_ID_##CB_ID < HIP_API_ID_NUMBER) { \ - hip_api_data_t api_data{}; \ - INIT_CB_ARGS_DATA(CB_ID, api_data); \ - api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); \ - } + hip_api_data_t api_data{}; \ + INIT_CB_ARGS_DATA(CB_ID, api_data); \ + api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); typedef api_callbacks_table_templ api_callbacks_table_t; extern api_callbacks_table_t callbacks_table; +template class api_callbacks_spawner_t { public: api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) : - cid_(cid), api_data_(api_data), record_({}) { @@ -174,7 +172,6 @@ class api_callbacks_spawner_t { return callbacks_table.entry(id); } - const hip_api_id_t cid_; hip_api_data_t& api_data_; hip_api_record_t record_; @@ -184,6 +181,12 @@ class api_callbacks_spawner_t { void* arg; }; +template <> +class api_callbacks_spawner_t { + public: + api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) {} +}; + #else #define HIP_CB_SPAWNER_OBJECT(x) do {} while(0) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_str.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_str.h index 40cd865c2e..512e8a3188 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_str.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_prof_str.h @@ -5,7 +5,6 @@ #include // Dummy API callbacks definition -#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAccelerator_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAcceleratorView_CB_ARGS_DATA(cb_data) {}; #define INIT_hipDeviceCanAccessPeer2_CB_ARGS_DATA(cb_data) {}; @@ -177,10 +176,10 @@ enum hip_api_id_t { HIP_API_ID_hipModuleGetFunction = 135, HIP_API_ID_hipGetDevice = 136, HIP_API_ID_hipGetDeviceCount = 137, - HIP_API_ID_NUMBER = 138, - HIP_API_ID_ANY = 139, + HIP_API_ID_hipHccModuleLaunchKernel = 138, + HIP_API_ID_NUMBER = 139, + HIP_API_ID_ANY = 140, - HIP_API_ID_hipHccModuleLaunchKernel = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAccelerator = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAcceleratorView = HIP_API_ID_NUMBER, HIP_API_ID_hipDeviceCanAccessPeer2 = HIP_API_ID_NUMBER, @@ -340,6 +339,7 @@ static const char* hip_api_name(const uint32_t& id) { case HIP_API_ID_hipCtxEnablePeerAccess: return "hipCtxEnablePeerAccess"; case HIP_API_ID_hipMemcpyDtoHAsync: return "hipMemcpyDtoHAsync"; case HIP_API_ID_hipModuleLaunchKernel: return "hipModuleLaunchKernel"; + case HIP_API_ID_hipHccModuleLaunchKernel: return "hipHccModuleLaunchKernel"; case HIP_API_ID_hipModuleGetTexRef: return "hipModuleGetTexRef"; case HIP_API_ID_hipRemoveActivityCallback: return "hipRemoveActivityCallback"; case HIP_API_ID_hipDeviceGetLimit: return "hipDeviceGetLimit"; @@ -907,6 +907,9 @@ struct hip_api_data_t { void** kernelParams; void** extra; } hipModuleLaunchKernel; + struct { + hipFunction_t f; + } hipHccModuleLaunchKernel; struct { textureReference** texRef; hipModule_t hmod; @@ -1526,6 +1529,9 @@ struct hip_api_data_t { cb_data.args.hipModuleLaunchKernel.kernelParams = (void**)kernelParams; \ cb_data.args.hipModuleLaunchKernel.extra = (void**)extra; \ }; +#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLaunchKernel.f = (hipFunction_t)f; \ +}; #define INIT_hipModuleGetTexRef_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipModuleGetTexRef.texRef = (textureReference**)texRef; \ cb_data.args.hipModuleGetTexRef.hmod = (hipModule_t)hmod; \ @@ -2396,6 +2402,11 @@ const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) { << " extra=" << data->args.hipModuleLaunchKernel.extra << ")"; break; + case HIP_API_ID_hipHccModuleLaunchKernel: + oss << "hipHccModuleLaunchKernel(" + << " f=" << data->args.hipHccModuleLaunchKernel.f << "," + << ")"; + break; case HIP_API_ID_hipModuleGetTexRef: oss << "hipModuleGetTexRef(" << " texRef=" << data->args.hipModuleGetTexRef.texRef << ","