Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error out of counter splitting if group max is zero #70

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions include/gpu_performance_api/gpu_perf_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef enum
kGpaStatusErrorLibAlreadyLoaded = -41,
kGpaStatusErrorOtherSessionActive = -42,
kGpaStatusErrorException = -43,
gGpaInvalidCounterGroupData = -44,
PLohrmannAMD marked this conversation as resolved.
Show resolved Hide resolved
kGpaStatusMin = kGpaStatusErrorException,
PLohrmannAMD marked this conversation as resolved.
Show resolved Hide resolved
kGpaStatusInternal = 256, ///< Status codes used internally within GPUPerfAPI.
} GpaStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,37 @@ GpaStatus GpaCounterSchedulerBase::GetNumRequiredPasses(GpaUInt32* num_required_
// Add the HW groups max's.
for (unsigned int i = 0; i < hw_counters->internal_counter_groups_.size(); ++i)
{
max_counters_per_group.push_back(hw_counters->internal_counter_groups_[i].max_active_discrete_counters);
auto count = hw_counters->internal_counter_groups_[i].max_active_discrete_counters;
if (count == 0)
{
GPA_LOG_DEBUG_ERROR("ERROR: hardware counter group '%s' has zero for max-counters-per-group", hw_counters->internal_counter_groups_[i].name);
return gGpaInvalidCounterGroupData;
}
max_counters_per_group.push_back(count);
}

// Add the Additional groups max's.
for (unsigned int i = 0; i < hw_counters->additional_group_count_; ++i)
{
max_counters_per_group.push_back(hw_counters->additional_groups_[i].max_active_discrete_counters);
auto count = hw_counters->additional_groups_[i].max_active_discrete_counters;
if (count == 0)
{
GPA_LOG_DEBUG_ERROR("ERROR: hardware counter additional group '%s' has zero for max-counters-per-group", hw_counters->additional_groups_[i].name);
return gGpaInvalidCounterGroupData;
}
max_counters_per_group.push_back(count);
}

// TODO: properly handle software groups -- right now, this works because there is only ever a single group defined.
if (sw_counters->group_count_ == 1)
{
max_counters_per_group.push_back(DoGetNumSoftwareCounters());
auto count = DoGetNumSoftwareCounters();
if (count == 0)
{
GPA_LOG_DEBUG_ERROR("ERROR: software counter group has zero for max-counters-per-group");
return gGpaInvalidCounterGroupData;
}
max_counters_per_group.push_back(count);
}

GpaCounterGroupAccessor accessor(hw_counters->internal_counter_groups_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#ifdef DEBUG_PUBLIC_COUNTER_SPLITTER
#include <sstream>
#include "gpu_perf_api_common/logging.h"
#endif

#include "gpu_perf_api_counter_generator/gpa_derived_counter.h"
#include "gpu_perf_api_common/logging.h"

/// @brief Enum to represent the different SQ shader stages.
enum GpaSqShaderStage
Expand Down Expand Up @@ -390,6 +390,11 @@ class IGpaSplitCounters
}

unsigned int group_limit = max_counters_per_group[group_index];
if (group_limit == 0)
{
GPA_LOG_DEBUG_ERROR("ERROR: group(%d) count limit is zero", group_index);
PLohrmannAMD marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

return new_group_used_count <= group_limit;
}
Expand Down