Commit 9cd0fe01 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Eliminated anonymous namespaces and made all compiler warnings disappear

parent 265ba2ac
......@@ -138,7 +138,7 @@ void GridManager::generateGrids() {
for(unsigned int iy = 0; iy < samplingY(); iy++) {
double k2 = sqrt(pow(kx(ix), 2) + pow(ky(iy), 2)) * p.wavelength();
unsigned int index = algorithms::getIndexOfAdaptiveSpace(k2 * 1e3,
int index = algorithms::getIndexOfAdaptiveSpace(k2 * 1e3,
get<0>(p.adfDetectorAngles()),
get<1>(p.adfDetectorAngles()),
get<2>(p.adfDetectorAngles()),
......
......@@ -904,7 +904,7 @@ string getTempFileName() {
}
void IO::writeTemporaryResult(unsigned int idefocus, unsigned int iconf,
const shared_ptr<GridManager> &gridman, ScanPoint &point,
ScanPoint &point,
shared_ptr<memory::buffer::number_buffer<float>> &ibuf,
shared_ptr<memory::buffer::number_buffer<float>> &cbuf) {
......
......@@ -103,7 +103,7 @@ namespace stemsalabim {
std::shared_ptr<memory::buffer::number_buffer<float>> &cbuf);
static void writeTemporaryResult(unsigned int idefocus, unsigned int iconf,
const std::shared_ptr<GridManager> &gridman, ScanPoint &point,
ScanPoint &point,
std::shared_ptr<memory::buffer::number_buffer<float>> &ibuf,
std::shared_ptr<memory::buffer::number_buffer<float>> &cbuf);
......
......@@ -32,8 +32,6 @@ using namespace stemsalabim;
void Simulation::init() {
high_resolution_clock::time_point init_start = high_resolution_clock::now();
Wave::fft_duration_nanoseconds = 0;
Params &p = Params::getInstance();
auto &mpi_env = mpi::Environment::getInstance();
......@@ -110,10 +108,13 @@ void Simulation::init() {
vector<double> numbers;
if(mpi_env.isMaster()) {
numbers.resize(number_fp_random_numbers);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
normal_distribution<double> distribution(0.0, 1.0);
auto rgen = p.getRandomGenerator();
for(unsigned long i = 0; i < number_fp_random_numbers; ++i)
numbers[i] = distribution(rgen);
#pragma GCC diagnostic pop
}
mpi_env.broadcast(numbers, mpi::Environment::MASTER);
......@@ -301,14 +302,6 @@ void Simulation::run() {
// destroy ffts
//Wave::destroyPlans();
int num_effective_threads = prms.numberOfThreads() - 1;
if(mpi_env.isSlave())
num_effective_threads++;
std::chrono::nanoseconds num_nanoseconds(Wave::fft_duration_nanoseconds);
output::print("Total time spent doing FFTs: %s (on %d threads).\n",
output::humantime(std::chrono::duration_cast<std::chrono::milliseconds>(num_nanoseconds)),
num_effective_threads);
postStatus(STATUS_SIGNAL::FINISH_SIMULATION, SimulationState());
printMaster(output::fmt("Finished computation in %s. Find the results in %s.\n",
......@@ -552,7 +545,6 @@ void Simulation::multisliceMaster(const SimulationState &st) {
if(sp.hasAdfIntensities() || sp.hasCbedIntensities())
IO::writeTemporaryResult(st.idefocus(),
st.iconf(),
_gridman,
sp,
_adf_intensity_buffer,
_cbed_intensity_buffer);
......@@ -578,7 +570,6 @@ void Simulation::multisliceMaster(const SimulationState &st) {
ScanPoint &sp = work_packages[px_idx];
IO::writeTemporaryResult(st.idefocus(),
st.iconf(),
_gridman,
sp,
_adf_intensity_buffer,
_cbed_intensity_buffer);
......@@ -699,7 +690,6 @@ void Simulation::multisliceSlave(const SimulationState &st) {
ScanPoint &sp = work_packages[px_idx];
IO::writeTemporaryResult(st.idefocus(),
st.iconf(),
_gridman,
sp,
_adf_intensity_buffer,
_cbed_intensity_buffer);
......@@ -786,8 +776,6 @@ void Simulation::generatePropagator() {
void Simulation::propagate(Wave &wave, bool do_backward_fft) {
Params &p = Params::getInstance();
// propagate and bandwidth limit
// see page 145ff in Kirkland and 402 - 405 in autostem.cpp of his code.
wave.forwardFFT();
......
......@@ -28,7 +28,7 @@
#include "Crystal.hpp"
#include "../utilities/Wave.hpp"
namespace stemsalabim { namespace {
namespace stemsalabim {
/*!
* Class to calculate and cache atomic structure factors.
......@@ -44,6 +44,7 @@ namespace stemsalabim { namespace {
*/
static const Wave & cache(std::shared_ptr<Element> e) {
static std::map<std::string, Wave> _s_potential_cache;
static std::mutex _cache_lock;
std::unique_lock<std::mutex> qlck(_cache_lock);
......@@ -66,7 +67,7 @@ namespace stemsalabim { namespace {
int grating_atompot = 8 * algorithms::round_even(p.samplingDensity() * p.maxPotentialRadius());
double length_atompot = 2 * p.maxPotentialRadius();
_s_grating_scale = grating_atompot / length_atompot;
double grating_scale = gratingScale();
//potential_cache.initPlans((unsigned int) grating_atompot, (unsigned int) grating_atompot, true);
......@@ -105,12 +106,12 @@ namespace stemsalabim { namespace {
for(int ix = 0; ix < (int) potential_cache.lx(); ++ix) {
for(int iy = 0; iy < (int) potential_cache.ly(); ++iy) {
x = ix / _s_grating_scale;
y = iy / _s_grating_scale;
x = ix / grating_scale;
y = iy / grating_scale;
if(ix > grating_atompot / 2)
x = (ix - grating_atompot) / _s_grating_scale;
x = (ix - grating_atompot) / grating_scale;
if(iy > grating_atompot / 2)
y = (iy - grating_atompot) / _s_grating_scale;
y = (iy - grating_atompot) / grating_scale;
double radius = sqrt(pow(x, 2) + pow(y, 2));
......@@ -154,24 +155,19 @@ namespace stemsalabim { namespace {
* @return scale of the grating
*/
static double gratingScale() {
return _s_grating_scale;
Params &p = Params::getInstance();
int grating_atompot = 8 * algorithms::round_even(p.samplingDensity() * p.maxPotentialRadius());
double length_atompot = 2 * p.maxPotentialRadius();
return grating_atompot / length_atompot;
}
private:
/// this is \f$2\pi^2 a_0 e\f$, with \f$e = 2R_ya_0\f$ (\f$R_y = 13.6 eV\f$)
constexpr static double PREFACTOR_ATOMPOT = 150.4120584;
static std::mutex _cache_lock;
/// pi
constexpr static double pi = 3.14159265358979323846;
static double _s_grating_scale;
};
std::mutex StructureFactors::_cache_lock;
double StructureFactors::_s_grating_scale;
}}
}
#endif //STEMSALABIM_POTENTIAL_HPP
......@@ -33,8 +33,9 @@
#include <cstdlib>
#include <atomic>
#include "algorithms.hpp"
namespace stemsalabim { namespace {
namespace stemsalabim {
/*!
* We define our own allocator to use with the vector<> stdlib class so
......@@ -83,10 +84,12 @@ namespace stemsalabim { namespace {
}
void deallocate(pointer p, size_type count) {
algorithms::ignore(count);
fftw_free(static_cast<void *>(p));
}
bool operator==(fftwAllocator const &rhs) const {
algorithms::ignore(rhs);
return true;
}
......@@ -243,6 +246,7 @@ namespace stemsalabim { namespace {
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);
......@@ -266,6 +270,7 @@ namespace stemsalabim { namespace {
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);
......@@ -312,12 +317,9 @@ namespace stemsalabim { namespace {
*/
void forwardFFT() {
_is_kspace = true;
auto start = std::chrono::high_resolution_clock::now();
fftwf_execute_dft(getForwardPlan(_lx, _ly, _fftw_quick_planning),
reinterpret_cast<fftwf_complex *>(&_data[0]),
reinterpret_cast<fftwf_complex *>(&_data[0]));
auto elapsed = std::chrono::high_resolution_clock::now() - start;
fft_duration_nanoseconds += std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed).count();
}
/*!
......@@ -344,12 +346,9 @@ namespace stemsalabim { namespace {
void backwardFFT() {
_is_kspace = false;
auto start = std::chrono::high_resolution_clock::now();
fftwf_execute_dft(getBackwardPlan(_lx, _ly, _fftw_quick_planning),
reinterpret_cast<fftwf_complex *>(&_data[0]),
reinterpret_cast<fftwf_complex *>(&_data[0]));
auto elapsed = std::chrono::high_resolution_clock::now() - start;
fft_duration_nanoseconds += std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed).count();
// normalize
double norm = 1. / (_lx * _ly);
......@@ -400,7 +399,6 @@ namespace stemsalabim { namespace {
}
static std::mutex _s_init_mutex;
static std::atomic_ullong fft_duration_nanoseconds;
private:
unsigned int _lx{0};
unsigned int _ly{0};
......@@ -415,8 +413,5 @@ namespace stemsalabim { namespace {
std::vector<std::complex<float>, fftwAllocator<std::complex<float>>> _data;
};
// std::string Wave::_s_fftw_wisdom;
std::mutex Wave::_s_init_mutex;
std::atomic_ullong Wave::fft_duration_nanoseconds;
}}
}
#endif //STEMSALABIM_COMPLEX2D_HPP
This diff is collapsed.
......@@ -26,6 +26,7 @@
#include <memory>
#include <vector>
#include <iostream>
#include "algorithms.hpp"
/** @file */
......@@ -93,6 +94,7 @@ namespace stemsalabim {
}
size_t count(const std::string & val) const {
algorithms::ignore(val);
MPI_Datatype dt = detail::mpi_type<char>();
return count(dt);
}
......
......@@ -124,14 +124,14 @@ namespace stemsalabim {
}
inline void error(const std::string &str) {
std::cerr << "\n%s\n", " -- Error --\n";
std::cerr << " -- Error --\n";
std::cerr << str << "\n";
exit(1);
}
template<typename... ParamTypes>
void error(const std::string &str_format, ParamTypes... parameters) {
std::cerr << "\n%s\n", " -- Error --\n";
std::cerr << " -- Error --\n";
tfm::format(std::cerr, str_format.c_str(), parameters...);
exit(1);
}
......
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