From patchwork Wed Sep 2 10:22:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1355653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhKkk2CLJz9sTN for ; Wed, 2 Sep 2020 20:22:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 03399386EC47; Wed, 2 Sep 2020 10:22:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 613233857C48 for ; Wed, 2 Sep 2020 10:22:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 613233857C48 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1AA8EB6AF; Wed, 2 Sep 2020 10:22:31 +0000 (UTC) Subject: [RFC][nvptx, libgomp] Add 128-bit atomic support From: Tom de Vries To: Tobias Burnus , GCC Patches , Jakub Jelinek References: <3cbe58e6-b427-ff0d-b7d1-8723aac82b18@codesourcery.com> <7d824fcc-cacf-6ad3-578d-1dc71243ed8a@suse.de> <8097cf6c-0044-77e6-d216-2abd63779754@codesourcery.com> <3694266b-47ae-4c51-a40c-09bcff5c8ada@suse.de> <0162d4b1-fe2a-a670-7a39-6fcef4dae19a@codesourcery.com> <30032d02-e9a8-d084-788f-c0791a49fb8e@suse.de> <8669d1a0-65f5-e5f4-bd5a-821f8db9e545@suse.de> Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAh CRDuhV2rbOJEoBYhBKydJ7mEpsswrWYaaO6FXats4kSgc48H/Ra2lq5p3dHsrlQLqM7N68Fo eRDf3PMevXyMlrCYDGLVncQwMw3O/AkousktXKQ42DPJh65zoXB22yUt8m0g12xkLax98KFJ 5NyUloa6HflLl+wQL/uZjIdNUQaHQLw3HKwRMVi4l0/Jh/TygYG1Dtm8I4o708JS4y8GQxoQ UL0z1OM9hyM3gI2WVTTyprsBHy2EjMOu/2Xpod95pF8f90zBLajy6qXEnxlcsqreMaqmkzKn 3KTZpWRxNAS/IH3FbGQ+3RpWkNGSJpwfEMVCeyK5a1n7yt1podd1ajY5mA1jcaUmGppqx827 8TqyteNe1B/pbiUt2L/WhnTgW1NC1QDOwE0EXSW0JwEIAM99H34Bu4MKM7HDJVt864MXbx7B 1M93wVlpJ7Uq+XDFD0A0hIal028j+h6jA6bhzWto4RUfDl/9mn1StngNVFovvwtfzbamp6+W pKHZm9X5YvlIwCx131kTxCNDcF+/adRW4n8CU3pZWYmNVqhMUiPLxElA6QhXTtVBh1RkjCZQ Kmbd1szvcOfaD8s+tJABJzNZsmO2hVuFwkDrRN8Jgrh92a+yHQPd9+RybW2l7sJv26nkUH5Z 5s84P6894ebgimcprJdAkjJTgprl1nhgvptU5M9Uv85Pferoh2groQEAtRPlCGrZ2/2qVNe9 XJfSYbiyedvApWcJs5DOByTaKkcAEQEAAcLAkwQYAQgAJhYhBKydJ7mEpsswrWYaaO6FXats 4kSgBQJdJbQnAhsMBQkDwmcAACEJEO6FXats4kSgFiEErJ0nuYSmyzCtZhpo7oVdq2ziRKD3 twf7BAQBZ8TqR812zKAD7biOnWIJ0McV72PFBxmLIHp24UVe0ZogtYMxSWKLg3csh0yLVwc7 H3vldzJ9AoK3Qxp0Q6K/rDOeUy3HMqewQGcqrsRRh0NXDIQk5CgSrZslPe47qIbe3O7ik/MC q31FNIAQJPmKXX25B115MMzkSKlv4udfx7KdyxHrTSkwWZArLQiEZj5KG4cCKhIoMygPTA3U yGaIvI/BGOtHZ7bEBVUCFDFfOWJ26IOCoPnSVUvKPEOH9dv+sNy7jyBsP5QxeTqwxC/1ZtNS DUCSFQjqA6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <9cde09ef-8a7f-fbc7-3677-fb6763cc82b4@suse.de> Date: Wed, 2 Sep 2020 12:22:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8669d1a0-65f5-e5f4-bd5a-821f8db9e545@suse.de> Content-Language: en-US X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Schwinge , Segher Boessenkool Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" [ was: Re: [patch][nvptx] libgomp: Split testcase in order to XFAIL __sync_val_compare_and_swap_16 (was: [PATCH] nvptx: Add support for subword compare-and-swap) ] On 9/2/20 9:56 AM, Tom de Vries wrote: > On 9/1/20 2:58 PM, Tom de Vries wrote: >> On 9/1/20 1:41 PM, Tobias Burnus wrote: >>> Hi Tom, hello all, >>> >>> it turned out that the testcase fails on PowerPC (but not x86_64) >>> as the nvptx lto complains: unresolved symbol >>> __sync_val_compare_and_swap_16 >>> >>> The testcase uses int128 – and that's the culprit, but I have no idea >>> why it only fails with PowerPC and not with x86-64. >>> >> > > Reproduced on x86_64 using trigger patch: > ... > $ git diff > diff --git a/gcc/config/i386/sync.md b/gcc/config/i386/sync.md > index ed17bb00205..eccedac192f 100644 > --- a/gcc/config/i386/sync.md > +++ b/gcc/config/i386/sync.md > @@ -153,9 +153,15 @@ > (DI "TARGET_64BIT || (TARGET_CMPXCHG8B && (TARGET_80387 || > TARGET_SSE))") > ]) > > + (define_mode_iterator ATOMIC2 > + [QI HI SI > + (DI "TARGET_64BIT || (TARGET_CMPXCHG8B && (TARGET_80387 || > TARGET_SSE))") > + TI > + ]) > + > (define_expand "atomic_load" > - [(set (match_operand:ATOMIC 0 "nonimmediate_operand") > - (unspec:ATOMIC [(match_operand:ATOMIC 1 "memory_operand") > + [(set (match_operand:ATOMIC2 0 "nonimmediate_operand") > + (unspec:ATOMIC2 [(match_operand:ATOMIC2 1 "memory_operand") > (match_operand:SI 2 "const_int_operand")] > UNSPEC_LDA))] > "" > diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c > b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c > index d0e82b04790..62b0e032c33 100644 > --- a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c > +++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c > @@ -1,4 +1,5 @@ > /* { dg-do run } */ > +/* { dg-additional-options "-mcx16" } */ > > #include > > ... > And test-case passes on x86_64 with this patch (obviously, in combination with trigger patch above). Jakub, WDYT? Tobias, can you try on powerpc? Thanks, - Tom [nvptx, libgomp] Add 128-bit atomic support --- libgomp/config/nvptx/atomic.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libgomp/config/nvptx/atomic.c b/libgomp/config/nvptx/atomic.c new file mode 100644 index 00000000000..49a6d350827 --- /dev/null +++ b/libgomp/config/nvptx/atomic.c @@ -0,0 +1,34 @@ +#include + +#include "../../atomic.c" + +unsigned __int128 +__sync_val_compare_and_swap_16 (volatile void *vptr, unsigned __int128 oldval, + unsigned __int128 newval) +{ + volatile unsigned __int128 *ptr = vptr; + GOMP_atomic_start (); + unsigned __int128 val = *ptr; + if (val == oldval) + *ptr = newval; + GOMP_atomic_end (); + return val; +} + +bool +__sync_bool_compare_and_swap_16 (volatile void *vptr, unsigned __int128 oldval, + unsigned __int128 newval) +{ + return __sync_val_compare_and_swap_16 (vptr, oldval, newval) == oldval; +} + +unsigned __int128 +__atomic_load_16 (const volatile void *vptr, + int memorder __attribute__((unused))) +{ + const volatile unsigned __int128 *ptr = vptr; + GOMP_atomic_start (); + unsigned __int128 val = *ptr; + GOMP_atomic_end (); + return val; +}