diff --git a/docs/envvars.rst b/docs/envvars.rst index 001b4336077..307eb5e28eb 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -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: diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index c97b2f20179..8eae8db5588 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -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. diff --git a/src/amd/vulkan/radv_instance.c b/src/amd/vulkan/radv_instance.c index 1b3a2964ccc..132144ac280 100644 --- a/src/amd/vulkan/radv_instance.c +++ b/src/amd/vulkan/radv_instance.c @@ -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 diff --git a/src/amd/vulkan/radv_instance.h b/src/amd/vulkan/radv_instance.h index 0c658ccaead..b33a9295c01 100644 --- a/src/amd/vulkan/radv_instance.h +++ b/src/amd/vulkan/radv_instance.h @@ -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;