public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/105358] New: [12 Regression] scan* fails on targets without aligned memory allocators.
@ 2022-04-23 12:00 iains at gcc dot gnu.org
  2022-04-25  6:52 ` [Bug libgomp/105358] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: iains at gcc dot gnu.org @ 2022-04-23 12:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105358

            Bug ID: 105358
           Summary: [12 Regression] scan* fails on targets without aligned
                    memory allocators.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

r12-4529-gc7abdf46fb7ac9a0c37 introduces a change to make use of efficient
allocators where they are available.

On i686/powerpc-darwin9 there are no such allocators (not even posix_memalign)
and so the GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC flags is false.

the following change:

 struct gomp_work_share
 {
   /* This member records the SCHEDULE clause to be used for this construct.
@@ -324,7 +348,12 @@ struct gomp_work_share
      are in a different cache line.  */

   /* This lock protects the update of the following members.  */
+#ifdef GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC
   gomp_mutex_t lock __attribute__((aligned (64)));
+#else
+  char pad[64 - offsetof (struct gomp_work_share_1st_cacheline, pad)];
+  gomp_mutex_t lock;
+#endif

causes struct gomp_work_share to become less aligned than 'long long' on the
32b host, which leads to wrong code in work.c which manipulates offsets with
__alignof__(long long).

So the underlying issue is that the target does guarantee malloc aligned to a
cache line [64 bytes on x86] (but only to the size of the largest vector
supported by the target [16 bytes]).

I'm not clear what the change above is implementing (since i'm not familiar
with how this interacts with the rest of the library) so I'm probably missing
some subtlety.

... but ISTM that we could omit that change, and the structure would always
claim 64 byte alignment (with the lock correctly at offset of 64 bytes).

Of course, on these older targets, malloc only returns something guaranteed to
be 16 byte aligned - but that *is* sufficient that any use of vector operations
to manipulate the content should see suitable alignment.

We could also just force the gomp_work_share struct to be aligned to
__alignof__(long long).
I guess we also have __BIGGEST_ALIGNMENT__ which would at least mean we could
align it suitably for the target default.

At present, I'm not proposing any patch - since I do not understand the
subtleties of how these objects interact with the library.

====

The reason that the fail is not seen on later versions (e.g. i686-darwin17) is
because posix_memalign () was introduced in Darwin10.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-04-26  8:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23 12:00 [Bug libgomp/105358] New: [12 Regression] scan* fails on targets without aligned memory allocators iains at gcc dot gnu.org
2022-04-25  6:52 ` [Bug libgomp/105358] " rguenth at gcc dot gnu.org
2022-04-25  9:04 ` jakub at gcc dot gnu.org
2022-04-25  9:21 ` jakub at gcc dot gnu.org
2022-04-25  9:59 ` iains at gcc dot gnu.org
2022-04-25 11:19 ` jakub at gcc dot gnu.org
2022-04-25 11:34 ` jakub at gcc dot gnu.org
2022-04-25 11:44 ` iains at gcc dot gnu.org
2022-04-25 11:46 ` iains at gcc dot gnu.org
2022-04-25 11:47 ` jakub at gcc dot gnu.org
2022-04-25 22:19 ` iains at gcc dot gnu.org
2022-04-26  7:15 ` cvs-commit at gcc dot gnu.org
2022-04-26  8:15 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).