Fix for big endian machines

This commit is contained in:
Stan Moore
2017-11-20 10:18:53 -07:00
parent 40e776ebc6
commit f3ed148828
2 changed files with 22 additions and 0 deletions

View File

@ -291,6 +291,17 @@ int HostThreadTeamData::rendezvous( int64_t * const buffer
+ ( ( rank & ~mask_byte ) << shift_mem_cycle ) + ( ( rank & ~mask_byte ) << shift_mem_cycle )
+ ( sync_offset << shift_byte ); + ( sync_offset << shift_byte );
// Switch designated byte if running on big endian machine
volatile uint16_t value = 1;
volatile uint8_t* byte = (uint8_t*) &value;
volatile bool is_big_endian = (!(byte[0] == 1));
if (is_big_endian) {
int remainder = ((offset) % 8);
int base = offset - remainder;
int shift = 7 - remainder;
offset = base + shift;
}
// All of this thread's previous memory stores must be complete before // All of this thread's previous memory stores must be complete before
// this thread stores the step value at this thread's designated byte // this thread stores the step value at this thread's designated byte
// in the shared synchronization array. // in the shared synchronization array.

View File

@ -137,6 +137,17 @@ int rendezvous( volatile int64_t * const buffer
+ ( ( rank & ~mask_byte ) << shift_mem_cycle ) + ( ( rank & ~mask_byte ) << shift_mem_cycle )
+ ( sync_offset << shift_byte ); + ( sync_offset << shift_byte );
// Switch designated byte if running on big endian machine
volatile uint16_t value = 1;
volatile uint8_t* byte = (uint8_t*) &value;
volatile bool is_big_endian = (!(byte[0] == 1));
if (is_big_endian) {
int remainder = ((offset) % 8);
int base = offset - remainder;
int shift = 7 - remainder;
offset = base + shift;
}
// All of this thread's previous memory stores must be complete before // All of this thread's previous memory stores must be complete before
// this thread stores the step value at this thread's designated byte // this thread stores the step value at this thread's designated byte
// in the shared synchronization array. // in the shared synchronization array.