Skip to content

Commit

Permalink
sysman-metrics updated
Browse files Browse the repository at this point in the history
  • Loading branch information
solo2abera committed Sep 25, 2023
1 parent 8b5c3b2 commit 9c15987
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 64 deletions.
8 changes: 4 additions & 4 deletions utils/xprof_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bt_message* create_frequency_message(const char* hostname, const process_id_t pr
}

bt_message* create_computeEU_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id,
const uintptr_t hDevice, const uint32_t subDevice, const uint64_t activeTime, const uint64_t ts,
const uintptr_t hDevice, const uint32_t subDevice, const float activeTime, const uint64_t ts,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream, backend_t backend) {

/* Message creation */
Expand Down Expand Up @@ -161,13 +161,13 @@ bt_message* create_computeEU_message(const char* hostname, const process_id_t pr

//activeTime
bt_field *activeTime_field = bt_field_structure_borrow_member_field_by_index(payload_field,2);
bt_field_integer_unsigned_set_value(activeTime_field, activeTime);
bt_field_real_single_precision_set_value(activeTime_field, activeTime);

return message;
}

bt_message* create_copyEU_message(const char* hostname, const process_id_t process_id, const thread_id_t thread_id,
const uintptr_t hDevice, const uint32_t subDevice, const uint64_t activeTime, const uint64_t ts,
const uintptr_t hDevice, const uint32_t subDevice, const float activeTime, const uint64_t ts,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream, backend_t backend) {

/* Message creation */
Expand Down Expand Up @@ -209,7 +209,7 @@ bt_message* create_copyEU_message(const char* hostname, const process_id_t proce

//activeTime
bt_field *activeTime_field = bt_field_structure_borrow_member_field_by_index(payload_field,2);
bt_field_integer_unsigned_set_value(activeTime_field, activeTime);
bt_field_real_single_precision_set_value(activeTime_field, activeTime);

return message;
}
Expand Down
4 changes: 2 additions & 2 deletions utils/xprof_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ bt_message* create_frequency_message(const char* hostname, const process_id_t pr
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream, backend_t backend = BACKEND_UNKNOWN);

bt_message* create_computeEU_message(const char* hostname, const process_id_t proprocess_id, const thread_id_t thread_id,
const uintptr_t hDevice, const uint32_t subDevice, const uint64_t activeTime, const uint64_t ts,
const uintptr_t hDevice, const uint32_t subDevice, const float activeTime, const uint64_t ts,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream, backend_t backend = BACKEND_UNKNOWN);

bt_message* create_copyEU_message(const char* hostname, const process_id_t proprocess_id, const thread_id_t thread_id,
const uintptr_t hDevice, const uint32_t subDevice, const uint64_t activeTime, const uint64_t ts,
const uintptr_t hDevice, const uint32_t subDevice, const float activeTime, const uint64_t ts,
bt_event_class *event_class, bt_self_message_iterator *message_iterator, bt_stream *stream, backend_t backend = BACKEND_UNKNOWN);

bt_message *create_host_message(const char *hostname, const process_id_t, const thread_id_t,
Expand Down
10 changes: 4 additions & 6 deletions xprof/btx_interval_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@
:cast_type: uint32_t
- :name: activeTime
:field_class:
:type: integer_unsigned
:field_value_range: 64
:cast_type: uint64_t
:type: single
:cast_type: float
- :name: lttng:copyEU
:payload_field_class:
:type: structure
Expand All @@ -162,6 +161,5 @@
:cast_type: uint32_t
- :name: activeTime
:field_class:
:type: integer_unsigned
:field_value_range: 64
:cast_type: uint64_t
:type: single
:cast_type: float
12 changes: 6 additions & 6 deletions xprof/btx_timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static void add_event_power(timeline_dispatch_t *dispatch, std::string hostname,

static void add_event_computeEU(timeline_dispatch_t *dispatch, std::string hostname,
uint64_t process_id, uint64_t thread_id, uintptr_t did,
uint32_t subDevice, uint64_t timestamp, uint64_t activeTime) {
uint32_t subDevice, uint64_t timestamp, float activeTime) {
perfetto_uuid_t track_uuid = get_computeEU_track_uuuid(dispatch, hostname, process_id, did, subDevice);
auto *packet = dispatch->trace.add_packet();
packet->set_trusted_packet_sequence_id(10000);
Expand All @@ -158,12 +158,12 @@ static void add_event_computeEU(timeline_dispatch_t *dispatch, std::string hostn
track_event->set_type(perfetto_pruned::TrackEvent::TYPE_COUNTER);
track_event->set_track_uuid(track_uuid);
track_event->set_name("computeEngine Usage");
track_event->set_counter_value(activeTime);
track_event->set_double_counter_value(activeTime);
}

static void add_event_copyEU(timeline_dispatch_t *dispatch, std::string hostname,
uint64_t process_id, uint64_t thread_id, uintptr_t did,
uint32_t subDevice, uint64_t timestamp, uint64_t activeTime) {
uint32_t subDevice, uint64_t timestamp, float activeTime) {
perfetto_uuid_t track_uuid = get_copyEU_track_uuuid(dispatch, hostname, process_id, did, subDevice);
auto *packet = dispatch->trace.add_packet();
packet->set_trusted_packet_sequence_id(10000);
Expand All @@ -172,7 +172,7 @@ static void add_event_copyEU(timeline_dispatch_t *dispatch, std::string hostname
track_event->set_type(perfetto_pruned::TrackEvent::TYPE_COUNTER);
track_event->set_track_uuid(track_uuid);
track_event->set_name("copyEngine Usage");
track_event->set_counter_value(activeTime);
track_event->set_double_counter_value(activeTime);
}

static void add_event_begin(timeline_dispatch_t *dispatch, perfetto_uuid_t uuid, timestamp_t begin,
Expand Down Expand Up @@ -394,14 +394,14 @@ static void power_usr_callback(void *btx_handle, void *usr_data, const char *hos

static void computeEU_usr_callback(void *btx_handle, void *usr_data, const char *hostname,
int64_t vpid, uint64_t vtid, int64_t ts, int64_t backend,
uint64_t did, uint32_t subDevice, uint64_t activeTime) {
uint64_t did, uint32_t subDevice, float activeTime) {
auto *dispatch = static_cast<timeline_dispatch_t *>(usr_data);
add_event_computeEU(dispatch, hostname, vpid, vtid, did, subDevice, ts, activeTime);
}

static void copyEU_usr_callback(void *btx_handle, void *usr_data, const char *hostname,
int64_t vpid, uint64_t vtid, int64_t ts, int64_t backend,
uint64_t did, uint32_t subDevice, uint64_t activeTime) {
uint64_t did, uint32_t subDevice, float activeTime) {
auto *dispatch = static_cast<timeline_dispatch_t *>(usr_data);
add_event_copyEU(dispatch, hostname, vpid, vtid, did, subDevice, ts, activeTime);
}
Expand Down
15 changes: 6 additions & 9 deletions ze/tracer_ze_helpers.include.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ static uint32_t _sampling_subDeviceCount;
static uint32_t* _sampling_freqDomainCounts;
static uint32_t* _sampling_powerDomainCounts;
static uint32_t* _sampling_engineCounts;
static uint32_t* _sampling_engineCounts;

typedef struct {
uint64_t timestamp;
Expand Down Expand Up @@ -797,7 +796,7 @@ int initializeHandles() {
#endif

// Query driver
uint32_t driverCount;
uint32_t driverCount = 0;
res = ZE_DRIVER_GET_PTR(&driverCount, NULL);
if (res != ZE_RESULT_SUCCESS) {
_ZE_ERROR_MSG("1st ZE_DRIVER_GET_PTR", res);
Expand Down Expand Up @@ -851,7 +850,6 @@ int initializeHandles() {
printf("zesDeviceEnumFrequencyDomains failed for device %d: %d\n", i, res);
return(-1);
}

// Get power domains for each device
res = zesDeviceEnumPowerDomains(_sampling_hDevices[i], &_sampling_powerDomainCounts[i], NULL);
if (res != ZE_RESULT_SUCCESS) {
Expand All @@ -871,6 +869,7 @@ int initializeHandles() {
printf("No engine groups found\n");
return(-1);
}

_sampling_engineHandles[i] = (zes_engine_handle_t*)malloc(_sampling_engineCounts[i] * sizeof(zes_engine_handle_t));
res = zesDeviceEnumEngineGroups(_sampling_hDevices[i], &_sampling_engineCounts[i], _sampling_engineHandles[i]);
if (res != ZE_RESULT_SUCCESS) {
Expand All @@ -889,7 +888,6 @@ void readFrequency(uint32_t deviceIdx, uint32_t domainIdx, uint32_t *frequency)
*frequency=0;
zes_freq_state_t freqState;
if (zesFrequencyGetState(_sampling_hFrequencies[deviceIdx][domainIdx], &freqState) == ZE_RESULT_SUCCESS) {
// printf("Device %d - Frequency Domain %d: Current frequency: %lf MHz\n", deviceIdx, domainIdx, freqState.actual);
*frequency = freqState.actual;
}
}
Expand All @@ -900,7 +898,6 @@ void readEnergy(uint32_t deviceIdx, uint32_t domainIdx, uint64_t *ts_us, uint64_
*energy_uj = 0;
zes_power_energy_counter_t energyCounter;
if (zesPowerGetEnergyCounter(_sampling_hPowers[deviceIdx][domainIdx], &energyCounter) == ZE_RESULT_SUCCESS) {
// printf("Device %d - Power Domain %d: Total energy consumption: %lu Joules\n", deviceIdx, domainIdx, energyCounter.energy);
*ts_us = energyCounter.timestamp;
*energy_uj = energyCounter.energy;
}
Expand Down Expand Up @@ -953,16 +950,16 @@ static void thapi_sampling_energy() {
for (uint32_t i = 0; i < _sampling_deviceCount; i++) {
for (uint32_t j = 0; j < _sampling_freqDomainCounts[i]; j++) {
readFrequency(i, j, &frequency);
do_tracepoint(lttng_ust_ze_sampling, gpu_frequency, (ze_device_handle_t)_sampling_hDevices[i], j, ts_us, frequency);
tracepoint(lttng_ust_ze_sampling, gpu_frequency, (ze_device_handle_t)_sampling_hDevices[i], j, ts_us, frequency);
}
for (uint32_t j = 0; j < _sampling_powerDomainCounts[i]; j++) {
readEnergy(i, j, &ts_us, &energy_uj);
do_tracepoint(lttng_ust_ze_sampling, gpu_energy, (ze_device_handle_t)_sampling_hDevices[i], j, (uint64_t)energy_uj, ts_us);
tracepoint(lttng_ust_ze_sampling, gpu_energy, (ze_device_handle_t)_sampling_hDevices[i], j, (uint64_t)energy_uj, ts_us);
}
readPerformance(i, computeE, copyE);
for (uint32_t k=0; k<_sampling_subDeviceCount; k++){
do_tracepoint(lttng_ust_ze_sampling, computeEngine, (ze_device_handle_t)_sampling_hDevices[i], k, computeE[k].computeActive, computeE[k].timestamp);
do_tracepoint(lttng_ust_ze_sampling, copyEngine, (ze_device_handle_t)_sampling_hDevices[i], k, copyE[k].copyActive, copyE[k].timestamp);
tracepoint(lttng_ust_ze_sampling, computeEngine, (ze_device_handle_t)_sampling_hDevices[i], k, computeE[k].computeActive, computeE[k].timestamp);
tracepoint(lttng_ust_ze_sampling, copyEngine, (ze_device_handle_t)_sampling_hDevices[i], k, copyE[k].copyActive, copyE[k].timestamp);
}
}
}
Expand Down
Loading

0 comments on commit 9c15987

Please sign in to comment.