Commit 080e713b authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Fixed an output bug, where the IO buffers were empty for MPI workers

parent a1b6bc08
......@@ -277,9 +277,6 @@ IO::initNcFile(const shared_ptr<GridManager> &gridman, const shared_ptr<Crystal>
if(p.outputCompress())
CHK(nc_def_var_deflate(adf_id, intensities_var, NC_NOSHUFFLE, 1, 1));
// resize the read/write buffer
_adf_intensities_buffer.resize(gridman->adfDetectorGrid().size() * gridman->adfSliceCoords().size());
}
if(p.cbed()) {
......@@ -348,9 +345,6 @@ IO::initNcFile(const shared_ptr<GridManager> &gridman, const shared_ptr<Crystal>
if(p.outputCompress())
CHK(nc_def_var_deflate(cbed_id, cbed_intensity_var, NC_NOSHUFFLE, 1, 1));
// resize the write buffer
_cbed_intensities_buffer.resize(k_sampling_x * k_sampling_y * gridman->cbedSliceCoords().size());
}
// set up all variables
......@@ -508,6 +502,23 @@ IO::initNcFile(const shared_ptr<GridManager> &gridman, const shared_ptr<Crystal>
}
void
IO::initBuffers(const shared_ptr<GridManager> &gridman, const shared_ptr<Crystal> &crystal) {
Params &p = Params::getInstance();
auto &mpi_env = mpi::Environment::getInstance();
if(p.adf()) {
_adf_intensities_buffer.resize(gridman->adfDetectorGrid().size() * gridman->adfSliceCoords().size());
}
if(p.cbed()) {
unsigned int k_sampling_x = gridman->storedCbedSizeX();
unsigned int k_sampling_y = gridman->storedCbedSizeY();
// resize the write buffer
_cbed_intensities_buffer.resize(k_sampling_x * k_sampling_y * gridman->cbedSliceCoords().size());
}
}
void IO::writeParams(const shared_ptr<GridManager> &gridman) {
int id;
......
......@@ -67,6 +67,8 @@ namespace stemsalabim {
*/
void initNcFile(const std::shared_ptr<GridManager> &gridman, const std::shared_ptr<Crystal> &crystal);
void initBuffers(const std::shared_ptr<GridManager> &gridman, const std::shared_ptr<Crystal> &crystal);
/*!
* Appends the atomic positions of the current FP configuration to the AMBER group.
* @param fpman FP configuration manager
......
......@@ -142,6 +142,7 @@ void Simulation::init() {
_io->writeParams(_gridman);
_io->writeGrids(_gridman);
}
_io->initBuffers(_gridman, _crystal);
printMaster(output::fmt("Calculating on a real and k space lattice of %dx%d points.\n",
_gridman->samplingX(),
......@@ -299,9 +300,6 @@ void Simulation::run() {
};
// destroy ffts
//Wave::destroyPlans();
postStatus(STATUS_SIGNAL::FINISH_SIMULATION, SimulationState());
printMaster(output::fmt("Finished computation in %s. Find the results in %s.\n",
......@@ -380,7 +378,7 @@ void Simulation::calculatePixel(ScanPoint &point, const double defocus) {
// first, we cut off high frequencies from the wave if necessary. Note, that we follow
// the FFTW storage scheme for frequencies, hence, half of the values are in the lower
// range and the other half in the higher range of the wave function.
// range and the other half in the range of the wave function.
size_t bandwidth_lx = _gridman->storedCbedSizeX(true);
size_t bandwidth_ly = _gridman->storedCbedSizeY(true);
......@@ -666,6 +664,8 @@ void Simulation::multisliceSlave(const SimulationState &st) {
pixel_index_queue.append(package);
pixel_calculated += package.size();
for(unsigned int nt = 0; nt < _pool->numThreads(); nt++) {
_pool->enqueue([&] {
unsigned int pix_index;
......
......@@ -320,55 +320,6 @@ namespace stemsalabim {
void init(unsigned int lx, unsigned int ly) {
init(lx, ly, std::complex<float>(0, 0));
}
//
// const fftwf_plan &getForwardPlan(unsigned int lx, unsigned int ly, bool quick_planning) {
// static std::map<std::tuple<unsigned int, unsigned int>, fftwf_plan> cache;
// static std::mutex _s_init_mutex;
//
// std::unique_lock<std::mutex> qlck(_s_init_mutex);
//
// auto key = std::make_tuple(lx, ly);
//
// if(cache.count(key) > 0)
// return cache[key];
//
// std::vector<std::complex<float>, fftwAllocator<std::complex<float>>> data(lx * ly,
// std::complex<float>(1.0, 0.0));
//
// cache[key] = fftwf_plan_dft_2d(lx,
// ly,
// reinterpret_cast<fftwf_complex *>(&data[0]),
// reinterpret_cast<fftwf_complex *>(&data[0]),
// FFTW_BACKWARD,
// quick_planning ? FFTW_ESTIMATE : FFTW_PATIENT);
//
// return cache[key];
// }
//
// const fftwf_plan &getBackwardPlan(unsigned int lx, unsigned int ly, bool quick_planning) {
//
// static std::map<std::tuple<unsigned int, unsigned int>, fftwf_plan> cache;
// static std::mutex _s_init_mutex;
//
// std::unique_lock<std::mutex> qlck(_s_init_mutex);
//
// auto key = std::make_tuple(lx, ly);
//
// if(cache.count(key) > 0)
// return cache[key];
//
// std::vector<std::complex<float>, fftwAllocator<std::complex<float>>> data(lx * ly,
// std::complex<float>(1.0, 0.0));
//
// cache[key] = fftwf_plan_dft_2d(lx,
// ly,
// reinterpret_cast<fftwf_complex *>(&data[0]),
// reinterpret_cast<fftwf_complex *>(&data[0]),
// FFTW_FORWARD,
// quick_planning ? FFTW_ESTIMATE : FFTW_PATIENT);
//
// return cache[key];
// }
/*!
* Initialize the function with a given complex value for all elements. If the data array is already
......@@ -474,7 +425,7 @@ namespace stemsalabim {
* Get handle to the raw data of the WF.
* @return complex valued data vector
*/
const std::vector<std::complex<float>, fftwAllocator<std::complex<float>>> &data() const {
const FFTWCache::data_type &data() const {
return _data;
}
......@@ -483,12 +434,10 @@ namespace stemsalabim {
unsigned int _ly{0};
bool _is_kspace{false};
bool _fftw_quick_planning{false};
bool _initialized{false};
std::vector<std::complex<float>, fftwAllocator<std::complex<float>>> _data;
FFTWCache::data_type _data;
};
}
......
Markdown is supported
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