From 5130c49fd8b6b659f8f923625d155fc66769a147 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 1 Feb 2016 13:18:06 +0100 Subject: [PATCH] have the two versions of EP together + avoid replication + solve some casting issues too --- examples/smpi/NAS/EP-sampling/Makefile | 28 ----- examples/smpi/NAS/EP-sampling/README | 6 - examples/smpi/NAS/EP-sampling/randlc.c | 107 ------------------ examples/smpi/NAS/EP-sampling/randlc.h | 3 - examples/smpi/NAS/EP/Makefile | 10 +- .../{EP-sampling/ep.c => EP/ep-sampling.c} | 10 +- examples/smpi/NAS/EP/ep.c | 11 +- examples/smpi/NAS/Makefile | 4 - 8 files changed, 17 insertions(+), 162 deletions(-) delete mode 100644 examples/smpi/NAS/EP-sampling/Makefile delete mode 100644 examples/smpi/NAS/EP-sampling/README delete mode 100644 examples/smpi/NAS/EP-sampling/randlc.c delete mode 100644 examples/smpi/NAS/EP-sampling/randlc.h rename examples/smpi/NAS/{EP-sampling/ep.c => EP/ep-sampling.c} (98%) diff --git a/examples/smpi/NAS/EP-sampling/Makefile b/examples/smpi/NAS/EP-sampling/Makefile deleted file mode 100644 index 6205cb4ae2..0000000000 --- a/examples/smpi/NAS/EP-sampling/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -SHELL=/bin/sh -BENCHMARK=ep -BENCHMARKU=EP - -include ../config/make.def - -#OBJS = ep.o ${COMMON}/print_results.o ${COMMON}/${RAND}.o ${COMMON}/timers.o -OBJS = ep.o randlc.o - -include ../sys/make.common - -${PROGRAM}: config ${OBJS} -# ${FLINK} ${FLINKFLAGS} -o ${PROGRAM} ${OBJS} ${FMPI_LIB} - ${CLINK} ${CLINKFLAGS} -o ${PROGRAM} ${OBJS} ${CMPI_LIB} - - -#ep.o: ep.f mpinpb.h npbparams.h -# ${FCOMPILE} ep.f - -ep.o: ep.c randlc.c ../EP/mpinpb.h npbparams.h - ${CCOMPILE} ep.c - -clean: - - rm -f *.o *~ - - rm -f npbparams.h core - - - diff --git a/examples/smpi/NAS/EP-sampling/README b/examples/smpi/NAS/EP-sampling/README deleted file mode 100644 index 6eb36571af..0000000000 --- a/examples/smpi/NAS/EP-sampling/README +++ /dev/null @@ -1,6 +0,0 @@ -This code implements the random-number generator described in the -NAS Parallel Benchmark document RNR Technical Report RNR-94-007. -The code is "embarrassingly" parallel in that no communication is -required for the generation of the random numbers itself. There is -no special requirement on the number of processors used for running -the benchmark. diff --git a/examples/smpi/NAS/EP-sampling/randlc.c b/examples/smpi/NAS/EP-sampling/randlc.c deleted file mode 100644 index 4de6c93b88..0000000000 --- a/examples/smpi/NAS/EP-sampling/randlc.c +++ /dev/null @@ -1,107 +0,0 @@ - -/* - * FUNCTION RANDLC (X, A) - * - * This routine returns a uniform pseudorandom double precision number in the - * range (0, 1) by using the linear congruential generator - * - * x_{k+1} = a x_k (mod 2^46) - * - * where 0 < x_k < 2^46 and 0 < a < 2^46. This scheme generates 2^44 numbers - * before repeating. The argument A is the same as 'a' in the above formula, - * and X is the same as x_0. A and X must be odd double precision integers - * in the range (1, 2^46). The returned value RANDLC is normalized to be - * between 0 and 1, i.e. RANDLC = 2^(-46) * x_1. X is updated to contain - * the new seed x_1, so that subsequent calls to RANDLC using the same - * arguments will generate a continuous sequence. - * - * This routine should produce the same results on any computer with at least - * 48 mantissa bits in double precision floating point data. On Cray systems, - * double precision should be disabled. - * - * David H. Bailey October 26, 1990 - * - * IMPLICIT DOUBLE PRECISION (A-H, O-Z) - * SAVE KS, R23, R46, T23, T46 - * DATA KS/0/ - * - * If this is the first call to RANDLC, compute R23 = 2 ^ -23, R46 = 2 ^ -46, - * T23 = 2 ^ 23, and T46 = 2 ^ 46. These are computed in loops, rather than - * by merely using the ** operator, in order to insure that the results are - * exact on all systems. This code assumes that 0.5D0 is represented exactly. - */ - - -/*****************************************************************/ -/************* R A N D L C ************/ -/************* ************/ -/************* portable random number generator ************/ -/*****************************************************************/ - -double randlc( double *X, double *A ) -{ - static int KS=0; - static double R23, R46, T23, T46; - double T1, T2, T3, T4; - double A1; - double A2; - double X1; - double X2; - double Z; - int i, j; - - if (KS == 0) - { - R23 = 1.0; - R46 = 1.0; - T23 = 1.0; - T46 = 1.0; - - for (i=1; i<=23; i++) - { - R23 = 0.50 * R23; - T23 = 2.0 * T23; - } - for (i=1; i<=46; i++) - { - R46 = 0.50 * R46; - T46 = 2.0 * T46; - } - KS = 1; - } - -/* Break A into two parts such that A = 2^23 * A1 + A2 and set X = N. */ - - T1 = R23 * *A; - j = T1; - A1 = j; - A2 = *A - T23 * A1; - -/* Break X into two parts such that X = 2^23 * X1 + X2, compute - Z = A1 * X2 + A2 * X1 (mod 2^23), and then - X = 2^23 * Z + A2 * X2 (mod 2^46). */ - - T1 = R23 * *X; - j = T1; - X1 = j; - X2 = *X - T23 * X1; - T1 = A1 * X2 + A2 * X1; - - j = R23 * T1; - T2 = j; - Z = T1 - T23 * T2; - T3 = T23 * Z + A2 * X2; - j = R46 * T3; - T4 = j; - *X = T3 - T46 * T4; - return(R46 * *X); -} - - - -/*****************************************************************/ -/************ F I N D _ M Y _ S E E D ************/ -/************ ************/ -/************ returns parallel random number seq seed ************/ -/*****************************************************************/ - diff --git a/examples/smpi/NAS/EP-sampling/randlc.h b/examples/smpi/NAS/EP-sampling/randlc.h deleted file mode 100644 index aff84d341a..0000000000 --- a/examples/smpi/NAS/EP-sampling/randlc.h +++ /dev/null @@ -1,3 +0,0 @@ - -double randlc( double *X, double *A ); - diff --git a/examples/smpi/NAS/EP/Makefile b/examples/smpi/NAS/EP/Makefile index 217f57df69..3387d73a3f 100644 --- a/examples/smpi/NAS/EP/Makefile +++ b/examples/smpi/NAS/EP/Makefile @@ -5,18 +5,22 @@ BENCHMARKU=EP include ../config/make.def OBJS = ep.o randlc.o +OBJS-S = ep-sampling.o randlc.o include ../sys/make.common -${PROGRAM}: config ${OBJS} - ${CLINK} ${CLINKFLAGS} -o ${PROGRAM} ${OBJS} ${CMPI_LIB} +${PROGRAM}: config ${OBJS} ${OBJS-S} + ${CLINK} ${CLINKFLAGS} -o ${PROGRAM} ${OBJS} ${CMPI_LIB} -lm + ${CLINK} ${CLINKFLAGS} -o ${PROGRAM}-sampling ${OBJS-S} ${CMPI_LIB} -lm ep.o: ep.c randlc.c mpinpb.h npbparams.h ${CCOMPILE} ep.c +ep-sampling.o: ep-sampling.c randlc.c mpinpb.h npbparams.h + ${CCOMPILE} ep-sampling.c clean: - rm -f *.o *~ - - rm -f npbparams.h core + - rm -f npbparams.h diff --git a/examples/smpi/NAS/EP-sampling/ep.c b/examples/smpi/NAS/EP/ep-sampling.c similarity index 98% rename from examples/smpi/NAS/EP-sampling/ep.c rename to examples/smpi/NAS/EP/ep-sampling.c index 940c1b98e3..01bd4c71ff 100644 --- a/examples/smpi/NAS/EP-sampling/ep.c +++ b/examples/smpi/NAS/EP/ep-sampling.c @@ -156,7 +156,7 @@ * point print statement (internal file) */ fprintf(stdout," NAS Parallel Benchmarks 3.2 -- EP Benchmark"); - sprintf(size,"%d",pow(2,m+1)); + sprintf(size,"%d",(int) pow(2,m+1)); //size = size.replace('.', ' '); fprintf(stdout," Number of random numbers generated: %s\n",size); fprintf(stdout," Number of active processes: %d\n",no_nodes); @@ -397,13 +397,13 @@ Mops = (pow(2.0, m+1))/tm/1000; fprintf(stdout,"EP Benchmark Results:\n"); - fprintf(stdout,"CPU Time=%d\n",tm); + fprintf(stdout,"CPU Time=%d\n",(int) tm); fprintf(stdout,"N = 2^%d\n",m); - fprintf(stdout,"No. Gaussain Pairs =%d\n",gc); - fprintf(stdout,"Sum = %f %ld\n",sx,sy); + fprintf(stdout,"No. Gaussain Pairs =%d\n",(int) gc); + fprintf(stdout,"Sum = %f %ld\n",sx,(long) sy); fprintf(stdout,"Count:"); for(i = 0; i < nq; i++) { - fprintf(stdout,"%d\t %ld\n",i,q[i]); + fprintf(stdout,"%d\t %ld\n",i,(long) q[i]); } /* diff --git a/examples/smpi/NAS/EP/ep.c b/examples/smpi/NAS/EP/ep.c index 5cf9d5fb7f..685fdcaafc 100644 --- a/examples/smpi/NAS/EP/ep.c +++ b/examples/smpi/NAS/EP/ep.c @@ -17,7 +17,6 @@ #define true 1 #define false 0 - //---NOTE : all the timers function have been modified to // avoid global timers (privatize these). // ----------------------- timers --------------------- @@ -160,7 +159,7 @@ * point print statement (internal file) */ fprintf(stdout," NAS Parallel Benchmarks 3.2 -- EP Benchmark"); - sprintf(size,"%d",pow(2,m+1)); + sprintf(size,"%d",(int)pow(2,m+1)); //size = size.replace('.', ' '); fprintf(stdout," Number of random numbers generated: %s\n",size); fprintf(stdout," Number of active processes: %d\n",no_nodes); @@ -405,13 +404,13 @@ Mops = (pow(2.0, m+1))/tm/1000; fprintf(stdout,"EP Benchmark Results:\n"); - fprintf(stdout,"CPU Time=%d\n",tm); + fprintf(stdout,"CPU Time=%d\n",(int) tm); fprintf(stdout,"N = 2^%d\n",m); - fprintf(stdout,"No. Gaussain Pairs =%d\n",gc); - fprintf(stdout,"Sum = %f %ld\n",sx,sy); + fprintf(stdout,"No. Gaussain Pairs =%d\n",(int) gc); + fprintf(stdout,"Sum = %f %ld\n",sx,(long) sy); fprintf(stdout,"Count:"); for(i = 0; i < nq; i++) { - fprintf(stdout,"%d\t %ld\n",i,q[i]); + fprintf(stdout,"%d\t %ld\n",i,(long) q[i]); } /* diff --git a/examples/smpi/NAS/Makefile b/examples/smpi/NAS/Makefile index 04524009d1..ae04d5e54e 100644 --- a/examples/smpi/NAS/Makefile +++ b/examples/smpi/NAS/Makefile @@ -17,10 +17,6 @@ EP: ep ep: header cd EP; $(MAKE) NPROCS=$(NPROCS) CLASS=$(CLASS) -EP-sampling: ep-sampling -ep-sampling: header - cd EP-sampling; $(MAKE) NPROCS=$(NPROCS) CLASS=$(CLASS) - DT: dt dt: header cd DT; $(MAKE) CLASS=$(CLASS) -- 2.20.1