From patchwork Thu Jun 13 13:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 10991905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50EA514C0 for ; Thu, 13 Jun 2019 13:54:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8221FE6B for ; Thu, 13 Jun 2019 13:54:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 341AD1FF7F; Thu, 13 Jun 2019 13:54:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D0A3A1FF30 for ; Thu, 13 Jun 2019 13:54:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE37789AA2; Thu, 13 Jun 2019 13:54:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80C3C89A8B; Thu, 13 Jun 2019 13:54:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id 33518283E73 From: Guillaume Tucker To: Arkadiusz Hiler , Petri Latvala Date: Thu, 13 Jun 2019 14:53:22 +0100 Message-Id: <737b847e6518b74fe57de3e309b5a4ede719ea72.1560433744.git.guillaume.tucker@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 4/4] tests/sw_sync: use atomic_* instead of __sync_* X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Simon Ser --- 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 #include +#include #include #include #include @@ -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(); } -