Skip to content
Merged
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
16 changes: 9 additions & 7 deletions sw/nic/gpuagent/api/gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,21 @@ gpu_entry::update_handler(api_params_base *api_params) {
}

void
gpu_entry::fill_stats_(aga_gpu_stats_t *stats) {
gpu_entry::fill_stats_(aga_gpu_stats_t *stats,
const aga_gpu_get_filter_t *filter) {
// fill stats only for non-parent GPUs
if (child_gpus_.size()) {
return;
}
// fetch stats from smi apis
smi_gpu_fill_stats(handle_, &key_, is_partitioned_,
(partition_id_ == AGA_GPU_INVALID_PARTITION_ID) ? 0 : partition_id_,
first_partition_handle_, stats);
first_partition_handle_, stats, filter);
}

void
gpu_entry::fill_status_(aga_gpu_spec_t *spec, aga_gpu_status_t *status) {
gpu_entry::fill_status_(aga_gpu_spec_t *spec, aga_gpu_status_t *status,
const aga_gpu_get_filter_t *filter) {
if (child_gpus_.size()) {
status->num_gpu_partition = child_gpus_.size();
// for parent GPUs get uuids of all children
Expand All @@ -175,7 +177,7 @@ gpu_entry::fill_status_(aga_gpu_spec_t *spec, aga_gpu_status_t *status) {
if (parent_gpu_.valid()) {
status->physical_gpu = parent_gpu_;
}
smi_gpu_fill_status(handle_, &key_, id_, spec, status);
smi_gpu_fill_status(handle_, &key_, id_, spec, status, filter);
}
}

Expand All @@ -201,10 +203,10 @@ gpu_entry::fill_spec_(aga_gpu_spec_t *spec) {
}

sdk_ret_t
gpu_entry::read(aga_gpu_info_t *info) {
gpu_entry::read(aga_gpu_info_t *info, const aga_gpu_get_filter_t *filter) {
fill_spec_(&info->spec);
fill_status_(&info->spec, &info->status);
fill_stats_(&info->stats);
fill_status_(&info->spec, &info->status, filter);
fill_stats_(&info->stats, filter);
return SDK_RET_OK;
}

Expand Down
14 changes: 10 additions & 4 deletions sw/nic/gpuagent/api/gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ class gpu_entry : public api_base {
virtual sdk_ret_t delete_handler(api_params_base *api_params) override;

/// \brief read config
/// \param[out] info pointer to the info object
/// \param[out] info pointer to the info object
/// \param[in] filter attributes to skip (NULL fetches all attributes)
/// \return SDK_RET_OK on success, failure status code on error
sdk_ret_t read(aga_gpu_info_t *info);
sdk_ret_t read(aga_gpu_info_t *info,
const aga_gpu_get_filter_t *filter = NULL);

/// \brief return stringified key of the object (for debugging)
virtual string key2str(void) const override {
Expand Down Expand Up @@ -296,11 +298,15 @@ class gpu_entry : public api_base {
/// \brief fill the gpu operational status
/// \param[in] spec config specification
/// \param[out] status operational status
void fill_status_(aga_gpu_spec_t *spec, aga_gpu_status_t *status);
/// \param[in] filter attributes to skip (NULL fetches all attributes)
void fill_status_(aga_gpu_spec_t *spec, aga_gpu_status_t *status,
const aga_gpu_get_filter_t *filter);

/// \brief fill the gpu statistics
/// \param[out] stats statistics
void fill_stats_(aga_gpu_stats_t *stats);
/// \param[in] filter attributes to skip (NULL fetches all attributes)
void fill_stats_(aga_gpu_stats_t *stats,
const aga_gpu_get_filter_t *filter);

private:
/// uuid of the object
Expand Down
12 changes: 8 additions & 4 deletions sw/nic/gpuagent/api/gpu_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ aga_gpu_create (_In_ aga_gpu_spec_t *spec)
}

sdk_ret_t
aga_gpu_read (_In_ aga_obj_key_t *key, _Out_ aga_gpu_info_t *info)
aga_gpu_read (_In_ aga_obj_key_t *key, _Out_ aga_gpu_info_t *info,
const aga_gpu_get_filter_t *filter)
{
sdk_ret_t ret;
gpu_entry *entry;
Expand All @@ -95,12 +96,13 @@ aga_gpu_read (_In_ aga_obj_key_t *key, _Out_ aga_gpu_info_t *info)
if (unlikely(ret != SDK_RET_OK)) {
return ret;
}
return entry->read(info);
return entry->read(info, filter);
}

typedef struct aga_gpu_read_args_s {
void *ctxt;
gpu_read_cb_t cb;
const aga_gpu_get_filter_t *filter;
} aga_gpu_read_args_t;

static bool
Expand All @@ -120,19 +122,21 @@ aga_gpu_info_from_entry (void *entry, void *ctxt)
}
memset(&info, 0, sizeof(aga_gpu_info_t));
// call entry read
gpu->read(&info);
gpu->read(&info, args->filter);
// call cb on info
args->cb(&info, args->ctxt);
return false;
}

sdk_ret_t
aga_gpu_read_all (gpu_read_cb_t gpu_read_cb, void *ctxt)
aga_gpu_read_all (gpu_read_cb_t gpu_read_cb, void *ctxt,
const aga_gpu_get_filter_t *filter)
{
aga_gpu_read_args_t args = { 0 };

args.ctxt = ctxt;
args.cb = gpu_read_cb;
args.filter = filter;
return gpu_db()->walk(aga_gpu_info_from_entry, &args);
}

Expand Down
48 changes: 42 additions & 6 deletions sw/nic/gpuagent/api/include/aga_gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,38 @@ typedef enum aga_gpu_admin_state_e {
AGA_GPU_ADMIN_STATE_DOWN = 2,
} aga_gpu_admin_state_t;

/// \brief GPU attributes that can be skipped in a get request;
/// default (all false) fetches all attributes
typedef struct aga_gpu_get_filter_s {
/// skip clock status
bool skip_clock_status;
/// skip PCIe status
bool skip_pcie_status;
/// skip XGMI error status
bool skip_xgmi_status;
/// skip process list
bool skip_process_status;
/// skip UALink state
bool skip_ualink_status;
/// skip VRAM usage
bool skip_vram_usage_stats;
/// skip ECC error counts
bool skip_ecc_stats;
/// skip violation stats
bool skip_violation_stats;
/// skip PCIe stats
bool skip_pcie_stats;
/// skip XGMI counters
bool skip_xgmi_stats;
/// skip GPU activity and usage
bool skip_activity_stats;
} aga_gpu_get_filter_t;

/// true if the given attribute should be skipped;
/// a NULL filter fetches all attributes
#define AGA_GPU_SKIP(_filter_, _field_) \
(((_filter_) != NULL) && ((_filter_)->_field_))

/// \brief GPU clock types
typedef enum aga_gpu_clock_type_e {
AGA_GPU_CLOCK_TYPE_NONE = 0,
Expand Down Expand Up @@ -996,18 +1028,22 @@ typedef struct aga_cper_info_s {
sdk_ret_t aga_gpu_create(_In_ aga_gpu_spec_t *spec);

/// \brief read gpu
/// \param[in] key key of the gpu object
/// \param[out] info information
/// \param[in] key key of the gpu object
/// \param[out] info information
/// \param[in] filter attributes to skip (NULL fetches all attributes)
/// \return #SDK_RET_OK on success, failure status code on error
sdk_ret_t aga_gpu_read(_In_ aga_obj_key_t *key, _Out_ aga_gpu_info_t *info);
sdk_ret_t aga_gpu_read(_In_ aga_obj_key_t *key, _Out_ aga_gpu_info_t *info,
const aga_gpu_get_filter_t *filter = NULL);

typedef void (*gpu_read_cb_t)(aga_gpu_info_t *info, void *ctxt);

/// \brief read all gpu information
/// \param[in] cb callback function
/// \param[in] ctxt opaque context passed to cb
/// \param[in] cb callback function
/// \param[in] ctxt opaque context passed to cb
/// \param[in] filter attributes to skip (NULL fetches all attributes)
/// \return #SDK_RET_OK on success, failure status code on error
sdk_ret_t aga_gpu_read_all(_In_ gpu_read_cb_t gpu_read_cb, _In_ void *ctxt);
sdk_ret_t aga_gpu_read_all(_In_ gpu_read_cb_t gpu_read_cb, _In_ void *ctxt,
const aga_gpu_get_filter_t *filter = NULL);

/// \brief function to get compute partition info of a given physical gpu
/// which has been partitioned
Expand Down
Loading
Loading