Skip to content

Commit

Permalink
Add missing options.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncbowman committed Nov 12, 2022
1 parent 665bd3a commit 5a7c8e1
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 90 deletions.
31 changes: 15 additions & 16 deletions tests/cconv2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ unsigned int ny=0;
unsigned int mx=4;
unsigned int my=0;

bool Direct=false, Implicit=true, Explicit=false, Pruned=false;

inline void init(Complex **F, unsigned int nxp, unsigned int nyp, unsigned int A)
{
if(A%2 == 0) {
Expand Down Expand Up @@ -60,11 +58,15 @@ int main(int argc, char* argv[])
{
fftw::maxthreads=get_max_threads();

unsigned int A=2;
unsigned int B=1;

bool Direct=false;
bool Implicit=true;
bool Explicit=false;
bool Output=false;
bool Normalized=true;
bool Pruned=false;

unsigned int A=2;
unsigned int B=1;

int stats=0; // Type of statistics used in timing test.

Expand Down Expand Up @@ -156,7 +158,14 @@ int main(int argc, char* argv[])

size_t align=ALIGNMENT;
array2<Complex> h0;
if(Direct) h0.Allocate(mx,my,align);
if(Direct) {
if(!Normalized) {
cerr << "-u option is incompatible with -d." << endl;
exit(-1);
}

h0.Allocate(mx,my,align);
}
int nxp=Explicit ? nx : mx;
int nyp=Explicit ? ny : my;

Expand Down Expand Up @@ -212,14 +221,6 @@ int main(int argc, char* argv[])
f[i][j] *= norm;
}

Complex sum=0.0;
for(unsigned int i=0; i < mx; i++) {
for(unsigned int j=0; j < my; j++) {
sum += f[i][j];
}
}
cout << "sum=" << sum << endl;

if(Direct) {
for(unsigned int i=0; i < mx; i++)
for(unsigned int j=0; j < my; j++)
Expand All @@ -232,8 +233,6 @@ int main(int argc, char* argv[])
cout << f[i][j] << "\t";
cout << endl;
}
} else {
cout << f[0][0] << endl;
}
}

Expand Down
41 changes: 29 additions & 12 deletions tests/cconv3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ unsigned int mx=4;
unsigned int my=0;
unsigned int mz=0;

bool Direct=false, Implicit=true, Explicit=false, Pruned=false;


