Loading graph_driver/xrays.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ template<typename T, bool SAFE_MATH=false> void trace_ray(const size_t num_times, const size_t sub_steps, const size_t num_rays) { const timeing::measure_diagnostic total("Total Ray Time"); std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, SAFE_MATH>::max_concurrency()), static_cast<unsigned int> (num_rays)), Loading Loading @@ -191,6 +192,8 @@ void trace_ray(const size_t num_times, for (std::thread &t : threads) { t.join(); } total.print(); } //------------------------------------------------------------------------------ Loading @@ -203,6 +206,8 @@ template<typename T, bool SAFE_MATH=false> void calculate_power(const size_t num_times, const size_t sub_steps, const size_t num_rays) { const timeing::measure_diagnostic total("Power Time"); std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, SAFE_MATH>::max_concurrency()), static_cast<unsigned int> (num_rays)), static_cast<unsigned int> (1))); Loading Loading @@ -259,6 +264,8 @@ void calculate_power(const size_t num_times, for (std::thread &t : threads) { t.join(); } total.print(); } //------------------------------------------------------------------------------ Loading graph_framework/absorption.hpp +18 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #ifndef absorption_h #define absorption_h #include <thread> #include "newton.hpp" namespace absorption { Loading Loading @@ -66,6 +68,9 @@ namespace absorption { /// Output dataset. output::data_set<typename DISPERSION_FUNCTION::base> dataset; /// Async thread to write data files. std::thread sync; public: //------------------------------------------------------------------------------ /// @brief Constructor for root finding. Loading Loading @@ -108,7 +113,7 @@ namespace absorption { const size_t num_rays=0, const size_t index=0) : kamp(kamp), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename), dataset(file), index(index), work(index) { file(filename), dataset(file), index(index), work(index), sync([]{}) { auto kvec = graph::vector(kx, ky, kz); auto kunit = kvec->unit(); auto klen = kvec->length(); Loading Loading @@ -142,6 +147,13 @@ namespace absorption { solver::newton(work, {kamp}, inputs, {D.get_d()}); } //------------------------------------------------------------------------------ /// @brief Destructor. //------------------------------------------------------------------------------ ~root_finder() { sync.join(); } //------------------------------------------------------------------------------ /// @brief Compile the workitems. //------------------------------------------------------------------------------ Loading Loading @@ -179,7 +191,11 @@ namespace absorption { work.run(); work.wait(); dataset.write(file, time_index); sync.join(); sync = std::thread([this] (const size_t index) -> void { dataset.write(file, index); }, time_index); } }; } Loading graph_framework/solver.hpp +19 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #ifndef solver_h #define solver_h #include <thread> #include "dispersion.hpp" #include "output.hpp" Loading Loading @@ -88,6 +90,9 @@ namespace solver { /// Output dataset. output::data_set<typename DISPERSION_FUNCTION::base> dataset; /// Async thread to write data files. std::thread sync; public: //------------------------------------------------------------------------------ /// @brief Construct a new solver_interface with inital conditions. Loading Loading @@ -127,9 +132,16 @@ namespace solver { const size_t num_rays=0, const size_t index=0) : D(w, kx, ky, kz, x, y, z, t, eq), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename, num_rays), dataset(file), index(index), work(index) {} kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename, num_rays), dataset(file), index(index), work(index), sync([]{}) {} //------------------------------------------------------------------------------ /// @brief Destructor. //------------------------------------------------------------------------------ ~solver_interface() { sync.join(); } //------------------------------------------------------------------------------ /// @brief Method to initalize the rays. Loading Loading @@ -281,7 +293,10 @@ namespace solver { //------------------------------------------------------------------------------ void write_step() { work.wait(); sync.join(); sync = std::thread([this] { dataset.write(file); }); } //------------------------------------------------------------------------------ Loading Loading
graph_driver/xrays.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ template<typename T, bool SAFE_MATH=false> void trace_ray(const size_t num_times, const size_t sub_steps, const size_t num_rays) { const timeing::measure_diagnostic total("Total Ray Time"); std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, SAFE_MATH>::max_concurrency()), static_cast<unsigned int> (num_rays)), Loading Loading @@ -191,6 +192,8 @@ void trace_ray(const size_t num_times, for (std::thread &t : threads) { t.join(); } total.print(); } //------------------------------------------------------------------------------ Loading @@ -203,6 +206,8 @@ template<typename T, bool SAFE_MATH=false> void calculate_power(const size_t num_times, const size_t sub_steps, const size_t num_rays) { const timeing::measure_diagnostic total("Power Time"); std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, SAFE_MATH>::max_concurrency()), static_cast<unsigned int> (num_rays)), static_cast<unsigned int> (1))); Loading Loading @@ -259,6 +264,8 @@ void calculate_power(const size_t num_times, for (std::thread &t : threads) { t.join(); } total.print(); } //------------------------------------------------------------------------------ Loading
graph_framework/absorption.hpp +18 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #ifndef absorption_h #define absorption_h #include <thread> #include "newton.hpp" namespace absorption { Loading Loading @@ -66,6 +68,9 @@ namespace absorption { /// Output dataset. output::data_set<typename DISPERSION_FUNCTION::base> dataset; /// Async thread to write data files. std::thread sync; public: //------------------------------------------------------------------------------ /// @brief Constructor for root finding. Loading Loading @@ -108,7 +113,7 @@ namespace absorption { const size_t num_rays=0, const size_t index=0) : kamp(kamp), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename), dataset(file), index(index), work(index) { file(filename), dataset(file), index(index), work(index), sync([]{}) { auto kvec = graph::vector(kx, ky, kz); auto kunit = kvec->unit(); auto klen = kvec->length(); Loading Loading @@ -142,6 +147,13 @@ namespace absorption { solver::newton(work, {kamp}, inputs, {D.get_d()}); } //------------------------------------------------------------------------------ /// @brief Destructor. //------------------------------------------------------------------------------ ~root_finder() { sync.join(); } //------------------------------------------------------------------------------ /// @brief Compile the workitems. //------------------------------------------------------------------------------ Loading Loading @@ -179,7 +191,11 @@ namespace absorption { work.run(); work.wait(); dataset.write(file, time_index); sync.join(); sync = std::thread([this] (const size_t index) -> void { dataset.write(file, index); }, time_index); } }; } Loading
graph_framework/solver.hpp +19 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #ifndef solver_h #define solver_h #include <thread> #include "dispersion.hpp" #include "output.hpp" Loading Loading @@ -88,6 +90,9 @@ namespace solver { /// Output dataset. output::data_set<typename DISPERSION_FUNCTION::base> dataset; /// Async thread to write data files. std::thread sync; public: //------------------------------------------------------------------------------ /// @brief Construct a new solver_interface with inital conditions. Loading Loading @@ -127,9 +132,16 @@ namespace solver { const size_t num_rays=0, const size_t index=0) : D(w, kx, ky, kz, x, y, z, t, eq), w(w), kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename, num_rays), dataset(file), index(index), work(index) {} kx(kx), ky(ky), kz(kz), x(x), y(y), z(z), t(t), file(filename, num_rays), dataset(file), index(index), work(index), sync([]{}) {} //------------------------------------------------------------------------------ /// @brief Destructor. //------------------------------------------------------------------------------ ~solver_interface() { sync.join(); } //------------------------------------------------------------------------------ /// @brief Method to initalize the rays. Loading Loading @@ -281,7 +293,10 @@ namespace solver { //------------------------------------------------------------------------------ void write_step() { work.wait(); sync.join(); sync = std::thread([this] { dataset.write(file); }); } //------------------------------------------------------------------------------ Loading