[PATCH 2/2] xe_exec_system_allocator: Add benchmark
Matthew Brost
matthew.brost at intel.com
Thu Jun 20 03:50:57 UTC 2024
Signed-off-by: Matthew Brost <matthew.brost at intel.com>
---
tests/intel/xe_exec_system_allocator.c | 31 +++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/tests/intel/xe_exec_system_allocator.c b/tests/intel/xe_exec_system_allocator.c
index 7b85f85e5e..1b93d6d87a 100644
--- a/tests/intel/xe_exec_system_allocator.c
+++ b/tests/intel/xe_exec_system_allocator.c
@@ -13,6 +13,7 @@
#include <fcntl.h>
#include <linux/mman.h>
+#include <time.h>
#include "igt.h"
#include "lib/igt_syncobj.h"
@@ -62,7 +63,8 @@ static void check_all_pages(void *ptr, uint64_t alloc_size, uint64_t stride)
}
static void touch_all_pages(int fd, uint32_t exec_queue, void *ptr,
- uint64_t alloc_size, uint64_t stride)
+ uint64_t alloc_size, uint64_t stride,
+ struct timespec *tv, uint64_t *submit)
{
struct drm_xe_sync sync[1] = {
{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
@@ -97,6 +99,9 @@ static void touch_all_pages(int fd, uint32_t exec_queue, void *ptr,
igt_assert(b <= ARRAY_SIZE(data->batch));
}
+ igt_nsec_elapsed(tv);
+ *submit = igt_nsec_elapsed(tv);
+
addr = to_user_pointer(ptr);
for (i = 0; i < n_writes; ++i, addr += stride) {
struct batch_data *data = ptr + i * stride;
@@ -147,6 +152,7 @@ static void touch_all_pages(int fd, uint32_t exec_queue, void *ptr,
#define odd(__i) (__i & 1)
#define MIX_BO_ALLOC (0x1 << 0)
+#define BENCHMARK (0x1 << 1)
#define SYNC_FILE "/tmp/xe_exec_system_allocator_sync"
@@ -185,9 +191,12 @@ evict(int fd, struct drm_xe_engine_class_instance *eci, uint64_t total_alloc,
unsigned int flags)
{
uint32_t vm, exec_queue;
- int num_allocs = (9 * (total_alloc / alloc_size)) / 8;
+ int num_allocs = flags & BENCHMARK ? 1 :
+ (9 * (total_alloc / alloc_size)) / 8;
void **allocs;
uint32_t *bos = NULL;
+ struct timespec tv = {};
+ uint64_t submit, read, elapsed;
int i;
vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE |
@@ -227,14 +236,24 @@ evict(int fd, struct drm_xe_engine_class_instance *eci, uint64_t total_alloc,
}
allocs[i] = alloc;
- touch_all_pages(fd, exec_queue, allocs[i], alloc_size, stride);
+ touch_all_pages(fd, exec_queue, allocs[i], alloc_size, stride,
+ &tv, &submit);
}
if (barrier)
pthread_barrier_wait(barrier);
for (i = 0; i < num_allocs; ++i) {
+ if (flags & BENCHMARK)
+ read = igt_nsec_elapsed(&tv);
check_all_pages(allocs[i], alloc_size, stride);
+ if (flags & BENCHMARK) {
+ elapsed = igt_nsec_elapsed(&tv);
+ printf("Execution took %.3fms (submit %.1fus, read %.1fus, total %.1fus, read_total %.1fus)\n",
+ 1e-6 * elapsed, 1e-3 * submit, 1e-3 * read,
+ 1e-3 * (elapsed - submit),
+ 1e-3 * (elapsed - read));
+ }
if (bos && bos[i]) {
munmap(allocs[i], alloc_size);
gem_close(fd, bos[i]);
@@ -1262,6 +1281,12 @@ igt_main
break;
}
+ igt_subtest_f("fault-benchmark")
+ xe_for_each_engine(fd, hwe) {
+ evict(fd, hwe, SZ_64M, SZ_64M, SZ_4K, NULL, BENCHMARK);
+ break;
+ }
+
for (const struct section *s = esections; s->name; s++) {
igt_subtest_f("evict-%s", s->name)
xe_for_each_engine(fd, hwe) {
--
2.34.1
More information about the igt-dev
mailing list