From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id CA9253858409 for ; Thu, 6 Jan 2022 17:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CA9253858409 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B8B671F37F; Thu, 6 Jan 2022 17:53:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9620613C63; Thu, 6 Jan 2022 17:53:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XmQZI34s12FJLwAAMHmgww (envelope-from ); Thu, 06 Jan 2022 17:53:02 +0000 Message-ID: <3e39c39d-2753-f08c-5fb7-85051cafab85@suse.de> Date: Thu, 6 Jan 2022 18:53:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] libgomp, OpenMP, nvptx: Low-latency memory allocator Content-Language: en-US From: Tom de Vries To: Andrew Stubbs , "gcc-patches@gcc.gnu.org" Cc: Tobias Burnus , Jakub Jelinek References: <25ad524d-f0d6-1970-b8e9-9b11b6cde68b@codesourcery.com> <42c70624-2b10-340c-8945-601203768d48@suse.de> <664653d3-cf64-b800-6ffb-c27e50dc15bf@suse.de> <5e75a64c-a8d3-2d2a-162a-a3ea79358b48@suse.de> In-Reply-To: <5e75a64c-a8d3-2d2a-162a-a3ea79358b48@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Thu, 06 Jan 2022 17:53:05 -0000 On 1/6/22 10:29, Tom de Vries wrote: > At first glance, the above behaviour doesn't look like a too short timeout. Using patch below, this passes for me, I'm currently doing a full build and test to confirm. Looks like it has to do with: ... For sm_6x and earlier architectures, atom operations on .shared state space do not guarantee atomicity with respect to normal store instructions to the same address. It is the programmer's responsibility to guarantee correctness of programs that use shared memory atomic instructions, e.g., by inserting barriers between normal stores and atomic operations to a common address, or by using atom.exch to store to locations accessed by other atomic operations. ... My current understanding is that this is a backend problem, and needs to be fixed by defining atomic_store patterns which take care of this peculiarity. Thanks, - Tom diff --git a/libgomp/config/nvptx/allocator.c b/libgomp/config/nvptx/allocator.c index 6bc2ea48043..4524122b3e7 100644 --- a/libgomp/config/nvptx/allocator.c +++ b/libgomp/config/nvptx/allocator.c @@ -122,7 +122,8 @@ nvptx_memspace_alloc (omp_memspace_handle_t memspace, size_t size) } /* Update the free chain root and release the lock. */ - __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE); + __atomic_exchange_n (&__nvptx_lowlat_heap_root, + root.raw, MEMMODEL_RELEASE); return result; } else- @@ -221,7 +222,8 @@ nvptx_memspace_free (omp_memspace_handle_t memspace, void *addr, s ize_t size) root.raw = newfreechunk.raw; /* Update the free chain root and release the lock. */ - __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE); + __atomic_exchange_n (&__nvptx_lowlat_heap_root, + root.raw, MEMMODEL_RELEASE); } else free (addr); @@ -331,7 +333,8 @@ nvptx_memspace_realloc (omp_memspace_handle_t memspace, void *addr , /* Else realloc in-place has failed and result remains NULL. */ /* Update the free chain root and release the lock. */ - __atomic_store_n (&__nvptx_lowlat_heap_root, root.raw, MEMMODEL_RELEASE); + __atomic_exchange_n (&__nvptx_lowlat_heap_root, + root.raw, MEMMODEL_RELEASE); if (result == NULL) {