[Mesa-dev] [PATCH 3/4] gallium/radeon: add a HUD query for monitoring the CS thread activity
Grazvydas Ignotas
notasas at gmail.com
Sat Feb 11 21:31:45 UTC 2017
On Sat, Feb 11, 2017 at 9:58 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/drivers/radeon/r600_query.c | 25 ++++++++++++++++++++++-
> src/gallium/drivers/radeon/r600_query.h | 1 +
> src/gallium/drivers/radeon/radeon_winsys.h | 1 +
> src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 2 ++
> src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 2 ++
> 5 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index 05741d3..8009416 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -19,37 +19,41 @@
> * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
> * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> * USE OR OTHER DEALINGS IN THE SOFTWARE.
> */
>
> #include "r600_query.h"
> #include "r600_cs.h"
> #include "util/u_memory.h"
> #include "util/u_upload_mgr.h"
> -
> +#include "os/os_time.h"
> #include "tgsi/tgsi_text.h"
>
> struct r600_hw_query_params {
> unsigned start_offset;
> unsigned end_offset;
> unsigned fence_offset;
> unsigned pair_stride;
> unsigned pair_count;
> };
>
> /* Queries without buffer handling or suspend/resume. */
> struct r600_query_sw {
> struct r600_query b;
>
> uint64_t begin_result;
> uint64_t end_result;
> +
> + uint64_t begin_time;
> + uint64_t end_time;
> +
> /* Fence for GPU_FINISHED. */
> struct pipe_fence_handle *fence;
> };
>
> static void r600_query_sw_destroy(struct r600_common_context *rctx,
> struct r600_query *rquery)
> {
> struct pipe_screen *screen = rctx->b.screen;
> struct r600_query_sw *query = (struct r600_query_sw *)rquery;
>
> @@ -69,28 +73,30 @@ static enum radeon_value_id winsys_id_from_type(unsigned type)
> case R600_QUERY_NUM_GFX_IBS: return RADEON_NUM_GFX_IBS;
> case R600_QUERY_NUM_SDMA_IBS: return RADEON_NUM_SDMA_IBS;
> case R600_QUERY_NUM_BYTES_MOVED: return RADEON_NUM_BYTES_MOVED;
> case R600_QUERY_NUM_EVICTIONS: return RADEON_NUM_EVICTIONS;
> case R600_QUERY_VRAM_USAGE: return RADEON_VRAM_USAGE;
> case R600_QUERY_VRAM_VIS_USAGE: return RADEON_VRAM_VIS_USAGE;
> case R600_QUERY_GTT_USAGE: return RADEON_GTT_USAGE;
> case R600_QUERY_GPU_TEMPERATURE: return RADEON_GPU_TEMPERATURE;
> case R600_QUERY_CURRENT_GPU_SCLK: return RADEON_CURRENT_SCLK;
> case R600_QUERY_CURRENT_GPU_MCLK: return RADEON_CURRENT_MCLK;
> + case R600_QUERY_CS_THREAD_BUSY: return RADEON_CS_THREAD_TIME;
> default: unreachable("query type does not correspond to winsys id");
> }
> }
>
> static bool r600_query_sw_begin(struct r600_common_context *rctx,
> struct r600_query *rquery)
> {
> struct r600_query_sw *query = (struct r600_query_sw *)rquery;
> + enum radeon_value_id ws_id;
>
> switch(query->b.type) {
> case PIPE_QUERY_TIMESTAMP_DISJOINT:
> case PIPE_QUERY_GPU_FINISHED:
> break;
> case R600_QUERY_DRAW_CALLS:
> query->begin_result = rctx->num_draw_calls;
> break;
> case R600_QUERY_SPILL_DRAW_CALLS:
> query->begin_result = rctx->num_spill_draw_calls;
> @@ -139,22 +145,28 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
> case R600_QUERY_NUM_MAPPED_BUFFERS:
> query->begin_result = 0;
> break;
> case R600_QUERY_BUFFER_WAIT_TIME:
> case R600_QUERY_NUM_GFX_IBS:
> case R600_QUERY_NUM_SDMA_IBS:
> case R600_QUERY_NUM_BYTES_MOVED:
> case R600_QUERY_NUM_EVICTIONS: {
> enum radeon_value_id ws_id = winsys_id_from_type(query->b.type);
> query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
> + query->begin_time = os_time_get_nano();
> break;
Is this needed? The corresponding end_time is never set.
Gražvydas
More information about the mesa-dev
mailing list