1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

remove compiler warnings, align buffers and flags

This commit is contained in:
Stefan Lankes 2015-10-19 22:57:39 +02:00
parent 238b0ddae0
commit 053d0ec76a
12 changed files with 63 additions and 75 deletions

View file

@ -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 {

View file

@ -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)

View file

@ -60,10 +60,10 @@ int RCCE_bcast(
if (RCCE_IAM == comm.member[root]) {
for (ue=0; ue<comm.size; ue++) if (ue != root)
if(ierr=RCCE_send(buf, num, comm.member[ue]))
if((ierr=RCCE_send(buf, num, comm.member[ue])))
return(RCCE_error_return(RCCE_debug_comm,ierr));
}
else if(ierr=RCCE_recv(buf, num, comm.member[root]))
else if((ierr=RCCE_recv(buf, num, comm.member[root])))
return(RCCE_error_return(RCCE_debug_comm,ierr));
return(RCCE_SUCCESS);

View file

@ -92,7 +92,7 @@ int RCCE_comm_split(
}
#endif
if(error=RCCE_flag_alloc(&(comm->release)))
if((error=RCCE_flag_alloc(&(comm->release))))
return(RCCE_error_return(RCCE_debug_comm,error));
comm->label = 0;

View file

@ -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

View file

@ -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);

View file

@ -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); \

View file

@ -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; ue<comm.size; ue++) if (ue != root) {
if (ierr=RCCE_recv(inbuf, num*type_size, comm.member[ue]))
if ((ierr=RCCE_recv(inbuf, num*type_size, comm.member[ue])))
return(ierr);
// use combination of operation and data type to reduce number of switch statements
@ -127,11 +127,11 @@ static int RCCE_reduce_general(
// in case of allreduce the root sends the reduction results to all non-root UEs
if (all) for (ue=0; ue<comm.size; ue++) if (ue != root)
if(ierr=RCCE_send(outbuf, num*type_size, comm.member[ue]))
if((ierr=RCCE_send(outbuf, num*type_size, comm.member[ue])))
return(ierr);
}
return(RCCE_SUCCESS);
#endif GORY
#endif // GORY
}
//---------------------------------------------------------------------------------------

View file

@ -128,10 +128,10 @@ int RCCE_test_flag(RCCE_FLAG flag, RCCE_FLAG_STATUS val, int *result) {
//--------------------------------------------------------------------------------------
int RCCE_barrier(RCCE_COMM *comm) {
t_vchar cyclechar[RCCE_LINE_SIZE] __attribute__ ((aligned (32)));
t_vchar valchar [RCCE_LINE_SIZE] __attribute__ ((aligned (32)));
int counter, i, error;
int ROOT = 0;
t_vchar cyclechar[RCCE_LINE_SIZE];
t_vchar valchar [RCCE_LINE_SIZE];
t_vcharp gatherp, releasep;
RCCE_FLAG_STATUS cycle;
@ -339,12 +339,12 @@ int RCCE_test_tagged(RCCE_FLAG flag, RCCE_FLAG_STATUS val, int *result, void *ta
//--------------------------------------------------------------------------------------
int RCCE_barrier(RCCE_COMM *comm) {
int counter, i, error;
int ROOT = 0;
volatile unsigned char cyclechar[RCCE_LINE_SIZE];
volatile unsigned char valchar[RCCE_LINE_SIZE];
volatile unsigned char cyclechar[RCCE_LINE_SIZE] __attribute__ ((aligned (32)));
volatile unsigned char valchar[RCCE_LINE_SIZE] __attribute__ ((aligned (32)));
volatile char *cycle;
volatile char *val;
int counter, i, error;
int ROOT = 0;
counter = 0;
cycle = (volatile char *)cyclechar;
@ -403,16 +403,16 @@ int RCCE_barrier(RCCE_COMM *comm) {
// flip local barrier variable
#ifndef USE_FLAG_EXPERIMENTAL
if (error = RCCE_get(cyclechar, (t_vcharp)(comm->gather), 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; i<comm->size; 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; i<comm->size; 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; i<comm->size; 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; i<comm->size; 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));
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);