inline void init(Complex **F,
unsigned int nxp, unsigned int nyp, unsigned int nzp,
unsigned int A)
Expand Down Expand Up @@ -60,6 +57,13 @@ int main(int argc, char* argv[])
{
fftw::maxthreads=get_max_threads();

bool Direct=false;
bool Implicit=true;
bool Explicit=false;
bool Output=false;
bool Normalized=true;
bool Pruned=false;

unsigned int A=2; // Number of independent inputs
unsigned int B=1; // Number of independent outputs

Expand All @@ -73,7 +77,7 @@ int main(int argc, char* argv[])
optind=0;
#endif
for (;;) {
int c = getopt(argc,argv,"hdeiptA:B:N:m:x:y:z:n:T:S:");
int c = getopt(argc,argv,"hdeiptA:B:N:Om:x:y:z:n:T:uS:");
if (c == -1) break;

switch (c) {
Expand Down Expand Up @@ -105,6 +109,9 @@ int main(int argc, char* argv[])
case 'N':
N=atoi(optarg);
break;
case 'O':
Output=true;
break;
case 'm':
mx=my=mz=atoi(optarg);
break;
Expand All @@ -117,6 +124,9 @@ int main(int argc, char* argv[])
case 'z':
mz=atoi(optarg);
break;
case 'u':
Normalized=false;
break;
case 'n':
N0=atoi(optarg);
break;
Expand Down Expand Up @@ -153,7 +163,13 @@ int main(int argc, char* argv[])
size_t align=ALIGNMENT;

array3<Complex> h0;
if(Direct) h0.Allocate(mx,my,mz,align);
if(Direct) {
h0.Allocate(mx,my,mz,align);
if(!Normalized) {
cerr << "-u option is incompatible with -d." << endl;
exit(-1);
}
}

int nxp=Explicit ? nx : mx;
int nyp=Explicit ? ny : my;
Expand Down Expand Up @@ -204,21 +220,22 @@ int main(int argc, char* argv[])
cout << endl;
timings("Implicit",mx*my*mz,T,N,stats);

if(Direct)
if(Normalized) {
double norm=0.125/(mx*my*mz);
for(unsigned int i=0; i < mx; i++)
for(unsigned int j=0; j < my; j++)
for(unsigned int k=0; k < mz; k++)
h0[i][j][k]=f[i][j][k];
f[i][j][k] *= norm;
}

Complex sum=0.0;
if(Direct)
for(unsigned int i=0; i < mx; i++)
for(unsigned int j=0; j < my; j++)
for(unsigned int k=0; k < mz; k++)
sum += f[i][j][k];
cout << endl;
if(mx*my*mz < outlimit)
h0[i][j][k]=f[i][j][k];

if(Output)
cout << f;
cout << endl << "sum=" << sum << endl;
}

if(Explicit) {
Expand Down
39 changes: 11 additions & 28 deletions tests/conv2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,30 +247,19 @@ int main(int argc, char* argv[])
h0[i][j]=f[i+!xcompact][j];
}

Complex sum=0.0;
for(unsigned int i=!xcompact; i < nxp; i++) {
for(unsigned int j=0; j < my; j++) {
Complex v=f[i][j];
sum += v;
if(Output)
cout << v << "\t";
}
if(Output)
if(Output) {
for(unsigned int i=!xcompact; i < nxp; i++) {
for(unsigned int j=0; j < my; j++)
cout << f[i][j] << "\t";
cout << endl;
}
cout << endl;
}
cout << "sum=" << sum << endl;
cout << endl;
}

if(Explicit) {
unsigned int M=A/2;
ExplicitHConvolution2 C(nx,ny,mx,my,f,M,Pruned);
/*
Realmultiplier *mult;
if(Normalized) mult=multbinary;
else mult=multbinaryUnNormalized;
*/

cout << "threads=" << C.Threads() << endl << endl;

for(unsigned int i=0; i < N; ++i) {
Expand All @@ -291,19 +280,13 @@ int main(int argc, char* argv[])
h0[i][j]=f[offset+i][j];
}

Complex sum=0.0;
for(unsigned int i=offset; i < offset+2*mx-1; i++) {
for(unsigned int j=0; j < my; j++) {
Complex v=f[i][j];
sum += v;
if(Output)
cout << v << "\t";
}
if(Output)
if(Output) {
for(unsigned int i=offset; i < offset+2*mx-1; i++) {
for(unsigned int j=0; j < my; j++)
cout << f[i][j] << "\t";
cout << endl;
}
}
cout << "sum=" << sum << endl;
cout << endl;
}

if(Direct) {
Expand Down
80 changes: 46 additions & 34 deletions tests/conv3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ bool zcompact=true;

unsigned int threads;

bool Direct=false, Implicit=true, Explicit=false;

unsigned int outlimit=300;

bool Explicit=false;

inline void init(Complex **F,
unsigned int mx, unsigned int my, unsigned int mz,
unsigned int nxp, unsigned int nyp, unsigned int nzp,
Expand Down Expand Up @@ -117,6 +117,11 @@ int main(int argc, char* argv[])
{
threads=fftw::maxthreads=get_max_threads();

bool Direct=false;
bool Implicit=true;
bool Output=false;
bool Normalized=true;

unsigned int A=2; // Number of independent inputs
unsigned int B=1; // Number of outputs

Expand All @@ -130,7 +135,7 @@ int main(int argc, char* argv[])
optind=0;
#endif
for (;;) {
int c = getopt(argc,argv,"hdeipA:B:N:m:x:y:z:n:T:S:X:Y:Z:");
int c = getopt(argc,argv,"hdeipA:B:N:Om:x:y:z:n:T:uS:X:Y:Z:");
if (c == -1) break;

switch (c) {
Expand All @@ -156,6 +161,9 @@ int main(int argc, char* argv[])
case 'N':
N=atoi(optarg);
break;
case 'O':
Output=true;
break;
case 'm':
mx=my=mz=atoi(optarg);
break;
Expand All @@ -168,6 +176,9 @@ int main(int argc, char* argv[])
case 'z':
mz=atoi(optarg);
break;
case 'u':
Normalized=false;
break;
case 'n':
N0=atoi(optarg);
break;
Expand Down Expand Up @@ -232,7 +243,13 @@ int main(int argc, char* argv[])
array3<Complex> f(nxp,nyp,nzp,F[0]);

array3<Complex> h0;
if(Direct) h0.Allocate(mx,my,mz,align);
if(Direct) {
h0.Allocate(mx,my,mz,align);
if(!Normalized) {
cerr << "-u option is incompatible with -d." << endl;
exit(-1);
}
}

double *T=new double[N];

Expand All @@ -258,31 +275,33 @@ int main(int argc, char* argv[])
timings("Implicit",mx*my*mz,T,N,stats);
cout << endl;

if(Normalized) {
double norm=1.0/(27.0*mx*my*mz);
for(unsigned int i=!xcompact; i < nxp; ++i) {
for(unsigned int j=!ycompact; j < nyp; ++j) {
for(unsigned int k=0; k < mz; k++)
f[i][j][k] *= norm;
}
}
}

if(Direct) {
for(unsigned int i=0; i < mx; i++)
for(unsigned int j=0; j < my; j++)
for(unsigned int k=0; k < mz; k++)
h0[i][j][k]=f[i+!xcompact][j+!ycompact][k];
}

bool output=nxp*nyp*mz < outlimit;
Complex sum=0.0;
for(unsigned int i=!xcompact; i < nxp; ++i) {
for(unsigned int j=!ycompact; j < nyp; ++j) {
for(unsigned int k=0; k < mz; ++k) {
Complex v=f[i][j][k];
sum += v;
if(output)
cout << v << "\t";
}
if(output)
if(Output) {
for(unsigned int i=!xcompact; i < nxp; ++i) {
for(unsigned int j=!ycompact; j < nyp; ++j) {
for(unsigned int k=0; k < mz; ++k)
cout << f[i][j][k] << "\t";
cout << endl;
}
if(output)
}
cout << endl;
}
}
cout << "sum=" << sum << endl;
cout << endl;
}

if(Explicit) {
Expand Down Expand Up @@ -318,24 +337,17 @@ int main(int argc, char* argv[])
h0[i][j][k]=f[xoffset+i][yoffset+j][k];
}

bool output=2*(mx-1)*2*(my-1)*mz < outlimit;
Complex sum=0.0;
for(unsigned int i=xoffset; i < xoffset+2*mx-1; i++) {
for(unsigned int j=yoffset; j < yoffset+2*my-1; j++) {
for(unsigned int k=0; k < mz; ++k) {
Complex v=f[i][j][k];
sum += v;
if(output)
cout << v << "\t";
}
if(output)
if(Output) {
for(unsigned int i=xoffset; i < xoffset+2*mx-1; i++) {
for(unsigned int j=yoffset; j < yoffset+2*my-1; j++) {
for(unsigned int k=0; k < mz; ++k)
cout << f[i][j][k] << "\t";
cout << endl;
}
if(output)
}
cout << endl;
}
cout << endl;
}
cout << "sum=" << sum << endl;
cout << endl;
}

if(Direct) {
Expand Down

0 comments on commit 5a7c8e1

Please sign in to comment.