Skip to content
Snippets Groups Projects
Commit b760492a authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

fixes fft test

parent 26a6d468
Branches
Tags
No related merge requests found
Pipeline #93882 passed
FFTW_DIR=${CUSTOM_INSTALL_PATH}/fftw-3.3.9_mpich-3.3.2
FFTW_BASE=${FFTW_DIR}
FFTW_OPENMP_LIB=-L${FFTW_BASE}/lib -lfftw3_omp -lfftw3f_omp
FFTW_LIB=-L${FFTW_BASE}/lib -lfftw3_mpi -lfftw3 -lfftw3f_mpi -lfftw3f
MPICXX=mpicxx
LINKER=
CFLAGS=
LIBDIR=
test_fftw:
${MPICXX} \
-I${FFTW_BASE}/include \
-DPINCHECK_FOUND \
${TURTLE_COMPILATION_FLAGS} \
-I${FFTW_ROOT}/include \
-I${PINCHECK_ROOT}/include \
-Wall \
-g \
-Wfatal-errors \
......
......@@ -5,9 +5,11 @@
/****************************/
// parameters
const int nx = 128;
const int nx = 4096;
const int ny = 8;
const int nz = 128;
const int nz = 4096;
const int nsteps = 100;
/****************************/
......@@ -41,13 +43,12 @@ int test_fft(
FFTW_MPI_DEFAULT_BLOCK, FFTW_MPI_DEFAULT_BLOCK,
MPI_COMM_WORLD,
&local_n0, &local_0_start,
&local_n1, &local_1_start
);
&local_n1, &local_1_start);
/************/
/* ALLOCATE */
/************/
data = fftw_alloc_real(local_size);
data = fftw_alloc_real(local_size*2);
c2r_plan = fftw_mpi_plan_many_dft_c2r(
3, nfftw, 1,
......@@ -57,36 +58,47 @@ int test_fft(
MPI_COMM_WORLD,
fftw_plan_rigor | FFTW_MPI_TRANSPOSED_IN);
//r2c_plan = fftw_mpi_plan_many_dft_r2c(
// 3, nfftw, 1,
// FFTW_MPI_DEFAULT_BLOCK, FFTW_MPI_DEFAULT_BLOCK,
// data,
// (fftw_complex*)(data),
// MPI_COMM_WORLD,
// fftw_plan_rigor | FFTW_MPI_TRANSPOSED_OUT);
assert(c2r_plan != NULL);
r2c_plan = fftw_mpi_plan_many_dft_r2c(
3, nfftw, 1,
FFTW_MPI_DEFAULT_BLOCK, FFTW_MPI_DEFAULT_BLOCK,
data,
(fftw_complex*)(data),
MPI_COMM_WORLD,
fftw_plan_rigor | FFTW_MPI_TRANSPOSED_OUT);
assert(r2c_plan != NULL);
//DEBUG_MSG("r2c plan representation\n");
//print_plan(r2c_plan);
//DEBUG_MSG("c2r plan representation\n");
//print_plan(c2r_plan);
DEBUG_MSG("r2c plan representation\n");
print_plan(r2c_plan);
DEBUG_MSG("c2r plan representation\n");
print_plan(c2r_plan);
//// fill up data
//std::random_device rd{};
//std::mt19937 gen{rd()};
// fill up data
std::random_device rd{};
std::mt19937 gen{rd()};
//std::normal_distribution<> gaussian;
std::normal_distribution<> gaussian;
//for (ptrdiff_t ii = 0; ii < local_size; ii++)
// data[ii] = gaussian(gen);
for (ptrdiff_t ii = 0; ii < local_size; ii++)
data[ii] = gaussian(gen);
//// start mpi profiling
//MPI_Pcontrol(5);
// start mpi profiling
MPI_Pcontrol(5);
//fftw_execute(r2c_plan);
for (ptrdiff_t tt = 0; tt < nsteps; tt++)
{
fftw_execute(r2c_plan);
fftw_execute(c2r_plan);
#pragma omp parallel for schedule(static)
for(ptrdiff_t ii = 0; ii < local_size; ii++)
data[ii] /= nx*ny*nz;
}
//// stop mpi profiling
//MPI_Pcontrol(-5);
// stop mpi profiling
MPI_Pcontrol(-5);
/************/
......@@ -94,7 +106,7 @@ int test_fft(
/************/
fftw_free(data);
fftw_destroy_plan(c2r_plan);
//fftw_destroy_plan(r2c_plan);
fftw_destroy_plan(r2c_plan);
return EXIT_SUCCESS;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment