Loading CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ macro (add_tool_target target) endmacro () add_subdirectory (graph_driver) add_subdirectory (graph_benchmark) #------------------------------------------------------------------------------- # Setup testing Loading graph_benchmark/CMakeLists.txt 0 → 100644 +11 −0 Original line number Diff line number Diff line add_tool_target (xrays_bench) target_link_libraries (xrays_bench PUBLIC $<$<PLATFORM_ID:Linux>:pthread> ) if (${USE_PCH}) target_precompile_headers (xrays_bench REUSE_FROM xrays) endif () graph_benchmark/xrays_bench.cpp 0 → 100644 +115 −0 Original line number Diff line number Diff line //------------------------------------------------------------------------------ /// @file xrays.cpp /// @brief Benchmark Case for the Rays code. //------------------------------------------------------------------------------ #include <iostream> #include <thread> //------------------------------------------------------------------------------ /// @brief Bench runner. //------------------------------------------------------------------------------ template<typename T, size_t NUM_TIMES, size_t SUB_STEPS, size_t NUM_RAYS> void bench_runner() { if constexpr (std::is_same<T, float>::value) { std::cout << "Float "; } else if constexpr (std::is_same<T, double>::value) { std::cout << "Double "; } else if constexpr (std::is_same<T, std::complex<float>>::value) { std::cout << "Complex Float "; } else { std::cout << "Complex Double "; } std::cout << "--------------------------------------------------------------------------------" << std::endl; const size_t num_steps = NUM_TIMES/SUB_STEPS; std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, false>::max_concurrency()), static_cast<unsigned int> (NUM_RAYS)), static_cast<unsigned int> (1))); std::vector<timeing::measure_diagnostic> timers; for (size_t i = 0, ie = threads.size(); i < ie; i++) { threads[i] = std::thread([&timers] (const size_t thread_number, const size_t num_threads) -> void { const size_t local_num_rays = NUM_RAYS/num_threads + std::min(thread_number, NUM_RAYS%num_threads); auto omega = graph::variable<T, false> (local_num_rays, "\\omega"); auto kx = graph::variable<T, false> (local_num_rays, "k_{x}"); auto ky = graph::variable<T, false> (local_num_rays, "k_{y}"); auto kz = graph::variable<T, false> (local_num_rays, "k_{z}"); auto x = graph::variable<T, false> (local_num_rays, "x"); auto y = graph::variable<T, false> (local_num_rays, "y"); auto z = graph::variable<T, false> (local_num_rays, "z"); auto t = graph::variable<T, false> (local_num_rays, "t"); t->set(static_cast<T> (0.0)); // Inital conditions. omega->set(static_cast<T> (500.0)); x->set(static_cast<T> (2.5)); y->set(static_cast<T> (0.0)); z->set(static_cast<T> (0.0)); kx->set(static_cast<T> (-600)); ky->set(static_cast<T> (0.0)); kz->set(static_cast<T> (0.0)); auto eq = equilibrium::make_efit<T, false> (NC_FILE); const T endtime = static_cast<T> (1.0); const T dt = endtime/static_cast<T> (NUM_TIMES); solver::rk4<dispersion::cold_plasma<T, false>> solve(omega, kx, ky, kz, x, y, z, t, dt, eq, "", local_num_rays, thread_number); solve.init(kx); solve.compile(); std::ostringstream step_label; step_label << "Step Time thread " << thread_number; timers.emplace_back(step_label.str()); for (size_t j = 0; j < num_steps; j++) { for (size_t k = 0; k < SUB_STEPS; k++) { solve.step(); } } solve.sync_host(); timers[thread_number].stop(); }, i, threads.size()); } for (std::thread &t : threads) { t.join(); } for (auto &time : timers) { time.print(); } std::cout << "--------------------------------------------------------------------------------" << std::endl; } //------------------------------------------------------------------------------ /// @brief Main program of the benchmark. /// /// @params[in] argc Number of commandline arguments. /// @params[in] argv Array of commandline arguments. //------------------------------------------------------------------------------ int main(int argc, const char * argv[]) { START_GPU bench_runner<float, 100000, 10, 100000> (); bench_runner<double, 100000, 10, 100000> (); bench_runner<std::complex<float>, 100000, 10, 100000> (); bench_runner<std::complex<double>, 100000, 10, 100000> (); END_GPU } graph_driver/xrays.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ //------------------------------------------------------------------------------ #include <iostream> #include <chrono> #include <thread> #include <random> Loading @@ -31,7 +30,7 @@ int main(int argc, const char * argv[]) { //constexpr bool use_safe_math = true; constexpr bool use_safe_math = false; const timeing::measure_diagnostic total("Total Time"); timeing::measure_diagnostic total("Total Time"); const size_t num_times = 100000; const size_t sub_steps = 10; Loading Loading @@ -184,6 +183,7 @@ int main(int argc, const char * argv[]) { std::cout << std::endl << "Timing:" << std::endl; total.stop(); total.print(); END_GPU } graph_framework.xcodeproj/project.pbxproj +2 −0 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ C73BBE7B29F816E50027BB7F /* piecewise_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = piecewise_test; sourceTree = BUILT_PRODUCTS_DIR; }; C73BBE7D29F816E60027BB7F /* piecewise_test.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = piecewise_test.cpp; sourceTree = "<group>"; }; C73BBE9629F8669F0027BB7F /* newton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = newton.hpp; sourceTree = "<group>"; }; C7616FBC2AA7944400A831DE /* graph_benchmark */ = {isa = PBXFileReference; lastKnownFileType = folder; path = graph_benchmark; sourceTree = "<group>"; }; C77E6DF522DD64E700469621 /* trigonometry.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = trigonometry.hpp; sourceTree = "<group>"; }; C79141A622DA9BF200E0BA0D /* libgraph_framework.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgraph_framework.a; sourceTree = BUILT_PRODUCTS_DIR; }; C79141AE22DA9C3000E0BA0D /* node.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = node.hpp; sourceTree = "<group>"; }; Loading Loading @@ -352,6 +353,7 @@ C79141AD22DA9C0600E0BA0D /* graph_framework */, C7931E6928073BCA0033B488 /* graph_tests */, C79141B422DAAD0C00E0BA0D /* graph_driver */, C7616FBC2AA7944400A831DE /* graph_benchmark */, C717CB8C2A02E361008FBDD8 /* cmake */, C79141A722DA9BF200E0BA0D /* Products */, C71342672947F36100672AD4 /* Frameworks */, Loading Loading
CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ macro (add_tool_target target) endmacro () add_subdirectory (graph_driver) add_subdirectory (graph_benchmark) #------------------------------------------------------------------------------- # Setup testing Loading
graph_benchmark/CMakeLists.txt 0 → 100644 +11 −0 Original line number Diff line number Diff line add_tool_target (xrays_bench) target_link_libraries (xrays_bench PUBLIC $<$<PLATFORM_ID:Linux>:pthread> ) if (${USE_PCH}) target_precompile_headers (xrays_bench REUSE_FROM xrays) endif ()
graph_benchmark/xrays_bench.cpp 0 → 100644 +115 −0 Original line number Diff line number Diff line //------------------------------------------------------------------------------ /// @file xrays.cpp /// @brief Benchmark Case for the Rays code. //------------------------------------------------------------------------------ #include <iostream> #include <thread> //------------------------------------------------------------------------------ /// @brief Bench runner. //------------------------------------------------------------------------------ template<typename T, size_t NUM_TIMES, size_t SUB_STEPS, size_t NUM_RAYS> void bench_runner() { if constexpr (std::is_same<T, float>::value) { std::cout << "Float "; } else if constexpr (std::is_same<T, double>::value) { std::cout << "Double "; } else if constexpr (std::is_same<T, std::complex<float>>::value) { std::cout << "Complex Float "; } else { std::cout << "Complex Double "; } std::cout << "--------------------------------------------------------------------------------" << std::endl; const size_t num_steps = NUM_TIMES/SUB_STEPS; std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<T, false>::max_concurrency()), static_cast<unsigned int> (NUM_RAYS)), static_cast<unsigned int> (1))); std::vector<timeing::measure_diagnostic> timers; for (size_t i = 0, ie = threads.size(); i < ie; i++) { threads[i] = std::thread([&timers] (const size_t thread_number, const size_t num_threads) -> void { const size_t local_num_rays = NUM_RAYS/num_threads + std::min(thread_number, NUM_RAYS%num_threads); auto omega = graph::variable<T, false> (local_num_rays, "\\omega"); auto kx = graph::variable<T, false> (local_num_rays, "k_{x}"); auto ky = graph::variable<T, false> (local_num_rays, "k_{y}"); auto kz = graph::variable<T, false> (local_num_rays, "k_{z}"); auto x = graph::variable<T, false> (local_num_rays, "x"); auto y = graph::variable<T, false> (local_num_rays, "y"); auto z = graph::variable<T, false> (local_num_rays, "z"); auto t = graph::variable<T, false> (local_num_rays, "t"); t->set(static_cast<T> (0.0)); // Inital conditions. omega->set(static_cast<T> (500.0)); x->set(static_cast<T> (2.5)); y->set(static_cast<T> (0.0)); z->set(static_cast<T> (0.0)); kx->set(static_cast<T> (-600)); ky->set(static_cast<T> (0.0)); kz->set(static_cast<T> (0.0)); auto eq = equilibrium::make_efit<T, false> (NC_FILE); const T endtime = static_cast<T> (1.0); const T dt = endtime/static_cast<T> (NUM_TIMES); solver::rk4<dispersion::cold_plasma<T, false>> solve(omega, kx, ky, kz, x, y, z, t, dt, eq, "", local_num_rays, thread_number); solve.init(kx); solve.compile(); std::ostringstream step_label; step_label << "Step Time thread " << thread_number; timers.emplace_back(step_label.str()); for (size_t j = 0; j < num_steps; j++) { for (size_t k = 0; k < SUB_STEPS; k++) { solve.step(); } } solve.sync_host(); timers[thread_number].stop(); }, i, threads.size()); } for (std::thread &t : threads) { t.join(); } for (auto &time : timers) { time.print(); } std::cout << "--------------------------------------------------------------------------------" << std::endl; } //------------------------------------------------------------------------------ /// @brief Main program of the benchmark. /// /// @params[in] argc Number of commandline arguments. /// @params[in] argv Array of commandline arguments. //------------------------------------------------------------------------------ int main(int argc, const char * argv[]) { START_GPU bench_runner<float, 100000, 10, 100000> (); bench_runner<double, 100000, 10, 100000> (); bench_runner<std::complex<float>, 100000, 10, 100000> (); bench_runner<std::complex<double>, 100000, 10, 100000> (); END_GPU }
graph_driver/xrays.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ //------------------------------------------------------------------------------ #include <iostream> #include <chrono> #include <thread> #include <random> Loading @@ -31,7 +30,7 @@ int main(int argc, const char * argv[]) { //constexpr bool use_safe_math = true; constexpr bool use_safe_math = false; const timeing::measure_diagnostic total("Total Time"); timeing::measure_diagnostic total("Total Time"); const size_t num_times = 100000; const size_t sub_steps = 10; Loading Loading @@ -184,6 +183,7 @@ int main(int argc, const char * argv[]) { std::cout << std::endl << "Timing:" << std::endl; total.stop(); total.print(); END_GPU }
graph_framework.xcodeproj/project.pbxproj +2 −0 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ C73BBE7B29F816E50027BB7F /* piecewise_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = piecewise_test; sourceTree = BUILT_PRODUCTS_DIR; }; C73BBE7D29F816E60027BB7F /* piecewise_test.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = piecewise_test.cpp; sourceTree = "<group>"; }; C73BBE9629F8669F0027BB7F /* newton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = newton.hpp; sourceTree = "<group>"; }; C7616FBC2AA7944400A831DE /* graph_benchmark */ = {isa = PBXFileReference; lastKnownFileType = folder; path = graph_benchmark; sourceTree = "<group>"; }; C77E6DF522DD64E700469621 /* trigonometry.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = trigonometry.hpp; sourceTree = "<group>"; }; C79141A622DA9BF200E0BA0D /* libgraph_framework.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgraph_framework.a; sourceTree = BUILT_PRODUCTS_DIR; }; C79141AE22DA9C3000E0BA0D /* node.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = node.hpp; sourceTree = "<group>"; }; Loading Loading @@ -352,6 +353,7 @@ C79141AD22DA9C0600E0BA0D /* graph_framework */, C7931E6928073BCA0033B488 /* graph_tests */, C79141B422DAAD0C00E0BA0D /* graph_driver */, C7616FBC2AA7944400A831DE /* graph_benchmark */, C717CB8C2A02E361008FBDD8 /* cmake */, C79141A722DA9BF200E0BA0D /* Products */, C71342672947F36100672AD4 /* Frameworks */, Loading