From: Eric Engestrom <eric@engestrom.ch>
To: robert.foss@collabora.com
Cc: Daniel Stone <daniels@collabora.com>,
intel-gfx@lists.freedesktop.org,
Gustavo Padovan <gustavo.padovan@collabora.com>,
mesa-dev@lists.freedesktop.org
Subject: Re: [PATCH v1 11/13] tests/sw_sync: Add subtest test_sync_random_merge
Date: Tue, 23 Aug 2016 23:38:43 +0100 [thread overview]
Message-ID: <20160823223842.GC5972@engestrom.ch> (raw)
In-Reply-To: <1471974975-11531-12-git-send-email-robert.foss@collabora.com>
On Tue, Aug 23, 2016 at 01:56:13PM -0400, robert.foss@collabora.com wrote:
> From: Robert Foss <robert.foss@collabora.com>
>
> This subtest verifies that creating many timelines and merging random fences
> from each timeline with eachother results in merged fences that are fully
> functional.
>
> Signed-off-by: Robert Foss <robert.foss@collabora.com>
> ---
> tests/sw_sync.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 73 insertions(+)
>
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index 0e67ad5..8e5a7c9 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -383,6 +383,76 @@ static void test_sync_multi_consumer_producer(void)
> igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");
> }
>
> +static void test_sync_random_merge(void)
> +{
> + int i, size, ret;
> + const int nbr_timeline = 32;
> + const int nbr_merge = 1024;
> + int fence_map[nbr_timeline];
> + int timeline_arr[nbr_timeline];
> + int fence, tmpfence, merged;
> + int timeline, timeline_offset, sync_pt;
> +
> + srand(time(NULL));
> +
> + for (i = 0; i < nbr_timeline; i++)
> + timeline_arr[i] = sw_sync_timeline_create();
> +
> + memset(fence_map, -1, sizeof(fence_map));
This sets each byte to -1, which happens to be the same as an int -1,
but I don't really like it: this is only true for two special values, -1
and 0, and would become a bug if it was ever changed.
I'd much prefer if you simply set:
fence_map[i] = -1;
in the loop you already have just above.
BTW, seeing how many times you set and test for -1 as the "invalid fd
sentinel", how about a:
#define INVALID_FD (-1)
and use that token throughout the code? I think it would improve
readability as well
> +
> + sync_pt = rand();
> + fence = sw_sync_fence_create(timeline_arr[0], sync_pt);
> +
> + fence_map[0] = sync_pt;
> +
> + /* Randomly create syncpoints out of a fixed set of timelines,
> + * and merge them together.
> + */
> + for (i = 0; i < nbr_merge; i++) {
> + /* Generate syncpoint. */
> + timeline_offset = rand() % nbr_timeline;
> + timeline = timeline_arr[timeline_offset];
> + sync_pt = rand();
> +
> + /* Keep track of the latest sync_pt in each timeline. */
> + if (fence_map[timeline_offset] == -1)
> + fence_map[timeline_offset] = sync_pt;
> + else if (fence_map[timeline_offset] < sync_pt)
> + fence_map[timeline_offset] = sync_pt;
> +
> + /* Merge. */
> + tmpfence = sw_sync_fence_create(timeline, sync_pt);
> + merged = sw_sync_merge(tmpfence, fence);
> + sw_sync_fence_destroy(tmpfence);
> + sw_sync_fence_destroy(fence);
> + fence = merged;
> + }
> +
> + size = 0;
> + for (i = 0; i < nbr_timeline; i++)
> + if (fence_map[i] != -1)
> + size++;
> +
> + /* Trigger the merged fence. */
> + for (i = 0; i < nbr_timeline; i++) {
> + if (fence_map[i] != -1) {
> + ret = sw_sync_wait(fence, 0);
> + igt_assert_f(ret == 0,
> + "Failure waiting on fence until timeout\n");
> + /* Increment the timeline to the last sync_pt */
> + sw_sync_timeline_inc(timeline_arr[i], fence_map[i]);
> + }
> + }
> +
> + /* Check that the fence is triggered. */
> + ret = sw_sync_wait(fence, 0);
> + igt_assert_f(ret > 0, "Failure triggering fence\n");
> +
> + sw_sync_fence_destroy(fence);
> + for (i = 0; i < nbr_timeline; i++)
> + sw_sync_timeline_destroy(timeline_arr[i]);
> +}
> +
> igt_main
> {
> igt_subtest("alloc_timeline")
> @@ -411,5 +481,8 @@ igt_main
>
> igt_subtest("sync_multi_consumer_producer")
> test_sync_multi_consumer_producer();
> +
> + igt_subtest("sync_random_merge")
> + test_sync_random_merge();
> }
>
> --
> 2.7.4
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
next prev parent reply other threads:[~2016-08-23 22:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 17:56 [PATCH v1 00/13] Implement sw_sync test robert.foss
2016-08-23 17:56 ` [PATCH v1 01/13] lib/sw_sync: Add helper functions for managing synchronization primitives robert.foss
2016-08-23 22:05 ` [Mesa-dev] " Eric Engestrom
2016-08-23 17:56 ` [PATCH v1 02/13] tests/sw_sync: Add sw_sync test robert.foss
2016-08-23 22:12 ` [Mesa-dev] " Eric Engestrom
2016-08-23 17:56 ` [PATCH v1 03/13] tests/sw_sync: Add subtest test_alloc_fence robert.foss
2016-08-23 17:56 ` [PATCH v1 04/13] tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline robert.foss
2016-08-23 17:56 ` [PATCH v1 05/13] tests/sw_sync: Add subtest test_alloc_merge_fence robert.foss
2016-08-23 17:56 ` [PATCH v1 06/13] tests/sw_sync: Add subtest test_sync_wait robert.foss
2016-08-23 17:56 ` [PATCH v1 07/13] tests/sw_sync: Add subtest test_sync_merge robert.foss
2016-08-23 17:56 ` [PATCH v1 08/13] tests/sw_sync: Add subtest test_sync_merge_same robert.foss
2016-08-23 17:56 ` [PATCH v1 09/13] tests/sw_sync: Add subtest test_sync_multi_consumer robert.foss
2016-08-23 17:56 ` [PATCH v1 10/13] tests/sw_sync: Add subtest test_sync_multi_consumer_producer robert.foss
2016-08-23 17:56 ` [PATCH v1 11/13] tests/sw_sync: Add subtest test_sync_random_merge robert.foss
2016-08-23 22:38 ` Eric Engestrom [this message]
2016-08-23 17:56 ` [PATCH v1 12/13] tests/sw_sync: Add subtest test_sync_multi_timeline_wait robert.foss
2016-08-23 17:56 ` [PATCH v1 13/13] tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer robert.foss
2016-08-23 22:56 ` [Mesa-dev] [PATCH v1 00/13] Implement sw_sync test Eric Engestrom
2016-08-24 20:27 ` Robert Foss
2016-08-24 6:01 ` Daniel Vetter
2016-08-24 13:51 ` Robert Foss
2016-08-24 20:41 ` Gustavo Padovan
2016-08-25 6:56 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2016-08-23 17:53 robert.foss
2016-08-23 17:53 ` [PATCH v1 11/13] tests/sw_sync: Add subtest test_sync_random_merge robert.foss
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=20160823223842.GC5972@engestrom.ch \
--to=eric@engestrom.ch \
--cc=daniels@collabora.com \
--cc=gustavo.padovan@collabora.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mesa-dev@lists.freedesktop.org \
--cc=robert.foss@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