[OpenMP] Provide big-endian bitfield definitions (#69995)

structs kmp_depend_info.flags and kmp_tasking_flags contain bitfields,
which overlay integer flag values. The current bitfield definitions
target little-endian machines. On big-endian machines bitfields are laid
out in the opposite order, so the current definitions do not work there.

There are two ways to fix this: either provide big-endian bitfield
definitions, or bit-swap integer flag values. Go with the former, since
it's localized to one place and therefore is more maintainable.
This commit is contained in:
Ilya Leoshkevich 2023-10-24 19:39:50 +02:00 committed by GitHub
parent 122c89b271
commit 34459b72da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2456,12 +2456,22 @@ typedef struct kmp_depend_info {
union {
kmp_uint8 flag; // flag as an unsigned char
struct { // flag as a set of 8 bits
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
/* Same fields as in the #else branch, but in reverse order */
unsigned all : 1;
unsigned unused : 3;
unsigned set : 1;
unsigned mtx : 1;
unsigned out : 1;
unsigned in : 1;
#else
unsigned in : 1;
unsigned out : 1;
unsigned mtx : 1;
unsigned set : 1;
unsigned unused : 3;
unsigned all : 1;
#endif
} flags;
};
} kmp_depend_info_t;
@ -2611,6 +2621,33 @@ typedef struct kmp_task_stack {
#endif // BUILD_TIED_TASK_STACK
typedef struct kmp_tasking_flags { /* Total struct must be exactly 32 bits */
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
/* Same fields as in the #else branch, but in reverse order */
#if OMPX_TASKGRAPH
unsigned reserved31 : 6;
unsigned onced : 1;
#else
unsigned reserved31 : 7;
#endif
unsigned native : 1;
unsigned freed : 1;
unsigned complete : 1;
unsigned executing : 1;
unsigned started : 1;
unsigned team_serial : 1;
unsigned tasking_ser : 1;
unsigned task_serial : 1;
unsigned tasktype : 1;
unsigned reserved : 8;
unsigned hidden_helper : 1;
unsigned detachable : 1;
unsigned priority_specified : 1;
unsigned proxy : 1;
unsigned destructors_thunk : 1;
unsigned merged_if0 : 1;
unsigned final : 1;
unsigned tiedness : 1;
#else
/* Compiler flags */ /* Total compiler flags must be 16 bits */
unsigned tiedness : 1; /* task is either tied (1) or untied (0) */
unsigned final : 1; /* task is final(1) so execute immediately */
@ -2646,7 +2683,7 @@ typedef struct kmp_tasking_flags { /* Total struct must be exactly 32 bits */
#else
unsigned reserved31 : 7; /* reserved for library use */
#endif
#endif
} kmp_tasking_flags_t;
typedef struct kmp_target_data {