From: "Maíra Canal" <mcanal@igalia.com>
To: "Melissa Wen" <mwen@igalia.com>,
"André Almeida" <andrealmeid@igalia.com>,
"Petri Latvala" <adrinael@adrinael.net>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Iago Toral Quiroga" <itoral@igalia.com>
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v4 3/3] tests/v3d_job_submission: Create tests to mix CL and CSD jobs
Date: Wed, 15 Feb 2023 11:27:38 -0300 [thread overview]
Message-ID: <20230215142738.1121229-4-mcanal@igalia.com> (raw)
In-Reply-To: <20230215142738.1121229-1-mcanal@igalia.com>
Add three subtests that combine CL jobs and CSD jobs, to assure the
proper synchronization of different queues, especially the
independence between them. Moreover, tests the relationship between
single syncobjs and multisync using mixed jobs as well.
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
tests/v3d/meson.build | 1 +
tests/v3d/v3d_job_submission.c | 223 +++++++++++++++++++++++++++++++++
tests/v3d_ci/v3d.testlist | 3 +
3 files changed, 227 insertions(+)
create mode 100644 tests/v3d/v3d_job_submission.c
diff --git a/tests/v3d/meson.build b/tests/v3d/meson.build
index d070fdb5..03b4de61 100644
--- a/tests/v3d/meson.build
+++ b/tests/v3d/meson.build
@@ -2,6 +2,7 @@ v3d_progs = [
'v3d_create_bo',
'v3d_get_bo_offset',
'v3d_get_param',
+ 'v3d_job_submission',
'v3d_mmap',
'v3d_submit_cl',
'v3d_submit_csd',
diff --git a/tests/v3d/v3d_job_submission.c b/tests/v3d/v3d_job_submission.c
new file mode 100644
index 00000000..d6e415bb
--- /dev/null
+++ b/tests/v3d/v3d_job_submission.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Igalia S.L.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+#include "igt_syncobj.h"
+
+static int fd;
+
+IGT_TEST_DESCRIPTION("Tests that combines Command List (CL) and Compute Shader Dispatch (CSD) jobs.");
+
+/* Number of Command List (CL) jobs to be submitted. */
+#define NUM_CL_JOBS 1000
+
+/* Number of Compute Shader Dispatch (CSD) jobs to be submitted. */
+#define NUM_CSD_JOBS 250
+
+static int syncobj_wait_array(uint32_t *handles, uint32_t count)
+{
+ int i, ret = 0;
+
+ for (i = 0; i < count; i++) {
+ ret = syncobj_wait_err(fd, &handles[i], 1, INT64_MAX, 0);
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
+static void *create_cl_jobs(void *args)
+{
+ struct v3d_cl_job **jobs = args;
+ int i;
+
+ for (i = 0; i < NUM_CL_JOBS; i++) {
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, jobs[i]->submit);
+ igt_assert(syncobj_wait(fd, &jobs[i]->submit->out_sync, 1,
+ INT64_MAX, 0, NULL));
+ }
+
+ return NULL;
+}
+
+static void *create_csd_jobs(void *args)
+{
+ struct v3d_csd_job **jobs = args;
+ int i;
+
+ for (i = 0; i < NUM_CSD_JOBS; i++) {
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CSD, jobs[i]->submit);
+ igt_assert(syncobj_wait(fd, &jobs[i]->submit->out_sync, 1,
+ INT64_MAX, 0, NULL));
+ }
+
+ return NULL;
+}
+
+igt_main
+{
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_V3D);
+ igt_require(igt_v3d_get_param(fd, DRM_V3D_PARAM_SUPPORTS_CSD));
+ igt_require(igt_v3d_get_param(fd, DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT));
+ }
+
+ igt_describe("Test if the out-sync of an array of mixed jobs is behaving correctly.");
+ igt_subtest("array-job-submission") {
+ uint32_t handles[4];
+ struct v3d_cl_job *cl_jobs[2];
+ struct v3d_csd_job *csd_jobs[2];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(handles); i++)
+ handles[i] = syncobj_create(fd, 0);
+
+ for (i = 0; i < 2; i++) {
+ cl_jobs[i] = igt_v3d_noop_job(fd);
+ csd_jobs[i] = igt_v3d_empty_shader(fd);
+ }
+
+ cl_jobs[0]->submit->out_sync = handles[0];
+ csd_jobs[0]->submit->out_sync = handles[1];
+ cl_jobs[1]->submit->out_sync = handles[2];
+ csd_jobs[1]->submit->out_sync = handles[3];
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, cl_jobs[0]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[0]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, cl_jobs[1]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[1]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), 0);
+
+ for (i = 0; i < 2; i++) {
+ igt_v3d_free_cl_job(fd, cl_jobs[i]);
+ igt_v3d_free_csd_job(fd, csd_jobs[i]);
+ }
+ }
+
+ igt_describe("Test if multiple singlesyncs have the same behaviour as one multisync.");
+ igt_subtest("multiple-singlesync-to-multisync") {
+ struct drm_v3d_multi_sync ms = { 0 };
+ uint32_t handles[4];
+ struct v3d_cl_job *cl_jobs[2];
+ struct v3d_csd_job *csd_jobs[2];
+ struct drm_v3d_sem *in_syncs, *out_syncs;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(handles); i++)
+ handles[i] = syncobj_create(fd, 0);
+
+ for (i = 0; i < 2; i++) {
+ cl_jobs[i] = igt_v3d_noop_job(fd);
+ csd_jobs[i] = igt_v3d_empty_shader(fd);
+ }
+
+ cl_jobs[0]->submit->out_sync = handles[0];
+ csd_jobs[0]->submit->out_sync = handles[1];
+ cl_jobs[1]->submit->out_sync = handles[2];
+
+ igt_v3d_set_multisync(&ms, V3D_CSD);
+ ms.in_sync_count = 3;
+ ms.out_sync_count = 1;
+
+ in_syncs = malloc(ms.in_sync_count * sizeof(*in_syncs));
+ out_syncs = malloc(ms.out_sync_count * sizeof(*in_syncs));
+
+ for (i = 0; i < ms.in_sync_count; i++)
+ in_syncs[i].handle = handles[i];
+
+ out_syncs[0].handle = handles[3];
+
+ ms.in_syncs = to_user_pointer(in_syncs);
+ ms.out_syncs = to_user_pointer(out_syncs);
+
+ csd_jobs[1]->submit->flags = DRM_V3D_SUBMIT_EXTENSION;
+ csd_jobs[1]->submit->extensions = to_user_pointer(&ms);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, cl_jobs[0]->submit);
+
+ do_ioctl_err(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[1]->submit, EINVAL);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[0]->submit);
+
+ do_ioctl_err(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[1]->submit, EINVAL);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, cl_jobs[1]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), -EINVAL);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CSD, csd_jobs[1]->submit);
+ igt_assert_eq(syncobj_wait_array(handles, ARRAY_SIZE(handles)), 0);
+
+ for (i = 0; i < 2; i++) {
+ igt_v3d_free_cl_job(fd, cl_jobs[i]);
+ igt_v3d_free_csd_job(fd, csd_jobs[i]);
+ }
+ }
+
+ igt_describe("Test if all queues are progressing independently.");
+ igt_subtest("threaded-job-submission") {
+ struct v3d_cl_job **cl_jobs = NULL;
+ struct v3d_csd_job **csd_jobs = NULL;
+ pthread_t *threads[2];
+ int i, ret;
+
+ cl_jobs = malloc(NUM_CL_JOBS * sizeof(*cl_jobs));
+ csd_jobs = malloc(NUM_CSD_JOBS * sizeof(*csd_jobs));
+
+ for (i = 0; i < NUM_CL_JOBS; i++) {
+ igt_print_activity();
+
+ cl_jobs[i] = igt_v3d_noop_job(fd);
+ cl_jobs[i]->submit->out_sync = syncobj_create(fd,
+ DRM_SYNCOBJ_CREATE_SIGNALED);
+ }
+
+ for (i = 0; i < NUM_CSD_JOBS; i++) {
+ igt_print_activity();
+
+ csd_jobs[i] = igt_v3d_empty_shader(fd);
+ csd_jobs[i]->submit->out_sync = syncobj_create(fd,
+ DRM_SYNCOBJ_CREATE_SIGNALED);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(threads); i++) {
+ threads[i] = malloc(sizeof(*threads[i]));
+ igt_assert(threads[i]);
+ }
+
+ ret = pthread_create(threads[0], NULL, &create_cl_jobs, cl_jobs);
+ igt_assert_eq(ret, 0);
+
+ ret = pthread_create(threads[1], NULL, &create_csd_jobs, csd_jobs);
+ igt_assert_eq(ret, 0);
+
+ for (i = 0; i < ARRAY_SIZE(threads); i++)
+ pthread_join(*threads[i], NULL);
+
+ for (i = 0; i < NUM_CL_JOBS; i++)
+ igt_v3d_free_cl_job(fd, cl_jobs[i]);
+
+ for (i = 0; i < NUM_CSD_JOBS; i++)
+ igt_v3d_free_csd_job(fd, csd_jobs[i]);
+
+ for (i = 0; i < ARRAY_SIZE(threads); i++)
+ free(threads[i]);
+
+ free(cl_jobs);
+ free(csd_jobs);
+ }
+
+ igt_fixture
+ close(fd);
+}
diff --git a/tests/v3d_ci/v3d.testlist b/tests/v3d_ci/v3d.testlist
index 5452fd99..106e9cf2 100644
--- a/tests/v3d_ci/v3d.testlist
+++ b/tests/v3d_ci/v3d.testlist
@@ -7,6 +7,9 @@ igt@v3d/v3d_get_bo_offset@get-bad-handle
igt@v3d/v3d_get_param@base-params
igt@v3d/v3d_get_param@get-bad-param
igt@v3d/v3d_get_param@get-bad-flags
+igt@v3d/v3d_job_submission@array-job-submission
+igt@v3d/v3d_job_submission@multiple-singlesync-to-multisync
+igt@v3d/v3d_job_submission@threaded-job-submission
igt@v3d/v3d_mmap@mmap-bad-flags
igt@v3d/v3d_mmap@mmap-bad-handle
igt@v3d/v3d_mmap@mmap-bo
--
2.39.1
next prev parent reply other threads:[~2023-02-15 14:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 14:27 [igt-dev] [PATCH i-g-t v4 0/3] V3D Mixed Job Submission Tests Maíra Canal
2023-02-15 14:27 ` [igt-dev] [PATCH i-g-t v4 1/3] lib/v3d: Add a helper to create a empty shader Maíra Canal
2023-02-15 14:27 ` [igt-dev] [PATCH i-g-t v4 2/3] tests/v3d_submit_csd: Create test for V3D's Submit CSD IOCTL Maíra Canal
2023-02-15 14:27 ` Maíra Canal [this message]
2023-02-15 17:15 ` [igt-dev] ✓ Fi.CI.BAT: success for V3D Mixed Job Submission Tests (rev5) Patchwork
2023-02-16 11:34 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230215142738.1121229-4-mcanal@igalia.com \
--to=mcanal@igalia.com \
--cc=adrinael@adrinael.net \
--cc=andrealmeid@igalia.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=itoral@igalia.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=mwen@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox