Skip to content

Commit

Permalink
Merge pull request #1146 from STEllAR-GROUP/stencil_print
Browse files Browse the repository at this point in the history
Stencil print
  • Loading branch information
hkaiser committed Jun 3, 2014
2 parents 8e681d8 + 2c77432 commit aa3cff1
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 9 deletions.
15 changes: 13 additions & 2 deletions examples/1d_stencil/1d_stencil_1.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -12,6 +13,7 @@
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>

#include "print_time_results.hpp"
///////////////////////////////////////////////////////////////////////////////
// Timer with nanosecond resolution
inline boost::uint64_t now()
Expand All @@ -22,6 +24,8 @@ inline boost::uint64_t now()
}

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -78,6 +82,9 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;

// Create the stepper object
stepper step;

Expand All @@ -86,6 +93,7 @@ int hpx_main(boost::program_options::variables_map& vm)

// Execute nt time steps on nx grid points.
stepper::space solution = step.do_work(nx, nt);


// Print the final solution
if (vm.count("results"))
Expand All @@ -95,8 +103,10 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;


boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, nt, header);

return hpx::finalize();
}

Expand All @@ -117,6 +127,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", po::value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
13 changes: 12 additions & 1 deletion examples/1d_stencil/1d_stencil_2.cpp
@@ -1,5 +1,6 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Bryce Adelstein-Lelbach
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -19,7 +20,11 @@
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -94,6 +99,9 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;

// Create the stepper object
stepper step;

Expand All @@ -116,7 +124,9 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;

boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, nt, header);

return hpx::finalize();
}
Expand All @@ -138,6 +148,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
13 changes: 12 additions & 1 deletion examples/1d_stencil/1d_stencil_3.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -14,6 +15,8 @@
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Timer with nanosecond resolution
inline boost::uint64_t now()
Expand All @@ -24,6 +27,8 @@ inline boost::uint64_t now()
}

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -137,6 +142,10 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;


// Create the stepper object
stepper step;

Expand All @@ -154,7 +163,8 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;
boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, np, nt, header);

return hpx::finalize();
}
Expand All @@ -178,6 +188,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", po::value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
16 changes: 15 additions & 1 deletion examples/1d_stencil/1d_stencil_4.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -16,7 +17,11 @@
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -141,6 +146,10 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;


// Create the stepper object
stepper step;

Expand All @@ -163,7 +172,9 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;

boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, np, nt, header);

return hpx::finalize();
}
Expand All @@ -172,7 +183,9 @@ int main(int argc, char* argv[])
{
using namespace boost::program_options;

// Configure application-specific options.
options_description desc_commandline;

desc_commandline.add_options()
("results", "print generated results (default: false)")
("nx", value<boost::uint64_t>()->default_value(10),
Expand All @@ -187,6 +200,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
12 changes: 11 additions & 1 deletion examples/1d_stencil/1d_stencil_5.cpp
Expand Up @@ -20,7 +20,11 @@

#include <boost/shared_array.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -280,6 +284,9 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;

// Create the stepper object
stepper step;

Expand All @@ -306,7 +313,9 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;

boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, np, nt, header);

return hpx::finalize();
}
Expand All @@ -330,6 +339,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
13 changes: 12 additions & 1 deletion examples/1d_stencil/1d_stencil_6.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -13,7 +14,11 @@

#include <boost/shared_array.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -336,6 +341,9 @@ int hpx_main(boost::program_options::variables_map& vm)
boost::uint64_t nx = vm["nx"].as<boost::uint64_t>(); // Number of grid points.
boost::uint64_t nt = vm["nt"].as<boost::uint64_t>(); // Number of steps.

if (vm.count("no-header"))
header = false;

std::vector<hpx::id_type> localities = hpx::find_all_localities();
std::size_t nl = localities.size(); // Number of localities

Expand Down Expand Up @@ -372,7 +380,9 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;

boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, np, nt, header);

return hpx::finalize();
}
Expand All @@ -396,6 +406,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down
13 changes: 12 additions & 1 deletion examples/1d_stencil/1d_stencil_7.cpp
@@ -1,4 +1,5 @@
// Copyright (c) 2014 Hartmut Kaiser
// Copyright (c) 2014 Patricia Grubel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -13,7 +14,11 @@

#include <boost/shared_array.hpp>

#include "print_time_results.hpp"

///////////////////////////////////////////////////////////////////////////////
// Command-line variables
bool header = true; // print csv heading
double k = 0.5; // heat transfer coefficient
double dt = 1.; // time step
double dx = 1.; // grid spacing
Expand Down Expand Up @@ -348,6 +353,9 @@ int hpx_main(boost::program_options::variables_map& vm)
std::vector<hpx::id_type> localities = hpx::find_all_localities();
std::size_t nl = localities.size(); // Number of localities

if (vm.count("no-header"))
header = false;

if (np < nl)
{
std::cout << "The number of partitions should not be smaller than "
Expand Down Expand Up @@ -381,7 +389,9 @@ int hpx_main(boost::program_options::variables_map& vm)
}

boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;
std::cout << "Elapsed time: " << elapsed / 1e9 << " [s]" << std::endl;

boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
print_time_results(os_thread_count, elapsed, nx, np, nt, header);

return hpx::finalize();
}
Expand All @@ -405,6 +415,7 @@ int main(int argc, char* argv[])
"Timestep unit (default: 1.0[s])")
("dx", value<double>(&dx)->default_value(1.0),
"Local x dimension")
( "no-header", "do not print out the csv header row")
;

// Initialize and run HPX
Expand Down

0 comments on commit aa3cff1

Please sign in to comment.