From: "Ser, Simon" <simon.ser@intel.com>
To: "guillaume.tucker@collabora.com" <guillaume.tucker@collabora.com>,
"Hiler, Arkadiusz" <arkadiusz.hiler@intel.com>,
"Latvala, Petri" <petri.latvala@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t v2 4/4] tests/sw_sync: use atomic_* instead of __sync_*
Date: Fri, 14 Jun 2019 08:12:49 +0000 [thread overview]
Message-ID: <f8cfd4fd52c7176643968e2e23295ef0224e887a.camel@intel.com> (raw)
In-Reply-To: <737b847e6518b74fe57de3e309b5a4ede719ea72.1560433744.git.guillaume.tucker@collabora.com>
On Thu, 2019-06-13 at 14:53 +0100, Guillaume Tucker wrote:
> Replace calls to the older __sync_* functions with the new atomic_*
> standard ones to be consistent with other tests and improve
> portability across CPU architectures. Add dependency of sw_sync on
> libatomic.
>
> Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Reviewed-by: Simon Ser <simon.ser@intel.com>
Thanks!
> ---
> tests/Makefile.am | 1 +
> tests/meson.build | 8 +++++++-
> tests/sw_sync.c | 12 ++++++------
> 3 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index bbd386c9c2db..7d71df8c7a2e 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -122,6 +122,7 @@ prime_self_import_LDADD = $(LDADD) -lpthread
> gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
> gem_userptr_blits_LDADD = $(LDADD) -lpthread
> perf_pmu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
> +sw_sync_LDADD = $(LDADD) -latomic
>
> kms_flip_LDADD = $(LDADD) -lpthread
>
> diff --git a/tests/meson.build b/tests/meson.build
> index ffd432d38193..34a74025a537 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -76,7 +76,6 @@ test_progs = [
> 'prime_self_import',
> 'prime_udl',
> 'prime_vgem',
> - 'sw_sync',
> 'syncobj_basic',
> 'syncobj_wait',
> 'template',
> @@ -329,6 +328,13 @@ executable('testdisplay', ['testdisplay.c',
> 'testdisplay_hotplug.c'],
> install : true)
> test_list += 'testdisplay'
>
> +test_executables += executable('sw_sync', 'sw_sync.c',
> + dependencies : test_deps + [ libatomic ],
> + install_dir : libexecdir,
> + install_rpath : libexecdir_rpathdir,
> + install : true)
> +test_list += 'sw_sync'
> +
> subdir('amdgpu')
>
> gen_testlist = find_program('generate_testlist.sh')
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index 950b8b614759..62d1d17cab45 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -26,6 +26,7 @@
>
> #include <pthread.h>
> #include <semaphore.h>
> +#include <stdatomic.h>
> #include <stdint.h>
> #include <sys/socket.h>
> #include <sys/types.h>
> @@ -43,7 +44,7 @@ IGT_TEST_DESCRIPTION("Test SW Sync Framework");
> typedef struct {
> int timeline;
> uint32_t thread_id;
> - uint32_t *counter;
> + _Atomic(uint32_t) *counter;
> sem_t *sem;
> } data_t;
>
> @@ -489,7 +490,7 @@ static void test_sync_multi_consumer(void)
> pthread_t thread_arr[MULTI_CONSUMER_THREADS];
> sem_t sem;
> int timeline;
> - uint32_t counter = 0;
> + _Atomic(uint32_t) counter = 0;
> uintptr_t thread_ret = 0;
> data_t data;
> int i, ret;
> @@ -517,7 +518,7 @@ static void test_sync_multi_consumer(void)
> {
> sem_wait(&sem);
>
> - __sync_fetch_and_add(&counter, 1);
> + atomic_fetch_add(&counter, 1);
> sw_sync_timeline_inc(timeline, 1);
> }
>
> @@ -554,7 +555,7 @@ static void *
> test_sync_multi_consumer_producer_thread(void *arg)
> if (sync_fence_wait(fence, 1000) < 0)
> return (void *) 1;
>
> - if (__sync_fetch_and_add(data->counter, 1) !=
> next_point)
> + if (atomic_fetch_add(data->counter, 1) != next_point)
> return (void *) 1;
>
> /* Kick off the next thread. */
> @@ -570,7 +571,7 @@ static void
> test_sync_multi_consumer_producer(void)
> data_t data_arr[MULTI_CONSUMER_PRODUCER_THREADS];
> pthread_t thread_arr[MULTI_CONSUMER_PRODUCER_THREADS];
> int timeline;
> - uint32_t counter = 0;
> + _Atomic(uint32_t) counter = 0;
> uintptr_t thread_ret = 0;
> data_t data;
> int i, ret;
> @@ -900,4 +901,3 @@ igt_main
> igt_subtest("sync_random_merge")
> test_sync_random_merge();
> }
> -
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-06-14 8:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 13:53 [igt-dev] [PATCH i-g-t v2 0/4] Use C11 atomics Guillaume Tucker
2019-06-13 13:53 ` [Intel-gfx] [PATCH i-g-t v2 1/4] meson: add libatomic dependency Guillaume Tucker
2019-06-14 8:07 ` [igt-dev] " Ser, Simon
2019-06-18 8:33 ` Guillaume Tucker
2019-06-18 13:11 ` Ser, Simon
2019-06-13 13:53 ` [igt-dev] [PATCH i-g-t v2 2/4] gitlab-ci: add libatomic to docker images Guillaume Tucker
2019-06-14 8:08 ` Ser, Simon
2019-06-14 10:00 ` Petri Latvala
2019-06-14 11:24 ` Ser, Simon
2019-06-14 12:43 ` Petri Latvala
2019-06-14 12:53 ` [Intel-gfx] " Ser, Simon
2019-06-18 8:42 ` Guillaume Tucker
2019-06-13 13:53 ` [igt-dev] [PATCH i-g-t v2 3/4] i915/gem_create: use atomic_* instead of __sync_* Guillaume Tucker
2019-06-14 8:11 ` Ser, Simon
2019-06-13 13:53 ` [Intel-gfx] [PATCH i-g-t v2 4/4] tests/sw_sync: " Guillaume Tucker
2019-06-14 8:12 ` Ser, Simon [this message]
2019-06-13 16:33 ` [igt-dev] ✓ Fi.CI.BAT: success for Use C11 atomics Patchwork
2019-06-15 5:16 ` [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=f8cfd4fd52c7176643968e2e23295ef0224e887a.camel@intel.com \
--to=simon.ser@intel.com \
--cc=arkadiusz.hiler@intel.com \
--cc=guillaume.tucker@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=petri.latvala@intel.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