Commit c4143bfe authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

introduce parameter for fftw_plan_rigor

parent ec926152
Pipeline #36890 failed with stage
in 16 minutes and 18 seconds
......@@ -120,6 +120,7 @@ class DNS(_code):
return None
def generate_default_parameters(self):
# these parameters are relevant for all DNS classes
self.parameters['fftw_planner_type'] = 'FFTW_ESTIMATE'
self.parameters['dealias_type'] = int(1)
self.parameters['dkx'] = float(1.0)
self.parameters['dky'] = float(1.0)
......
......@@ -118,6 +118,7 @@ class PP(_code):
return None
def generate_default_parameters(self):
# these parameters are relevant for all PP classes
self.parameters['fftw_planner_type'] = 'FFTW_ESTIMATE'
self.parameters['dealias_type'] = int(1)
self.parameters['dkx'] = float(1.0)
self.parameters['dky'] = float(1.0)
......
......@@ -119,6 +119,7 @@ class TEST(_code):
return None
def generate_default_parameters(self):
# these parameters are relevant for all TEST classes
self.parameters['fftw_planner_type'] = 'FFTW_ESTIMATE'
self.parameters['dealias_type'] = int(1)
self.parameters['dkx'] = float(1.0)
self.parameters['dky'] = float(1.0)
......
......@@ -26,6 +26,8 @@
#define FFTW_INTERFACE_HPP
#include <fftw3-mpi.h>
#include <map>
#include <string>
#ifdef USE_FFTWESTIMATE
#define DEFAULT_FFTW_FLAG FFTW_ESTIMATE
......
......@@ -31,6 +31,13 @@
#define NDEBUG
std::map<std::string, unsigned> fftw_planner_string_to_flag = {
{"FFTW_ESTIMATE", FFTW_ESTIMATE},
{"FFTW_MEASURE", FFTW_MEASURE},
{"FFTW_PATIENT", FFTW_PATIENT},
{"parameter does not exist", DEFAULT_FFTW_FLAG},
};
template <class rnumber>
int clip_zero_padding(
field_descriptor<rnumber> *f,
......
......@@ -34,6 +34,8 @@
extern int myrank, nprocs;
extern std::map<std::string, unsigned> fftw_planner_string_to_flag;
/* given two arrays of the same dimension, we do a simple resize in
* Fourier space: either chop off high modes, or pad with zeros.
* the arrays are assumed to use 3D mpi fftw layout.
......
......@@ -2,6 +2,7 @@
#include <cmath>
#include "NSVE.hpp"
#include "scope_timer.hpp"
#include "fftw_tools.hpp"
template <typename rnumber>
......@@ -37,11 +38,11 @@ int NSVE<rnumber>::initialize(void)
simname.c_str(),
nx, ny, nz,
dkx, dky, dkz,
DEFAULT_FFTW_FLAG);
fftw_planner_string_to_flag[this->fftw_plan_type]);
this->tmp_vec_field = new field<rnumber, FFTW, THREE>(
nx, ny, nz,
this->comm,
DEFAULT_FFTW_FLAG);
fftw_planner_string_to_flag[this->fftw_plan_type]);
this->fs->checkpoints_per_file = checkpoints_per_file;
......@@ -161,6 +162,7 @@ int NSVE<rnumber>::read_parameters(void)
this->max_vorticity_estimate = hdf5_tools::read_value<double>(parameter_file, "parameters/max_vorticity_estimate");
std::string tmp = hdf5_tools::read_string(parameter_file, "parameters/forcing_type");
snprintf(this->forcing_type, 511, "%s", tmp.c_str());
this->fftw_plan_type = hdf5_tools::read_string(parameter_file, "parameters/fftw_plan_type");
H5Fclose(parameter_file);
return EXIT_SUCCESS;
}
......
......@@ -53,6 +53,7 @@ class NSVE: public direct_numerical_simulation
double max_velocity_estimate;
double max_vorticity_estimate;
double nu;
std::string fftw_plan_type;
/* other stuff */
vorticity_equation<rnumber, FFTW> *fs;
......
#include <string>
#include <cmath>
#include "NSVE_field_stats.hpp"
#include "fftw_tools.hpp"
#include "scope_timer.hpp"
......@@ -12,7 +13,7 @@ int NSVE_field_stats<rnumber>::initialize(void)
this->vorticity = new field<rnumber, FFTW, THREE>(
nx, ny, nz,
this->comm,
DEFAULT_FFTW_FLAG);
fftw_planner_string_to_flag[this->fftw_plan_type]);
this->vorticity->real_space_representation = false;
hid_t parameter_file = H5Fopen(
(this->simname + std::string(".h5")).c_str(),
......@@ -43,6 +44,7 @@ int NSVE_field_stats<rnumber>::initialize(void)
this->vorticity->clayout->starts,
this->vorticity->clayout->comm);
}
this->fftw_plan_type = hdf5_tools::read_string(parameter_file, "parameters/fftw_plan_type");
H5Fclose(parameter_file);
return EXIT_SUCCESS;
}
......
......@@ -42,6 +42,8 @@ class NSVE_field_stats: public postprocess
private:
field_binary_IO<rnumber, COMPLEX, THREE> *bin_IO;
public:
std::string fftw_plan_type;
field<rnumber, FFTW, THREE> *vorticity;
NSVE_field_stats(
......
......@@ -36,7 +36,7 @@ int field_output_test<rnumber>::do_work(void)
field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
std::default_random_engine rgen;
std::normal_distribution<rnumber> rdist;
rgen.seed(1);
......
......@@ -44,11 +44,11 @@ int field_test<rnumber>::do_work(void)
field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
field<rnumber, FFTW, ONE> *scal_field_alt = new field<rnumber, FFTW, ONE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
std::default_random_engine rgen;
std::normal_distribution<rnumber> rdist;
rgen.seed(2);
......
......@@ -12,7 +12,7 @@ int filter_test<rnumber>::initialize(void)
this->scal_field = new field<rnumber, FFTW, ONE>(
nx, ny, nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
this->kk = new kspace<FFTW, SMOOTH>(
this->scal_field->clayout, this->dkx, this->dky, this->dkz);
......
......@@ -110,7 +110,7 @@ int joint_acc_vel_stats<rnumber>::work_on_current_iteration(void)
vel = new field<rnumber, FFTW, THREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
this->vorticity->fftw_plan_rigor);
invert_curl(kk, this->ve->cvorticity, vel);
vel->ift();
......
......@@ -12,7 +12,7 @@ int native_binary_to_hdf5<rnumber>::initialize(void)
this->vec_field = new field<rnumber, FFTW, THREE>(
nx, ny, nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
this->vec_field->real_space_representation = false;
this->bin_IO = new field_binary_IO<rnumber, COMPLEX, THREE>(
this->vec_field->clayout->sizes,
......
......@@ -2,6 +2,7 @@
#include <cmath>
#include <random>
#include "symmetrize_test.hpp"
#include "fftw_tools.hpp"
#include "scope_timer.hpp"
......@@ -31,6 +32,7 @@ int symmetrize_test<rnumber>::read_parameters()
H5P_DEFAULT);
this->random_seed = hdf5_tools::read_value<int>(
parameter_file, "/parameters/random_seed");
this->fftw_plan_type = hdf5_tools::read_string(parameter_file, "parameters/fftw_plan_type");
H5Fclose(parameter_file);
return EXIT_SUCCESS;
}
......@@ -44,13 +46,13 @@ int symmetrize_test<rnumber>::do_work(void)
field<rnumber, FFTW, THREE> *test_field0 = new field<rnumber, FFTW, THREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
fftw_planner_string_to_flag[this->fftw_plan_type]);
DEBUG_MSG("finished allocating field0\n");
DEBUG_MSG("about to allocate field1\n");
field<rnumber, FFTW, THREE> *test_field1 = new field<rnumber, FFTW, THREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
fftw_planner_string_to_flag[this->fftw_plan_type]);
DEBUG_MSG("finished allocating field1\n");
std::default_random_engine rgen;
std::normal_distribution<rnumber> rdist;
......
......@@ -42,6 +42,7 @@ template <typename rnumber>
class symmetrize_test: public test
{
public:
std::string fftw_plan_type;
int random_seed;
symmetrize_test(
......
......@@ -30,18 +30,18 @@ int test_interpolation<rnumber>::initialize(void)
this->vorticity = new field<rnumber, FFTW, THREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
this->vorticity->real_space_representation = false;
this->velocity = new field<rnumber, FFTW, THREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
this->nabla_u = new field<rnumber, FFTW, THREExTHREE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
FFTW_ESTIMATE);
this->kk = new kspace<FFTW, SMOOTH>(
this->vorticity->clayout, this->dkx, this->dky, this->dkz);
......
......@@ -208,17 +208,26 @@ std::string hdf5_tools::read_string(
const hid_t group,
const std::string dset_name)
{
hid_t dset = H5Dopen(group, dset_name.c_str(), H5P_DEFAULT);
hid_t space = H5Dget_space(dset);
hid_t memtype = H5Dget_type(dset);
char *string_data = (char*)malloc(256);
H5Dread(dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string_data);
std::string std_string_data = std::string(string_data);
free(string_data);
H5Sclose(space);
H5Tclose(memtype);
H5Dclose(dset);
return std_string_data;
if (H5Lexists(group, dset_name.c_str(), H5P_DEFAULT))
{
hid_t dset = H5Dopen(group, dset_name.c_str(), H5P_DEFAULT);
hid_t space = H5Dget_space(dset);
hid_t memtype = H5Dget_type(dset);
char *string_data = (char*)malloc(256);
H5Dread(dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string_data);
std::string std_string_data = std::string(string_data);
free(string_data);
H5Sclose(space);
H5Tclose(memtype);
H5Dclose(dset);
return std_string_data;
}
else
{
DEBUG_MSG("attempted to read dataset %s which does not exist.\n",
dset_name.c_str());
return std::string("parameter does not exist");
}
}
template
......
......@@ -273,7 +273,7 @@ class CompileLibCommand(distutils.cmd.Command):
def get_file_dependency_list(src_file):
p = subprocess.Popen(
['g++', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
['g++', '-std=c++11', '-Ibfps/cpp', '-MM', 'bfps/cpp/' + src_file + '.cpp'],
stdout = subprocess.PIPE)
out, err = p.communicate()
p.terminate()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment