diff --git a/hermit/usr/ircce/RCCE.h b/hermit/usr/ircce/RCCE.h index 18ac37507..1a24a644b 100644 --- a/hermit/usr/ircce/RCCE.h +++ b/hermit/usr/ircce/RCCE.h @@ -164,14 +164,14 @@ typedef struct { #ifdef USE_FLAG_EXPERIMENTAL typedef volatile unsigned char *RCCE_FLAG; #else -typedef volatile int *RCCE_FLAG; +typedef volatile ssize_t *RCCE_FLAG; #endif #endif #ifdef USE_FLAG_EXPERIMENTAL typedef unsigned char RCCE_FLAG_STATUS; #else -typedef int RCCE_FLAG_STATUS; +typedef ssize_t RCCE_FLAG_STATUS; #endif typedef struct { diff --git a/hermit/usr/ircce/RCCE_admin.c b/hermit/usr/ircce/RCCE_admin.c index 58e643632..01cfacb7d 100644 --- a/hermit/usr/ircce/RCCE_admin.c +++ b/hermit/usr/ircce/RCCE_admin.c @@ -193,10 +193,8 @@ t_vcharp RCCE_fool_write_combine_buffer; #ifdef SCC #ifdef __hermit__ inline volatile uint64_t _rdtsc() { - uint64_t lo, hi; - + register uint64_t lo, hi; asm volatile ("rdtsc" : "=a"(lo), "=d"(hi) ); - return ((uint64_t)hi << 32ULL | (uint64_t)lo); } #elif defined(__INTEL_COMPILER) diff --git a/hermit/usr/ircce/RCCE_bcast.c b/hermit/usr/ircce/RCCE_bcast.c index 69ca6af2f..935f8c820 100644 --- a/hermit/usr/ircce/RCCE_bcast.c +++ b/hermit/usr/ircce/RCCE_bcast.c @@ -60,10 +60,10 @@ int RCCE_bcast( if (RCCE_IAM == comm.member[root]) { for (ue=0; uerelease))) + if((error=RCCE_flag_alloc(&(comm->release)))) return(RCCE_error_return(RCCE_debug_comm,error)); comm->label = 0; diff --git a/hermit/usr/ircce/RCCE_flags.c b/hermit/usr/ircce/RCCE_flags.c index ee7063ccf..4ef003777 100644 --- a/hermit/usr/ircce/RCCE_flags.c +++ b/hermit/usr/ircce/RCCE_flags.c @@ -60,10 +60,7 @@ int LEFTMOSTBIT = sizeof(int)*8-1; // END GLOBAL VARIABLES USED BY THE LIBRARY //...................................................................................... -RCCE_FLAG_LINE RCCE_flags = -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - NULL, 0, NULL}; +RCCE_FLAG_LINE RCCE_flags = {{[0 ... RCCE_FLAGS_PER_LINE-1] = 0}, NULL, 0, NULL}; // next three utility functions are only used by the library, not the user. We assume // there will never be errrors, so we do not return any error code. "location" of a @@ -362,9 +359,7 @@ int RCCE_flag_free(RCCE_FLAG *flag) { int RCCE_flag_write(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID) { int error; #ifndef USE_FLAG_EXPERIMENTAL - volatile unsigned char val_array[RCCE_LINE_SIZE] = - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + volatile int val_array[RCCE_LINE_SIZE/sizeof(int)] = {[0 ... RCCE_LINE_SIZE/sizeof(int)-1] = 0}; #ifdef GORY // check input parameters @@ -374,12 +369,12 @@ int RCCE_flag_write(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID) { #endif #ifndef USE_REVERTED_FLAGS - *(int *) val_array = val; + *val_array = val; #else - *(int *) &val_array[RCCE_LINE_SIZE-sizeof(int)] = val; + val_array[RCCE_LINE_SIZE/sizeof(int)-1] = val; #endif - error = RCCE_put((t_vcharp)(*flag), val_array, RCCE_LINE_SIZE, ID); + error = RCCE_put((t_vcharp)(*flag), (t_vcharp)val_array, RCCE_LINE_SIZE, ID); #else //*flag = val; @@ -394,9 +389,7 @@ int RCCE_flag_write(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID) { #ifdef USE_TAGGED_FLAGS int RCCE_flag_write_tagged(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID, void* tag, int len) { - unsigned char val_array[RCCE_LINE_SIZE] = - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + unsigned char val_array[RCCE_LINE_SIZE] = {[0 ... RCCE_LINE_SIZE-1] = 0}; int error, i, j; @@ -432,19 +425,19 @@ int RCCE_flag_write_tagged(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID, void* int RCCE_flag_read(RCCE_FLAG flag, RCCE_FLAG_STATUS *val, int ID) { int error; #ifndef USE_FLAG_EXPERIMENTAL - volatile unsigned char val_array[RCCE_LINE_SIZE]; + volatile int val_array[RCCE_LINE_SIZE/sizeof(int)]; #ifdef GORY if (!flag) return(RCCE_error_return(RCCE_debug_synch,RCCE_ERROR_FLAG_UNDEFINED)); if (!val) return(RCCE_error_return(RCCE_debug_synch,RCCE_ERROR_VAL_UNDEFINED)); #endif - if(error=RCCE_get(val_array, (t_vcharp)flag, RCCE_LINE_SIZE, ID)) + if((error=RCCE_get((t_vcharp)val_array, (t_vcharp)flag, RCCE_LINE_SIZE, ID))) return(RCCE_error_return(RCCE_debug_synch,error)); #ifndef USE_REVERTED_FLAGS - if(val) *val = *(int *)val_array; + if(val) *val = *val_array; #else - if(val) *val = *(int *)&val_array[RCCE_LINE_SIZE-sizeof(int)]; + if(val) *val = val_array[RCCE_LINE_SIZE/sizeof(int)-1]; #endif #else diff --git a/hermit/usr/ircce/RCCE_get.c b/hermit/usr/ircce/RCCE_get.c index 66e72b44e..166b87034 100644 --- a/hermit/usr/ircce/RCCE_get.c +++ b/hermit/usr/ircce/RCCE_get.c @@ -136,7 +136,7 @@ int RCCE_get( RCCE_memcpy_get((void *)target, (void *)source, num_bytes); if (RCCE_debug_synch) - fprintf(STDERR,"UE %d get data: %d from address %X \n", RCCE_IAM,*target,source); + fprintf(STDERR,"UE %d get data: %d from address %p \n", RCCE_IAM,*target,source); // printf("UE %d finished the memcopy\n", RCCE_IAM); diff --git a/hermit/usr/ircce/RCCE_qsort.c b/hermit/usr/ircce/RCCE_qsort.c index f436fccf4..fd9074f18 100644 --- a/hermit/usr/ircce/RCCE_qsort.c +++ b/hermit/usr/ircce/RCCE_qsort.c @@ -41,8 +41,7 @@ int id_compare( // Copyright 1993, John Wiley. /*assume sizeof(long) is a power of 2 */ -#define SWAPINIT(a, es) swaptype = \ - (a-(char*)0 | es) % sizeof(long) ? 2 : es > sizeof(long); +#define SWAPINIT(a, es) swaptype = ((a-(char*)0) | es) % sizeof(long) ? 2 : es > sizeof(long); #define swapcode(TYPE, parmi, parmj, n) { \ register TYPE *pi = (TYPE *) (parmi); \ register TYPE *pj = (TYPE *) (parmj); \ diff --git a/hermit/usr/ircce/RCCE_reduce.c b/hermit/usr/ircce/RCCE_reduce.c index 50ef9bec8..1723886a0 100644 --- a/hermit/usr/ircce/RCCE_reduce.c +++ b/hermit/usr/ircce/RCCE_reduce.c @@ -87,17 +87,17 @@ static int RCCE_reduce_general( if (RCCE_IAM != comm.member[root]) { // non-root UEs send their source buffers to the root - if (ierr=RCCE_send(inbuf, num*type_size, comm.member[root])) + if ((ierr=RCCE_send(inbuf, num*type_size, comm.member[root]))) return(ierr); // in case of allreduce they also receive the reduced buffer - if (all) if (ierr=RCCE_recv(outbuf, num*type_size, comm.member[root])) + if (all) if ((ierr=RCCE_recv(outbuf, num*type_size, comm.member[root]))) return(ierr); } else { // the root can copy directly from source to target buffer memcpy(outbuf, inbuf, num*type_size); for (ue=0; uegather), RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_get(cyclechar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, RCCE_IAM))) #else - if (error = RCCE_get_flag(cyclechar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_get_flag(cyclechar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, RCCE_IAM))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); *cycle = !(*cycle); #ifndef USE_FLAG_EXPERIMENTAL - if (error = RCCE_put((t_vcharp)(comm->gather), cyclechar, RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_put((t_vcharp)(comm->gather), cyclechar, RCCE_LINE_SIZE, RCCE_IAM))) #else - if (error = RCCE_put_flag((t_vcharp)(comm->gather), cyclechar, RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_put_flag((t_vcharp)(comm->gather), cyclechar, RCCE_LINE_SIZE, RCCE_IAM))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); @@ -424,11 +424,11 @@ int RCCE_barrier(RCCE_COMM *comm) { for (counter=i=1; isize; i++) { /* copy flag values out of comm buffer */ #ifndef USE_FLAG_EXPERIMENTAL - if (error = RCCE_get(valchar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, - comm->member[i])) + if ((error = RCCE_get(valchar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, + comm->member[i]))) #else - if (error = RCCE_get_flag(valchar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, - comm->member[i])) + if ((error = RCCE_get_flag(valchar, (t_vcharp)(comm->gather), RCCE_LINE_SIZE, + comm->member[i]))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); if (*val == *cycle) counter++; @@ -436,12 +436,12 @@ int RCCE_barrier(RCCE_COMM *comm) { } // set release flags for (i=1; isize; i++) { - if (error = RCCE_flag_write(&(comm->release), *cycle, comm->member[i])) + if ((error = RCCE_flag_write(&(comm->release), *cycle, comm->member[i]))) return(RCCE_error_return(RCCE_debug_synch,error)); } } else { - if (error = RCCE_wait_until(comm->release, *cycle)) { + if ((error = RCCE_wait_until(comm->release, *cycle))) { return(RCCE_error_return(RCCE_debug_synch,error)); } } @@ -458,10 +458,10 @@ int RCCE_barrier(RCCE_COMM *comm) { //-------------------------------------------------------------------------------------- int RCCE_nb_barrier(RCCE_COMM *comm) { + volatile unsigned char cyclechar[RCCE_LINE_SIZE] __attribute__ ((aligned (32))); + volatile unsigned char valchar[RCCE_LINE_SIZE] __attribute__ ((aligned (32))); int i, error; int ROOT = 0; - volatile unsigned char cyclechar[RCCE_LINE_SIZE]; - volatile unsigned char valchar[RCCE_LINE_SIZE]; #ifdef USE_FLAG_EXPERIMENTAL volatile char *cycle; volatile char *val; @@ -546,16 +546,16 @@ label2: // flip local barrier variable #ifndef USE_FLAG_EXPERIMENTAL - if (error = RCCE_get(cyclechar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_get(cyclechar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, RCCE_IAM))) #else - if (error = RCCE_get_flag(cyclechar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_get_flag(cyclechar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, RCCE_IAM))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); *cycle = !(*cycle); #ifndef USE_FLAG_EXPERIMENTAL - if (error = RCCE_put((t_vcharp)(comm->gather[0]), cyclechar, RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_put((t_vcharp)(comm->gather[0]), cyclechar, RCCE_LINE_SIZE, RCCE_IAM))) #else - if (error = RCCE_put_flag((t_vcharp)(comm->gather[0]), cyclechar, RCCE_LINE_SIZE, RCCE_IAM)) + if ((error = RCCE_put_flag((t_vcharp)(comm->gather[0]), cyclechar, RCCE_LINE_SIZE, RCCE_IAM))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); @@ -569,11 +569,11 @@ label1: for (comm->count=i=1; isize; i++) { /* copy flag values out of comm buffer */ #ifndef USE_FLAG_EXPERIMENTAL - if (error = RCCE_get(valchar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, - comm->member[i])) + if ((error = RCCE_get(valchar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, + comm->member[i]))) #else - if (error = RCCE_get_flag(valchar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, - comm->member[i])) + if ((error = RCCE_get_flag(valchar, (t_vcharp)(comm->gather[0]), RCCE_LINE_SIZE, + comm->member[i]))) #endif return(RCCE_error_return(RCCE_debug_synch,error)); if (*val == comm->cycle) comm->count++; @@ -585,7 +585,7 @@ label1: } // set release flags for (i=1; isize; i++) { - if (error = RCCE_flag_write(&(comm->release), comm->cycle, comm->member[i])) + if ((error = RCCE_flag_write(&(comm->release), comm->cycle, comm->member[i]))) return(RCCE_error_return(RCCE_debug_synch,error)); } } diff --git a/hermit/usr/ircce/iRCCE_irecv.c b/hermit/usr/ircce/iRCCE_irecv.c index 6ceb38d83..4ca347264 100644 --- a/hermit/usr/ircce/iRCCE_irecv.c +++ b/hermit/usr/ircce/iRCCE_irecv.c @@ -403,7 +403,7 @@ int iRCCE_iprobe(int source, int* test_rank, int* test_flag) #ifdef _iRCCE_ANY_LENGTH_ { - int size = iRCCE_ANY_LENGTH; + ssize_t size = iRCCE_ANY_LENGTH; RCCE_flag_read(RCCE_sent_flag[source], &size, RCCE_IAM); if(iRCCE_recent_length != size) iRCCE_recent_length = size; } diff --git a/hermit/usr/ircce/iRCCE_srecv.c b/hermit/usr/ircce/iRCCE_srecv.c index 3838ef31e..f2344eead 100644 --- a/hermit/usr/ircce/iRCCE_srecv.c +++ b/hermit/usr/ircce/iRCCE_srecv.c @@ -301,7 +301,7 @@ int iRCCE_probe(int source, int* test_rank) #ifdef _iRCCE_ANY_LENGTH_ { - int size; + ssize_t size; RCCE_flag_read(RCCE_sent_flag[source], &size, RCCE_IAM); if(iRCCE_recent_length != size) iRCCE_recent_length = size; } diff --git a/hermit/usr/ircce/iRCCE_synch.c b/hermit/usr/ircce/iRCCE_synch.c index 3f8e55fe3..5a4c8e046 100644 --- a/hermit/usr/ircce/iRCCE_synch.c +++ b/hermit/usr/ircce/iRCCE_synch.c @@ -140,15 +140,13 @@ int iRCCE_flag_alloc_tagged(RCCE_FLAG *flag) int iRCCE_flag_write_tagged(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID, void *tag, int len) { - unsigned char val_array[RCCE_LINE_SIZE] = - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + unsigned int val_array[RCCE_LINE_SIZE / sizeof(int)] = {[0 ... RCCE_LINE_SIZE/sizeof(int)-1] = 0}; int error, i, j; - *(int *) val_array = val; + *val_array = val; #ifdef _OPENMP - *(int *) &val_array[RCCE_LINE_SIZE-sizeof(int)] = val; + val_array[RCCE_LINE_SIZE/sizeof(int)-1] = val; #endif if(tag) @@ -158,9 +156,9 @@ int iRCCE_flag_write_tagged(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID, void } #ifdef RCCE_VERSION - error = iRCCE_put(flag->flag_addr, val_array, RCCE_LINE_SIZE, ID); + error = iRCCE_put(flag->flag_addr, (t_vcharp)val_array, RCCE_LINE_SIZE, ID); #else - error = iRCCE_put((t_vcharp)(*flag), val_array, RCCE_LINE_SIZE, ID); + error = iRCCE_put((t_vcharp)(*flag), (t_vcharp)val_array, RCCE_LINE_SIZE, ID); #endif return(RCCE_error_return(RCCE_debug_synch,error)); @@ -168,26 +166,26 @@ int iRCCE_flag_write_tagged(RCCE_FLAG *flag, RCCE_FLAG_STATUS val, int ID, void int iRCCE_flag_read_tagged(RCCE_FLAG flag, RCCE_FLAG_STATUS *val, int ID, void *tag, int len) { - unsigned char val_array[RCCE_LINE_SIZE]; + int val_array[RCCE_LINE_SIZE / sizeof(int)]; int error, i, j; #ifdef RCCE_VERSION - if(error=iRCCE_get(val_array, flag.flag_addr, RCCE_LINE_SIZE, ID)) + if((error=iRCCE_get((t_vcharp)val_array, flag.flag_addr, RCCE_LINE_SIZE, ID))) return(RCCE_error_return(RCCE_debug_synch,error)); #else - if(error=iRCCE_get(val_array, (t_vcharp)flag, RCCE_LINE_SIZE, ID)) + if((error=iRCCE_get((t_vcharp)val_array, (t_vcharp)flag, RCCE_LINE_SIZE, ID))) return(RCCE_error_return(RCCE_debug_synch,error)); #endif - if(val) *val = *(int *)val_array; + if(val) *val = *val_array; #ifdef _OPENMP - if(val) *val = *(int *)&val_array[RCCE_LINE_SIZE-sizeof(int)]; + if(val) *val = val_array[RCCE_LINE_SIZE / sizeof(int) - 1]; #endif if( (val) && (*val) && (tag) ) { if(len > iRCCE_MAX_TAGGED_LEN) len = iRCCE_MAX_TAGGED_LEN; - iRCCE_memcpy_put(tag, &val_array[sizeof(int)], len); + iRCCE_memcpy_put(tag, &val_array[1], len); } return(RCCE_SUCCESS);