[igt-dev] [PATCH i-g-t v2 14/20] benchmarks: Remove libdrm dependency
Dominik Grzegorzek
dominik.grzegorzek at intel.com
Thu Sep 17 13:07:05 UTC 2020
Thanks to intel_bb / intel_buf we could get rid of libdrm.
Source buffer creation moved outside do_render function,
because we are not reusing buffers any more so this would wrongly
affect the results.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
benchmarks/intel_upload_blit_large.c | 69 +++++++++++-----------
benchmarks/intel_upload_blit_large_gtt.c | 72 +++++++++++------------
benchmarks/intel_upload_blit_large_map.c | 74 ++++++++++++------------
benchmarks/intel_upload_blit_small.c | 68 +++++++++++-----------
4 files changed, 142 insertions(+), 141 deletions(-)
diff --git a/benchmarks/intel_upload_blit_large.c b/benchmarks/intel_upload_blit_large.c
index 12bbae3d..33a8d72b 100644
--- a/benchmarks/intel_upload_blit_large.c
+++ b/benchmarks/intel_upload_blit_large.c
@@ -72,74 +72,73 @@ get_time_in_secs(void)
}
static void
-do_render(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, int width, int height)
+do_render(int fd, struct intel_bb *ibb, struct intel_buf *src_buf,
+ struct intel_buf *dst_buf, int width, int height)
{
uint32_t data[width * height];
- drm_intel_bo *src_bo;
int i;
static uint32_t seed = 1;
/* Generate some junk. Real workloads would be doing a lot more
* work to generate the junk.
*/
- for (i = 0; i < width * height; i++) {
+ for (i = 0; i < width * height; i++)
data[i] = seed++;
- }
/* Upload the junk. */
- src_bo = drm_intel_bo_alloc(bufmgr, "src", sizeof(data), 4096);
- drm_intel_bo_subdata(src_bo, 0, sizeof(data), data);
+ gem_write(fd, src_buf->handle, 0, data, sizeof(data));
/* Render the junk to the dst. */
- BLIT_COPY_BATCH_START(0);
- OUT_BATCH((3 << 24) | /* 32 bits */
+ intel_bb_blit_start(ibb, 0);
+ intel_bb_out(ibb, (3 << 24) | /* 32 bits */
(0xcc << 16) | /* copy ROP */
(width * 4) /* dst pitch */);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(width * 4); /* src pitch */
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-
- drm_intel_bo_unreference(src_bo);
+ intel_bb_out(ibb, 0); /* dst x1,y1 */
+ intel_bb_out(ibb, (height << 16) | width); /* dst x2,y2 */
+ intel_bb_emit_reloc(ibb, dst_buf->handle, I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_RENDER, 0, dst_buf->addr.offset);
+ intel_bb_out(ibb, 0); /* src x1,y1 */
+ intel_bb_out(ibb, width * 4); /* src pitch */
+ intel_bb_emit_reloc(ibb, src_buf->handle, I915_GEM_DOMAIN_RENDER, 0, 0,
+ src_buf->addr.offset);
+
+ intel_bb_flush_blit(ibb);
}
int main(int argc, char **argv)
{
int fd;
- int object_size = OBJECT_WIDTH * OBJECT_HEIGHT * 4;
double start_time, end_time;
- drm_intel_bo *dst_bo;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct intel_buf *src_buf, *dst_buf;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
int i;
fd = drm_open_driver(DRIVER_INTEL);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ bops = buf_ops_create(fd);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ ibb = intel_bb_create(fd, 4096);
- dst_bo = drm_intel_bo_alloc(bufmgr, "dst", object_size, 4096);
+ dst_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
+ src_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
/* Prep loop to get us warmed up. */
for (i = 0; i < 60; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
/* Do the actual timing. */
start_time = get_time_in_secs();
for (i = 0; i < 200; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
end_time = get_time_in_secs();
printf("%d iterations in %.03f secs: %.01f MB/sec\n", i,
@@ -147,8 +146,10 @@ int main(int argc, char **argv)
(double)i * OBJECT_WIDTH * OBJECT_HEIGHT * 4 / 1024.0 / 1024.0 /
(end_time - start_time));
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
+ intel_buf_destroy(src_buf);
+ intel_buf_destroy(dst_buf);
+ intel_bb_destroy(ibb);
+ buf_ops_destroy(bops);
close(fd);
diff --git a/benchmarks/intel_upload_blit_large_gtt.c b/benchmarks/intel_upload_blit_large_gtt.c
index 0b704b57..da28686f 100644
--- a/benchmarks/intel_upload_blit_large_gtt.c
+++ b/benchmarks/intel_upload_blit_large_gtt.c
@@ -69,74 +69,70 @@ get_time_in_secs(void)
}
static void
-do_render(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, int width, int height)
+do_render(int fd, struct intel_bb *ibb, struct intel_buf *src_buf,
+ struct intel_buf *dst_buf, int width, int height)
{
uint32_t *data;
- drm_intel_bo *src_bo;
int i;
static uint32_t seed = 1;
- src_bo = drm_intel_bo_alloc(bufmgr, "src", width * height * 4, 4096);
+ data = gem_mmap__gtt(fd, src_buf->handle,
+ src_buf->surface[0].size, PROT_WRITE);
- drm_intel_gem_bo_map_gtt(src_bo);
-
- data = src_bo->virtual;
- for (i = 0; i < width * height; i++) {
+ for (i = 0; i < width * height; i++)
data[i] = seed++;
- }
- drm_intel_gem_bo_unmap_gtt(src_bo);
+ gem_munmap(data, src_buf->surface[0].size);
/* Render the junk to the dst. */
- BLIT_COPY_BATCH_START(0);
- OUT_BATCH((3 << 24) | /* 32 bits */
+ intel_bb_blit_start(ibb, 0);
+ intel_bb_out(ibb, (3 << 24) | /* 32 bits */
(0xcc << 16) | /* copy ROP */
(width * 4) /* dst pitch */);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(width * 4); /* src pitch */
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-
- drm_intel_bo_unreference(src_bo);
+ intel_bb_out(ibb, 0); /* dst x1,y1 */
+ intel_bb_out(ibb, (height << 16) | width); /* dst x2,y2 */
+ intel_bb_emit_reloc(ibb, dst_buf->handle, I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_RENDER, 0, dst_buf->addr.offset);
+ intel_bb_out(ibb, 0); /* src x1,y1 */
+ intel_bb_out(ibb, width * 4); /* src pitch */
+ intel_bb_emit_reloc(ibb, src_buf->handle, I915_GEM_DOMAIN_RENDER, 0, 0,
+ src_buf->addr.offset);
+
+ intel_bb_flush_blit(ibb);
}
int main(int argc, char **argv)
{
int fd;
- int object_size = OBJECT_WIDTH * OBJECT_HEIGHT * 4;
double start_time, end_time;
- drm_intel_bo *dst_bo;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct intel_buf *src_buf, *dst_buf;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
int i;
fd = drm_open_driver(DRIVER_INTEL);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ bops = buf_ops_create(fd);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ ibb = intel_bb_create(fd, 4096);
- dst_bo = drm_intel_bo_alloc(bufmgr, "dst", object_size, 4096);
+ dst_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
+ src_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
/* Prep loop to get us warmed up. */
for (i = 0; i < 60; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf, OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
/* Do the actual timing. */
start_time = get_time_in_secs();
for (i = 0; i < 200; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf, OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
end_time = get_time_in_secs();
printf("%d iterations in %.03f secs: %.01f MB/sec\n", i,
@@ -144,8 +140,10 @@ int main(int argc, char **argv)
(double)i * OBJECT_WIDTH * OBJECT_HEIGHT * 4 / 1024.0 / 1024.0 /
(end_time - start_time));
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
+ intel_buf_destroy(src_buf);
+ intel_buf_destroy(dst_buf);
+ intel_bb_destroy(ibb);
+ buf_ops_destroy(bops);
close(fd);
diff --git a/benchmarks/intel_upload_blit_large_map.c b/benchmarks/intel_upload_blit_large_map.c
index ae05434f..542512c9 100644
--- a/benchmarks/intel_upload_blit_large_map.c
+++ b/benchmarks/intel_upload_blit_large_map.c
@@ -72,74 +72,72 @@ get_time_in_secs(void)
}
static void
-do_render(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, int width, int height)
+do_render(struct intel_bb *ibb, struct intel_buf *src_buf,
+ struct intel_buf *dst_buf, int width, int height)
{
uint32_t *data;
- drm_intel_bo *src_bo;
int i;
static uint32_t seed = 1;
- src_bo = drm_intel_bo_alloc(bufmgr, "src", width * height * 4, 4096);
+ intel_buf_cpu_map(src_buf, true);
- drm_intel_bo_map(src_bo, 1);
-
- data = src_bo->virtual;
- for (i = 0; i < width * height; i++) {
+ data = src_buf->ptr;
+ for (i = 0; i < width * height; i++)
data[i] = seed++;
- }
- drm_intel_bo_unmap(src_bo);
+ intel_buf_unmap(src_buf);
/* Render the junk to the dst. */
- BLIT_COPY_BATCH_START(0);
- OUT_BATCH((3 << 24) | /* 32 bits */
+ intel_bb_blit_start(ibb, 0);
+ intel_bb_out(ibb, (3 << 24) | /* 32 bits */
(0xcc << 16) | /* copy ROP */
(width * 4) /* dst pitch */);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(width * 4); /* src pitch */
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-
- drm_intel_bo_unreference(src_bo);
+ intel_bb_out(ibb, 0); /* dst x1,y1 */
+ intel_bb_out(ibb, (height << 16) | width); /* dst x2,y2 */
+ intel_bb_emit_reloc(ibb, dst_buf->handle, I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_RENDER, 0, dst_buf->addr.offset);
+ intel_bb_out(ibb, 0); /* src x1,y1 */
+ intel_bb_out(ibb, width * 4); /* src pitch */
+ intel_bb_emit_reloc(ibb, src_buf->handle, I915_GEM_DOMAIN_RENDER, 0, 0,
+ src_buf->addr.offset);
+
+ intel_bb_flush_blit(ibb);
}
int main(int argc, char **argv)
{
int fd;
- int object_size = OBJECT_WIDTH * OBJECT_HEIGHT * 4;
double start_time, end_time;
- drm_intel_bo *dst_bo;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct intel_buf *src_buf, *dst_buf;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
int i;
fd = drm_open_driver(DRIVER_INTEL);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ bops = buf_ops_create(fd);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ ibb = intel_bb_create(fd, 4096);
- dst_bo = drm_intel_bo_alloc(bufmgr, "dst", object_size, 4096);
+ dst_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
+ src_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
/* Prep loop to get us warmed up. */
for (i = 0; i < 60; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
/* Do the actual timing. */
start_time = get_time_in_secs();
for (i = 0; i < 200; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
end_time = get_time_in_secs();
printf("%d iterations in %.03f secs: %.01f MB/sec\n", i,
@@ -147,8 +145,10 @@ int main(int argc, char **argv)
(double)i * OBJECT_WIDTH * OBJECT_HEIGHT * 4 / 1024.0 / 1024.0 /
(end_time - start_time));
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
+ intel_buf_destroy(src_buf);
+ intel_buf_destroy(dst_buf);
+ intel_bb_destroy(ibb);
+ buf_ops_destroy(bops);
close(fd);
diff --git a/benchmarks/intel_upload_blit_small.c b/benchmarks/intel_upload_blit_small.c
index 7e3346eb..327a6230 100644
--- a/benchmarks/intel_upload_blit_small.c
+++ b/benchmarks/intel_upload_blit_small.c
@@ -66,16 +66,13 @@ get_time_in_secs(void)
}
static void
-do_render(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, int width, int height)
+do_render(int fd, struct intel_bb *ibb, struct intel_buf *src_buf,
+ struct intel_buf *dst_buf, int width, int height)
{
uint32_t data[64];
- drm_intel_bo *src_bo;
int i;
static uint32_t seed = 1;
- src_bo = drm_intel_bo_alloc(bufmgr, "src", width * height * 4, 4096);
-
/* Upload some junk. Real workloads would be doing a lot more
* work to generate the junk.
*/
@@ -96,60 +93,63 @@ do_render(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch,
data[j] = seed++;
/* Upload the junk. */
- drm_intel_bo_subdata(src_bo, i * 4, size * 4, data);
+ gem_write(fd, src_buf->handle, i * 4, data,
+ size * 4);
i += size;
}
/* Render the junk to the dst. */
- BLIT_COPY_BATCH_START(0);
- OUT_BATCH((3 << 24) | /* 32 bits */
+ intel_bb_blit_start(ibb, 0);
+ intel_bb_out(ibb, (3 << 24) | /* 32 bits */
(0xcc << 16) | /* copy ROP */
(width * 4) /* dst pitch */);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(width * 4); /* src pitch */
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-
- drm_intel_bo_unreference(src_bo);
+ intel_bb_out(ibb, 0); /* dst x1,y1 */
+ intel_bb_out(ibb, (height << 16) | width); /* dst x2,y2 */
+ intel_bb_emit_reloc(ibb, dst_buf->handle, I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_RENDER, 0, dst_buf->addr.offset);
+ intel_bb_out(ibb, 0); /* src x1,y1 */
+ intel_bb_out(ibb, width * 4); /* src pitch */
+ intel_bb_emit_reloc(ibb, src_buf->handle, I915_GEM_DOMAIN_RENDER, 0, 0,
+ src_buf->addr.offset);
+
+ intel_bb_flush_blit(ibb);
}
int main(int argc, char **argv)
{
int fd;
- int object_size = OBJECT_WIDTH * OBJECT_HEIGHT * 4;
double start_time, end_time;
- drm_intel_bo *dst_bo;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct intel_buf *src_buf, *dst_buf;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
int i;
fd = drm_open_driver(DRIVER_INTEL);
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ bops = buf_ops_create(fd);
- batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
+ ibb = intel_bb_create(fd, 4096);
- dst_bo = drm_intel_bo_alloc(bufmgr, "dst", object_size, 4096);
+ dst_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
+ src_buf = intel_buf_create(bops, OBJECT_WIDTH, OBJECT_HEIGHT, 32, 4096,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
/* Prep loop to get us warmed up. */
for (i = 0; i < 20; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
/* Do the actual timing. */
start_time = get_time_in_secs();
for (i = 0; i < 1000; i++) {
- do_render(bufmgr, batch, dst_bo, OBJECT_WIDTH, OBJECT_HEIGHT);
+ do_render(fd, ibb, src_buf, dst_buf,
+ OBJECT_WIDTH, OBJECT_HEIGHT);
}
- drm_intel_bo_wait_rendering(dst_bo);
+ intel_bb_sync(ibb);
end_time = get_time_in_secs();
printf("%d iterations in %.03f secs: %.01f MB/sec\n", i,
@@ -157,8 +157,10 @@ int main(int argc, char **argv)
(double)i * OBJECT_WIDTH * OBJECT_HEIGHT * 4 / 1024.0 / 1024.0 /
(end_time - start_time));
- intel_batchbuffer_free(batch);
- drm_intel_bufmgr_destroy(bufmgr);
+ intel_buf_destroy(src_buf);
+ intel_buf_destroy(dst_buf);
+ intel_bb_destroy(ibb);
+ buf_ops_destroy(bops);
close(fd);
--
2.20.1
More information about the igt-dev
mailing list