Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Melissa Wen <mwen@igalia.com>
To: "Maíra Canal" <mcanal@igalia.com>
Cc: Rob Clark <robdclark@chromium.org>,
	igt-dev@lists.freedesktop.org,
	Petri Latvala <petri.latvala@intel.com>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Iago Toral Quiroga <itoral@igalia.com>
Subject: Re: [igt-dev] [PATCH i-g-t 3/3] tests/v3d_job_submission: Create tests to mix CL and CSD jobs
Date: Wed, 8 Feb 2023 09:27:10 -0100	[thread overview]
Message-ID: <20230208102710.6aytohkwffaxpmtk@mail.igalia.com> (raw)
In-Reply-To: <20230113124453.196280-4-mcanal@igalia.com>

[-- Attachment #1: Type: text/plain, Size: 8707 bytes --]

On 01/13, Maíra Canal wrote:
> Add three igt_subtests that combine CL jobs and CSD jobs, to assure the
> proper synchronization of different queues, especially the
> independence between them. Moreover, it tests the relationship between
> single syncobjs and multisync using mixed jobs as well.
> 
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---
>  tests/v3d/meson.build          |   1 +
>  tests/v3d/v3d_job_submission.c | 212 +++++++++++++++++++++++++++++++++
>  tests/v3d_ci/v3d.testlist      |   3 +
>  3 files changed, 216 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..3050284c
> --- /dev/null
> +++ b/tests/v3d/v3d_job_submission.c
> @@ -0,0 +1,212 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2022 Igalia S.L.
> + */
> +
> +#include "igt.h"
> +#include "igt_v3d.h"
> +#include "igt_syncobj.h"
> +
> +static int fd;
> +
> +#define NUM_CL_JOBS  1000
> +#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") {

As this test takes longer than usual, can you add a progress bar here?
https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/blob/master/lib/igt_aux.c#L686

> +		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++) {
> +			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++) {
> +			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] != NULL);
> +		}
> +
> +		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.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-02-08 10:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 12:44 [igt-dev] [PATCH i-g-t 0/3] V3D Mixed Job Submission Tests Maíra Canal
2023-01-13 12:44 ` [igt-dev] [PATCH i-g-t 1/3] lib/v3d: Add a helper to create a empty shader Maíra Canal
2023-02-10 13:31   ` Kamil Konieczny
2023-01-13 12:44 ` [igt-dev] [PATCH i-g-t 2/3] tests/v3d_submit_csd: Create test for V3D's Submit CSD IOCTL Maíra Canal
2023-01-13 12:44 ` [igt-dev] [PATCH i-g-t 3/3] tests/v3d_job_submission: Create tests to mix CL and CSD jobs Maíra Canal
2023-02-08 10:27   ` Melissa Wen [this message]
2023-01-13 13:23 ` [igt-dev] ✗ Fi.CI.BUILD: failure for V3D Mixed Job Submission Tests Patchwork
2023-02-07 14:17 ` [igt-dev] ✓ Fi.CI.BAT: success for V3D Mixed Job Submission Tests (rev2) Patchwork
2023-02-07 16:11 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-02-08 10:31 ` [igt-dev] [PATCH i-g-t 0/3] V3D Mixed Job Submission Tests Melissa Wen

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=20230208102710.6aytohkwffaxpmtk@mail.igalia.com \
    --to=mwen@igalia.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=itoral@igalia.com \
    --cc=mcanal@igalia.com \
    --cc=petri.latvala@intel.com \
    --cc=robdclark@chromium.org \
    --cc=tomeu.vizoso@collabora.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