From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH igt] benchmark/gem_busy: Compare polling with syncobj_wait
Date: Thu, 12 Oct 2017 10:53:13 +0100 [thread overview]
Message-ID: <543555ff-5696-e8ba-a787-18c1f9cde562@linux.intel.com> (raw)
In-Reply-To: <20171006190119.24808-1-chris@chris-wilson.co.uk>
On 06/10/2017 20:01, Chris Wilson wrote:
> v2: Hook the syncobj array to the execbuf!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> benchmarks/gem_busy.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 74 insertions(+), 1 deletion(-)
>
> diff --git a/benchmarks/gem_busy.c b/benchmarks/gem_busy.c
> index f050454b..ce631d56 100644
> --- a/benchmarks/gem_busy.c
> +++ b/benchmarks/gem_busy.c
> @@ -58,6 +58,15 @@
> #define DMABUF 0x4
> #define WAIT 0x8
> #define SYNC 0x10
> +#define SYNCOBJ 0x20
> +
> +#define LOCAL_I915_EXEC_FENCE_ARRAY (1 << 19)
> +struct local_gem_exec_fence {
> + uint32_t handle;
> + uint32_t flags;
> +#define LOCAL_EXEC_FENCE_WAIT (1 << 0)
> +#define LOCAL_EXEC_FENCE_SIGNAL (1 << 1)
> +};
>
> static void gem_busy(int fd, uint32_t handle)
> {
> @@ -109,11 +118,54 @@ static int sync_merge(int fd1, int fd2)
> return data.fence;
> }
>
> +static uint32_t __syncobj_create(int fd)
> +{
> + struct local_syncobj_create {
> + uint32_t handle, flags;
> + } arg;
> +#define LOCAL_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct local_syncobj_create)
> +
> + memset(&arg, 0, sizeof(arg));
> + ioctl(fd, LOCAL_IOCTL_SYNCOBJ_CREATE, &arg);
> +
> + return arg.handle;
> +}
> +
> +static uint32_t syncobj_create(int fd)
> +{
> + uint32_t ret;
> +
> + igt_assert_neq((ret = __syncobj_create(fd)), 0);
> +
> + return ret;
> +}
> +
> +#define LOCAL_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
> +#define LOCAL_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
> +struct local_syncobj_wait {
> + __u64 handles;
> + /* absolute timeout */
> + __s64 timeout_nsec;
> + __u32 count_handles;
> + __u32 flags;
> + __u32 first_signaled; /* only valid when not waiting all */
> + __u32 pad;
> +};
> +#define LOCAL_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct local_syncobj_wait)
> +static int __syncobj_wait(int fd, struct local_syncobj_wait *args)
> +{
> + int err = 0;
> + if (drmIoctl(fd, LOCAL_IOCTL_SYNCOBJ_WAIT, args))
> + err = -errno;
> + return err;
> +}
> +
> static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
> {
> struct drm_i915_gem_execbuffer2 execbuf;
> struct drm_i915_gem_exec_object2 obj[2];
> struct drm_i915_gem_relocation_entry reloc[2];
> + struct local_gem_exec_fence syncobj;
> unsigned engines[16];
> unsigned nengine;
> uint32_t *batch;
> @@ -150,6 +202,15 @@ static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
> return 77;
> }
>
> + if (flags & SYNCOBJ) {
> + syncobj.handle = syncobj_create(fd);
> + syncobj.flags = LOCAL_EXEC_FENCE_SIGNAL;
> +
> + execbuf.cliprects_ptr = (uintptr_t)&syncobj;
to_user_pointer if you want.
> + execbuf.num_cliprects = 1;
> + execbuf.flags |= LOCAL_I915_EXEC_FENCE_ARRAY;
> + }
> +
> if (ring == -1) {
> nengine = 0;
> for (ring = 1; ring < 16; ring++) {
> @@ -235,6 +296,14 @@ static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
> struct pollfd pfd = { .fd = dmabuf, .events = POLLOUT };
> for (int inner = 0; inner < 1024; inner++)
> poll(&pfd, 1, 0);
> + } else if (flags & SYNCOBJ) {
> + struct local_syncobj_wait arg = {
> + .handles = to_user_pointer(&syncobj.handle),
> + .count_handles = 1,
> + };
> +
> + for (int inner = 0; inner < 1024; inner++)
> + __syncobj_wait(fd, &arg);
> } else if (flags & SYNC) {
> struct pollfd pfd = { .fd = fence, .events = POLLOUT };
> for (int inner = 0; inner < 1024; inner++)
> @@ -275,7 +344,7 @@ int main(int argc, char **argv)
> int ncpus = 1;
> int c;
>
> - while ((c = getopt (argc, argv, "e:r:dfswWI")) != -1) {
> + while ((c = getopt (argc, argv, "e:r:dfsSwWI")) != -1) {
> switch (c) {
> case 'e':
> if (strcmp(optarg, "rcs") == 0)
> @@ -314,6 +383,10 @@ int main(int argc, char **argv)
> flags |= SYNC;
> break;
>
> + case 'S':
> + flags |= SYNCOBJ;
> + break;
> +
> case 'W':
> flags |= WRITE;
> break;
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-10-12 9:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 19:01 [PATCH igt] benchmark/gem_busy: Compare polling with syncobj_wait Chris Wilson
2017-10-06 19:24 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-10-07 4:36 ` ✗ Fi.CI.IGT: warning " Patchwork
2017-10-12 9:53 ` Tvrtko Ursulin [this message]
2017-10-12 11:34 ` [PATCH igt] " Chris Wilson
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=543555ff-5696-e8ba-a787-18c1f9cde562@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/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