From d1179cc8fb4b18203d0e1ebabf1025362770e339 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 31 May 2016 16:01:13 +0200 Subject: [PATCH] remove a couple of ugly things from DT.c a lot remains ... --- examples/smpi/NAS/dt.c | 61 +++++++++++++----------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/examples/smpi/NAS/dt.c b/examples/smpi/NAS/dt.c index 567ee17132..e38b99ee03 100644 --- a/examples/smpi/NAS/dt.c +++ b/examples/smpi/NAS/dt.c @@ -104,28 +104,8 @@ static int verify(char *bmname,double rnm2){ fprintf(stderr,"No such benchmark as %s.\n",bmname); verified = 0; } - }else if(class=='C') { - if(strstr(bmname,"BH")){ - verify_value = 0.0; - }else if(strstr(bmname,"WH")){ - verify_value = 0.0; - }else if(strstr(bmname,"SH")){ - verify_value = 0.0; - }else{ - fprintf(stderr,"No such benchmark as %s.\n",bmname); - verified = -1; - } - }else if(class=='D') { - if(strstr(bmname,"BH")){ - verify_value = 0.0; - }else if(strstr(bmname,"WH")){ + }else if(class=='C' || class == 'D') { verify_value = 0.0; - }else if(strstr(bmname,"SH")){ - verify_value = 0.0; - }else{ - fprintf(stderr,"No such benchmark as %s.\n",bmname); - } - verified = -1; }else{ fprintf(stderr,"No such class as %c.\n",class); } @@ -148,26 +128,28 @@ static int verify(char *bmname,double rnm2){ static int ipowMod(int a,long long int n,int md){ int seed=1,q=a,r=1; + int exp = n; if(n<0){ fprintf(stderr,"ipowMod: exponent must be nonnegative exp=%lld\n",n); - n=-n; /* temp fix */ + exp=-n; /* temp fix */ /* return 1; */ } if(md<=0){ fprintf(stderr,"ipowMod: module must be positive mod=%d",md); return 1; } - if(n==0) return 1; - while(n>1){ - int n2 = n/2; + if(n==0) + return 1; + while(exp>1){ + int n2 = exp/2; if (n2*2==n){ seed = (q*q)%md; q=seed; - n = n2; + exp = n2; }else{ seed = (r*q)%md; r=seed; - n = n-1; + exp = exp -1; } } seed = (r*q)%md; @@ -177,16 +159,18 @@ static int ipowMod(int a,long long int n,int md){ static DGraph *buildSH(const char cls){ /* Nodes of the graph must be topologically sorted to avoid MPI deadlock. */ DGraph *dg; - int numSources=num_sources; /* must be power of 2 */ - int numOfLayers=0,tmpS=numSources>>1; + unsigned int numSources=num_sources; /* must be power of 2 */ + int numOfLayers=0; + unsigned int tmpS=numSources>>1; int firstLayerNode=0; DGArc *ar=NULL; DGNode *nd=NULL; - int mask=0x0,ndid=0,ndoff=0; - int i=0,j=0; + unsigned int mask=0x0; + int ndid=0,ndoff=0; + unsigned int i=0,j=0; char nm[BLOCK_SIZE]; - sprintf(nm,"DT_SH.%c",cls); + snprintf(nm,BLOCK_SIZE -1,"DT_SH.%c",cls); dg=newDGraph(nm); while(tmpS>1){ @@ -194,14 +178,14 @@ static DGraph *buildSH(const char cls){ tmpS>>=1; } for(i=0;ilen); - } -} - static double CheckVal(Arr *feat){ double csum=0.0; for(int i=0;ilen;i++){ -- 2.20.1