Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libkineto/src/DeviceProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <hip/hip_runtime.h>
#endif

#if defined(HAS_XPUPTI)
#include "plugin/xpupti/XpuptiActivityProfiler.h"
#endif

#include "Logger.h"

namespace KINETO_NAMESPACE {
Expand Down Expand Up @@ -126,6 +130,11 @@ int smCount(uint32_t deviceId) {
const std::vector<gpuDeviceProp>& props = deviceProps();
return deviceId >= props.size() ? 0 : props[deviceId].multiProcessorCount;
}
#elif defined(HAS_XPUPTI)
const std::string& devicePropertiesJson() {
static std::string devicePropsJson = getXpuDeviceProperties();
return devicePropsJson;
}
#else
const std::string& devicePropertiesJson() {
static std::string devicePropsJson;
Expand Down
44 changes: 44 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/

#include "XpuptiActivityProfiler.h"
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <sycl/sycl.hpp>
#include "XpuptiActivityApi.h"

#include <chrono>
Expand Down Expand Up @@ -69,6 +72,47 @@ void XpuptiActivityProfilerSession::toggleCollectionDynamic(const bool enable) {
}
}

std::string getXpuDeviceProperties() {
std::vector<std::string> jsonProps;
// Enumerated GPU devices from the specific platform
for (const auto& platform : sycl::platform::get_platforms()) {
if (platform.get_backend() != sycl::backend::ext_oneapi_level_zero) {
continue;
}
const auto& device_list = platform.get_devices();
for (size_t i = 0; i < device_list.size(); i++) {
const auto& device = device_list[i];
jsonProps.push_back(
fmt::format(
R"JSON(
{{
"id": {},
"name": "{}",
"totalGlobalMem": {},
"maxComputeUnits": {},
"maxWorkGroupSize": {},
"maxClockFrequency": {},
"maxMemAllocSize": {},
"localMemSize": {},
"vendor": "{}",
"driverVersion": "{}"
}})JSON",
i,
device.get_info<sycl::info::device::name>(),
device.get_info<sycl::info::device::global_mem_size>(),
device.get_info<sycl::info::device::max_compute_units>(),
device.get_info<sycl::info::device::max_work_group_size>(),
device.get_info<sycl::info::device::max_clock_frequency>(),
device.get_info<sycl::info::device::max_mem_alloc_size>(),
device.get_info<sycl::info::device::local_mem_size>(),
device.get_info<sycl::info::device::vendor>(),
device.get_info<sycl::info::device::driver_version>()));
}
}

return fmt::format("{}", fmt::join(jsonProps, ","));
}

void XpuptiActivityProfilerSession::processTrace(ActivityLogger& logger) {
traceBuffer_.span = libkineto::TraceSpan(
profilerStartTs_, profilerEndTs_, "__xpu_profiler__");
Expand Down
2 changes: 2 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace KINETO_NAMESPACE {

std::string getXpuDeviceProperties();

class XpuptiActivityProfilerSession
: public libkineto::IActivityProfilerSession {
public:
Expand Down