From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cc-smtpout3.netcologne.de (cc-smtpout3.netcologne.de [89.1.8.213]) by sourceware.org (Postfix) with ESMTPS id 27C7C3851C24 for ; Sat, 2 Jan 2021 21:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27C7C3851C24 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id A90A712337; Sat, 2 Jan 2021 22:43:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 9A20B11DF9; Sat, 2 Jan 2021 22:43:52 +0100 (CET) Received: from [2001:4dd7:542b:0:97c4:7327:973b:657] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.11.6) (envelope-from ) id 5ff0e918-0799-7f0000012729-7f000001a096-1 for ; Sat, 02 Jan 2021 22:43:52 +0100 Received: from linux-p51k.fritz.box (2001-4dd7-542b-0-97c4-7327-973b-657.ipv6dyn.netcologne.de [IPv6:2001:4dd7:542b:0:97c4:7327:973b:657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sat, 2 Jan 2021 22:43:50 +0100 (CET) Subject: Re: Update on shared memory coarrays To: Iain Sandoe Cc: Fortran List , dhumieres.dominique@free.fr References: <3d57a473-4025-890d-d365-6c2f82e7f513@netcologne.de> <0e1c519febec1c47c411339269455b9d@free.fr> <7e332e70-246e-b44e-7689-477642bf114c@netcologne.de> <23f5fbb548e75b1a5029162b31a8ddd7@free.fr> <522f101eda4e212f98f1f071165a46e5@free.fr> <79fdfc28ee95e21ba173dad5780b4e02@free.fr> <0770e8fb5b4b479afc98be8cf6221cc5@free.fr> <1a63faebd65be2a76627a7873d74c0c8@free.fr> <86fa53e3-155d-1912-8b88-b0789323ee09@netcologne.de> <2d94ef13-e12e-b941-dcb0-a9a79362f2d5@netcologne.de> <6D26C802-E6E0-473F-BB17-A9B373541980@sandoe.co.uk> From: Thomas Koenig Message-ID: Date: Sat, 2 Jan 2021 22:43:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <6D26C802-E6E0-473F-BB17-A9B373541980@sandoe.co.uk> Content-Type: multipart/mixed; boundary="------------C035E26599C3FC4AE9CDBC30" Content-Language: de-DE X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, 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: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jan 2021 21:43:55 -0000 This is a multi-part message in MIME format. --------------C035E26599C3FC4AE9CDBC30 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Am 02.01.21 um 21:55 schrieb Iain Sandoe: > Thomas Koenig via Fortran wrote: > >>> map_memory image 0 size 1000 offset 0 pagesize 1000 >>> map_memory image 0 size 2000 offset 0 pagesize 1000 > > pagesize 1000? Output is in hex (easy to miss, as I didn't put the 0x into the printf statements :-) > Darwin’s pagesize is 4096 for PPC/X86 and 16384 for Arm64(aarch64). > >>> mmap failed: Invalid argument >> >> That means that a rewrite of shared_memory.c and shared_memory.h >> is required. >> >> I checked the attached program on every Unixoid system I >> could lay my hands on (Linux, AIX, OpenBSD, NetBSD, FreeBSD, >> OpenSolaris), and it passed everywhere.  Seems like MacOS >> is the only one where this particular idiom does not work. > > Perhaps I’m missing what the idiom is here :) The idiom is remapping a shared memory region a second time into memory, starting from the same offset (zero in this case). This is currently used to make the shared memory allocator more simple, and is something that, from Dominique's debugging, does not work on MacOS. It is something that can be worked around (says the person who didn't write the allocatator in the first place :-) but it's additional work. By the way, the original test case I posted to the list had an error, here is an updated one. Best regards Thomas --------------C035E26599C3FC4AE9CDBC30 Content-Type: text/x-csrc; charset=UTF-8; name="shm_open.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="shm_open.c" #include #include #include #include #include #include #include #define NAME "/random_namexxx" int main() { int fd; long pagesize; void *p1, *p2; volatile int *i1, *i2; size_t size1, size2; off_t offset; pagesize = sysconf (_SC_PAGE_SIZE); if (pagesize == -1) { perror ("sysconf failed"); exit (EXIT_FAILURE); } fd = shm_open (NAME, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); if (fd == -1) { perror ("shm_open failed"); exit (EXIT_FAILURE); } shm_unlink (NAME); offset = 0; size1 = pagesize; ftruncate (fd, size1); p1 = mmap (NULL, size1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); if (p1 == MAP_FAILED) { perror ("mmap 1 failed"); exit (EXIT_FAILURE); } printf ("p1 = %p\n", p1); i1 = p1; *i1 = 42; size2 = 2 * size1; ftruncate (fd, size2); p2 = mmap (NULL, size2, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); if (p2 == MAP_FAILED) { perror ("mmap 1 failed"); exit (EXIT_FAILURE); } printf ("p2 = %p\n", p2); i2 = p2; printf ("%d\n", *i2); return 0; } --------------C035E26599C3FC4AE9CDBC30--