-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PROTON] Roctracer: convert agent id to gpu id for gpu ops (#4090)
Roctracer reports (global) agent ids for the location of async ops, e.g. kernels and copies. The profiler would be better suited with gpu indexes (zero based). Created a mapping function to apply to values stored in KernelMetric::DeviceId. Caveat: if devices are hidden using HIP_VISIBLE_DEVICES then the hip device id, e.g. via hipGetDevice()/hipSetDevice(), will not match the reported unfiltered id. Additional support in hip will be needed to map through the filtering correctly. --------- Co-authored-by: Keren Zhou <robinho364@gmail.com>
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef PROTON_DRIVER_GPU_HSA_H_ | ||
#define PROTON_DRIVER_GPU_HSA_H_ | ||
|
||
#include "Driver/Device.h" | ||
#include "hsa/hsa_ext_amd.h" | ||
|
||
namespace proton { | ||
|
||
namespace hsa { | ||
|
||
template <bool CheckSuccess> | ||
hsa_status_t agentGetInfo(hsa_agent_t agent, hsa_agent_info_t attribute, | ||
void *value); | ||
|
||
hsa_status_t iterateAgents(hsa_status_t (*callback)(hsa_agent_t agent, | ||
void *data), | ||
void *data); | ||
|
||
} // namespace hsa | ||
|
||
} // namespace proton | ||
|
||
#endif // PROTON_DRIVER_GPU_HSA_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "Driver/GPU/HsaApi.h" | ||
#include "Driver/Dispatch.h" | ||
|
||
namespace proton { | ||
|
||
namespace hsa { | ||
|
||
struct ExternLibHsa : public ExternLibBase { | ||
using RetType = hsa_status_t; | ||
static constexpr const char *name = "libhsa-runtime64.so"; | ||
static constexpr RetType success = HSA_STATUS_SUCCESS; | ||
static void *lib; | ||
}; | ||
|
||
void *ExternLibHsa::lib = nullptr; | ||
|
||
DEFINE_DISPATCH(ExternLibHsa, agentGetInfo, hsa_agent_get_info, hsa_agent_t, | ||
hsa_agent_info_t, void *); | ||
|
||
hsa_status_t iterateAgents(hsa_status_t (*callback)(hsa_agent_t agent, | ||
void *data), | ||
void *data) { | ||
typedef hsa_status_t (*hsa_iterate_agents_t)( | ||
hsa_status_t (*)(hsa_agent_t, void *), void *data); | ||
static hsa_iterate_agents_t func = nullptr; | ||
Dispatch<ExternLibHsa>::init(ExternLibHsa::name, &ExternLibHsa::lib); | ||
if (func == nullptr) | ||
func = reinterpret_cast<hsa_iterate_agents_t>( | ||
dlsym(ExternLibHsa::lib, "hsa_iterate_agents")); | ||
return (func ? func(callback, data) : HSA_STATUS_ERROR_FATAL); | ||
} | ||
|
||
} // namespace hsa | ||
|
||
} // namespace proton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters