Skip to content

Commit

Permalink
Begin updating C and Python wrappers to use hybrid dealiasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncbowman committed May 30, 2023
1 parent e4f6889 commit 754ff7c
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 277 deletions.
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ examplecconvsame: examplecconvsame.o $(EXTRA:=.o)
exampleconv: exampleconv.o $(HYBRID:=.o)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@

examplecconv2: examplecconv2.o $(EXTRA:=.o)
exampleconv2: exampleconv2.o $(HYBRID:=.o)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@

exampleconv2: exampleconv2.o $(EXTRA:=.o)
examplecconv2: examplecconv2.o $(EXTRA:=.o)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@

examplecconv3: examplecconv3.o $(EXTRA:=.o)
Expand Down
10 changes: 5 additions & 5 deletions examples/exampleconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ int main(int argc, char* argv[])
{
fftw::maxthreads=get_max_threads();

#ifndef __SSE2__
fftw::effort |= FFTW_NO_SIMD;
#endif

size_t A=2; // Two inputs
size_t B=1; // One output

size_t L=8; // Length of input arrays
size_t M=16; // Minimal padded length for dealiasing via 1/2 padding

#ifndef __SSE2__
fftw::effort |= FFTW_NO_SIMD;
#endif
size_t M=15; // Minimal padded length for dealiasing via 1/2 padding

// allocate arrays:
Complex *f=ComplexAlign(L);
Expand Down
65 changes: 30 additions & 35 deletions examples/exampleconv2.cc
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
#include "Complex.h"
#include "convolution.h"
#include "convolve.h"
#include "Array.h"

// Compile with:
// g++ -I .. -fopenmp exampleconv2.cc ../convolution.cc ../fftw++.cc -lfftw3 -lfftw3_omp
// g++ -I .. -fopenmp exampleconv2.cc ../convolve.cc ../fftw++.cc ../parallel.cc -lfftw3 -lfftw3_omp

using namespace std;
using namespace utils;
using namespace Array;
using namespace fftwpp;
using namespace parallel;

// size of problem
size_t m=8;

size_t mx=4;
size_t my=4;

inline void init(array2<Complex>& f, array2<Complex>& g, size_t M=1)
inline void init(array2<Complex>& f, array2<Complex>& g)
{
size_t stop=2*mx-1;
size_t stopoffset=stop;
double factor=1.0/sqrt((double) M);
for(size_t s=0; s < M; ++s) {
double S=sqrt(1.0+s);
double ffactor=S*factor;
double gfactor=1.0/S*factor;
for(size_t i=0; i < stop; ++i) {
size_t I=s*stopoffset+i;
for(size_t j=0; j < my; j++) {
f[I][j]=ffactor*Complex(i,j);
g[I][j]=gfactor*Complex(2*i,j+1);
}
size_t Lx=f.Nx();
size_t Ly=f.Nx();
for(size_t i=0; i < Lx; ++i) {
for(size_t j=0; j < Ly; j++) {
f[i][j]=Complex(i,j);
g[i][j]=Complex(2*i,j+1);
}
}
}
Expand All @@ -44,27 +31,35 @@ int main(int argc, char* argv[])
fftw::effort |= FFTW_NO_SIMD;
#endif

cout << "2D centered Hermitian-symmetric convolution:" << endl;
size_t A=2; // Two inputs
size_t B=1; // One output

size_t Lx=4; // Length of input arrays in x direction
size_t Ly=4; // Length of input arrays in y direction
size_t Mx=7; // Minimal padded length for dealiasing via 1/2 padding
size_t My=7; // Minimal padded length for dealiasing via 1/2 padding

cout << "2D non-centered complex convolution:" << endl;

size_t align=sizeof(Complex);
array2<Complex> f(2*mx-1,my,align);
array2<Complex> g(2*mx-1,my,align);
array2<Complex> f(Lx,Ly,align);
array2<Complex> g(Lx,Ly,align);
Complex *F[]={f,g};

init(f,g);

cout << "\ninput:" << endl;
cout << "f:" << endl << f;
cout << "g:" << endl << g;

/*
cout << "input after symmetrization (done automatically):" << endl;
HermitianSymmetrizeX(mx,my,mx-1,f);
HermitianSymmetrizeX(mx,my,mx-1,g);
cout << "f:" << endl << f << endl;
cout << "g:" << endl << g << endl;
*/
Application appx(A,B,multNone,fftw::maxthreads);
fftPad fftx(Lx,Mx,appx,Ly);
Application appy(A,B,multbinary,appx);
fftPad ffty(Ly,My,appy);
Convolution2 C(&fftx,&ffty);

C.convolve(F);

bool symmetrize=true;
ImplicitHConvolution2 C(mx,my);
C.convolve(f,g,symmetrize);
cout << "\noutput:" << endl << f;

return 0;
Expand Down
7 changes: 4 additions & 3 deletions wrappers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ endif

LDFLAGS += -lfftw3_omp -lfftw3 -lm -lstdc++

FILES = fftw++ parallel convolution
FILES = fftw++ parallel convolve

all: _fftwpp.so cexample fexample
#all: _fftwpp.so cexample fexample
all: _fftwpp.so cexample

fftw++.o: ../fftw++.cc ../fftw++.h
$(CXX) $(CXXFLAGS) -c -o $@ $< $(LDFLAGS)

parallel.o: ../parallel.cc ../parallel.h
$(CXX) $(CXXFLAGS) -c -o $@ $< $(LDFLAGS)

convolution.o: ../convolution.cc ../convolution.h
convolve.o: ../convolve.cc ../convolve.h
$(CXX) $(CXXFLAGS) -c -o $@ $< $(LDFLAGS)

cfftw++.o: cfftw++.cc cfftw++.h
Expand Down
Loading

0 comments on commit 754ff7c

Please sign in to comment.