radv: Add RADV_PROFILE_PSTATE envvar

Enable selecting the specific pstate to enter when using thread tracing
and when acquiring the profiling lock for performance queries.

Signed-off-by: Josh Simmons <josh@nega.tv>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30139>
This commit is contained in:
Josh Simmons 2024-07-11 23:19:31 +02:00 committed by Marge Bot
parent bda1de89db
commit 1ced840632
4 changed files with 35 additions and 2 deletions

View file

@ -1465,6 +1465,20 @@ RADV driver environment variables
decrease the resolution used for dumping the ray history resolution when capturing
RRA traces. This allows for dumping every Nth invocation along each dispatch dimension.
.. envvar:: RADV_PROFILE_PSTATE
choose the specific pstate to enter when using thread tracing or when acquiring the
profiling lock for performance queries.
``standard``
force GPU clocks to an arbitrary fixed level
``min_sclk``
force the shader clock to its minimum level
``min_mclk``
force the memory clock to its minimum level
``peak``
force GPU clocks to their maximum level, this is the default value
.. envvar:: ACO_DEBUG
a comma-separated list of named flags, which do various things:

View file

@ -1863,8 +1863,9 @@ bool
radv_device_set_pstate(struct radv_device *device, bool enable)
{
const struct radv_physical_device *pdev = radv_device_physical(device);
const struct radv_instance *instance = radv_physical_device_instance(pdev);
struct radeon_winsys *ws = device->ws;
enum radeon_ctx_pstate pstate = enable ? RADEON_CTX_PSTATE_PEAK : RADEON_CTX_PSTATE_NONE;
enum radeon_ctx_pstate pstate = enable ? instance->profile_pstate : RADEON_CTX_PSTATE_NONE;
if (pdev->info.has_stable_pstate) {
/* pstate is per-device; setting it for one ctx is sufficient.

View file

@ -308,6 +308,22 @@ radv_handle_legacy_sqtt_trigger(struct vk_instance *instance)
}
}
static enum radeon_ctx_pstate
radv_parse_pstate(const char* str)
{
if (!strcmp(str, "peak")) {
return RADEON_CTX_PSTATE_PEAK;
} else if (!strcmp(str, "standard")) {
return RADEON_CTX_PSTATE_STANDARD;
} else if (!strcmp(str, "min_sclk")) {
return RADEON_CTX_PSTATE_MIN_SCLK;
} else if (!strcmp(str, "min_mclk")) {
return RADEON_CTX_PSTATE_MIN_MCLK;
} else {
return RADEON_CTX_PSTATE_NONE;
}
}
VKAPI_ATTR VkResult VKAPI_CALL
radv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance)
@ -338,6 +354,7 @@ radv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationC
instance->debug_flags = parse_debug_string(getenv("RADV_DEBUG"), radv_debug_options);
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"), radv_perftest_options);
instance->profile_pstate = radv_parse_pstate(debug_get_option("RADV_PROFILE_PSTATE", "peak"));
/* When RADV_FORCE_FAMILY is set, the driver creates a null
* device that allows to test the compiler without having an

View file

@ -12,7 +12,7 @@
#define RADV_INSTANCE_H
#include "util/xmlconfig.h"
#include "radv_radeon_winsys.h"
#include "vk_instance.h"
#ifdef ANDROID_STRICT
@ -39,6 +39,7 @@ struct radv_instance {
uint64_t debug_flags;
uint64_t perftest_flags;
enum radeon_ctx_pstate profile_pstate;
struct {
struct driOptionCache options;