mesa/src/intel/executor/executor.h
Caio Oliveira 2c64e12462
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
intel/executor: Add performance counter support
Add optional OA performance counter collection around each execute()
call. Examples:

```
  # List all profiles and counters, with descriptions.
  $ executor --oa list

  # Collect all counters from a profile.
  $ executor --oa ComputeBasic file.lua

  # Collect a subset of counters from a profile, separated by comma.
  $ executor --oa ComputeBasic:GpuTime,AvgGpuCoreFrequency file.lua

  # By default use ComputeBasic profile, so counter names only also work.
  $ executor --oa GpuTime file.lua
```

The selected counters are printed to stdout after the script finishes,
or written to a file specified by --oa-csv FILENAME.

Assisted-by: Pi coding agent (GPT-5.5)
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41610>
2026-05-21 16:46:35 -07:00

108 lines
2.1 KiB
C

/*
* Copyright © 2024 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#ifndef EXECUTOR_H
#define EXECUTOR_H
#include <stdbool.h>
#include <stdint.h>
#include "intel/dev/intel_device_info.h"
#include "intel/isl/isl.h"
#include "perf/intel_perf.h"
#include "perf/intel_perf_query.h"
typedef struct {
uint32_t size;
uint32_t handle;
void *map;
void *cursor;
uint64_t addr;
} executor_bo;
typedef struct {
void *mem_ctx;
struct intel_device_info *devinfo;
struct isl_device *isl_dev;
int fd;
struct {
uint32_t ctx_id;
} i915;
struct {
uint32_t vm_id;
uint32_t queue_id;
} xe;
struct {
executor_bo batch;
executor_bo extra;
executor_bo data;
executor_bo perf;
} bo;
bool perf_enabled;
struct {
struct intel_perf_context *ctx;
struct intel_perf_query_object *obj;
} perf_query;
uint64_t batch_start;
} executor_context;
typedef struct {
const char *original_src;
void *kernel_bin;
uint32_t kernel_size;
} executor_params;
typedef struct {
uint64_t offset;
} executor_address;
__attribute__((unused)) static uint64_t
executor_combine_address(void *data, void *location,
executor_address address, uint32_t delta)
{
return address.offset + delta;
}
executor_address executor_address_of_ptr(executor_bo *bo, void *ptr);
void *executor_alloc_bytes(executor_bo *bo, uint32_t size);
void *executor_alloc_bytes_aligned(executor_bo *bo, uint32_t size, uint32_t alignment);
void failf(const char *fmt, ...) PRINTFLIKE(1, 2);
const char *executor_apply_macros(executor_context *ec, const char *original_src);
#ifdef genX
# include "executor_genx.h"
#else
# define genX(x) gfx9_##x
# include "executor_genx.h"
# undef genX
# define genX(x) gfx11_##x
# include "executor_genx.h"
# undef genX
# define genX(x) gfx12_##x
# include "executor_genx.h"
# undef genX
# define genX(x) gfx125_##x
# include "executor_genx.h"
# undef genX
# define genX(x) gfx20_##x
# include "executor_genx.h"
# undef genX
# define genX(x) gfx30_##x
# include "executor_genx.h"
# undef genX
#endif
#endif /* EXECUTOR_H */