diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/numeric/odeint/performance/openmp | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/numeric/odeint/performance/openmp')
5 files changed, 0 insertions, 334 deletions
diff --git a/libs/numeric/odeint/performance/openmp/Jamfile.v2 b/libs/numeric/odeint/performance/openmp/Jamfile.v2 deleted file mode 100644 index 098cd53f0..000000000 --- a/libs/numeric/odeint/performance/openmp/Jamfile.v2 +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2011-2013 Mario Mulansky -# Copyright 2012 Karsten Ahnert -# Copyright 2013 Pascal Germroth -# 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) - -use-project /boost : $(BOOST_ROOT) ; -import openmp : * ; - -project - : requirements - <include>../../../../.. - <include>.. - <define>BOOST_ALL_NO_LIB=1 - <library>/boost//timer - <library>/boost//program_options - [ openmp ] - ; - -exe osc_chain_1d : osc_chain_1d.cpp ; diff --git a/libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp b/libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp deleted file mode 100644 index 8a5a2e857..000000000 --- a/libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Pascal Germroth - Copyright 2013 Mario Mulansky - - stronlgy nonlinear hamiltonian lattice in 2d - - 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) - */ - -#include <iostream> -#include <vector> - -#include <omp.h> -#include <boost/numeric/odeint.hpp> -#include <boost/numeric/odeint/external/openmp/openmp.hpp> - -#include <boost/program_options.hpp> -#include <boost/random.hpp> -#include <boost/timer/timer.hpp> -#include <boost/foreach.hpp> -#include <boost/accumulators/accumulators.hpp> -#include <boost/accumulators/statistics/stats.hpp> -#include <boost/accumulators/statistics/mean.hpp> -#include <boost/accumulators/statistics/median.hpp> -#include "osc_chain_1d_system.hpp" - -using namespace std; -using namespace boost::numeric::odeint; -using namespace boost::accumulators; -using namespace boost::program_options; - -using boost::timer::cpu_timer; - -const double p_kappa = 3.3; -const double p_lambda = 4.7; - -int main( int argc , char* argv[] ) -{ - size_t N, blocks, steps, repeat; - bool split_range, dump; - options_description desc("Options"); - desc.add_options() - ("help,h", "show this help") - ("length", value(&N)->default_value(1024), "length of chain") - ("steps", value(&steps)->default_value(100), "simulation steps") - ("blocks", value(&blocks)->default_value(omp_get_max_threads()), "number of blocks (split) or threads (non-split)") - ("split", bool_switch(&split_range), "split range") - ("repeat", value(&repeat)->default_value(25), "repeat runs") - ("dump", bool_switch(&dump), "dump final state to stderr") - ; - variables_map vm; - store(command_line_parser(argc, argv).options(desc).run(), vm); - notify(vm); - if(vm.count("help")) - { - cerr << desc << endl; - return EXIT_FAILURE; - } - cout << "length\tsteps\tthreads\ttime" << endl; - - accumulator_set< double, stats<tag::mean, tag::median> > acc_time; - - vector<double> p( N ), q( N, 0 ); - boost::random::uniform_real_distribution<double> distribution; - boost::random::mt19937 engine( 0 ); - generate( p.begin() , p.end() , boost::bind( distribution , engine ) ); - - if(split_range) { - typedef openmp_state<double> state_type; - typedef symplectic_rkn_sb3a_mclachlan< - state_type , state_type , double - > stepper_type; - state_type p_split(blocks), q_split(blocks); - split(p, p_split); - split(q, q_split); - - for(size_t n_run = 0 ; n_run != repeat ; n_run++) { - cpu_timer timer; - integrate_n_steps( stepper_type() , osc_chain( p_kappa , p_lambda ) , - make_pair( boost::ref(q_split) , boost::ref(p_split) ) , - 0.0 , 0.01 , steps ); - double run_time = static_cast<double>(timer.elapsed().wall) * 1.0e-9; - acc_time(run_time); - cout << N << '\t' << steps << '\t' << blocks << '\t' << run_time << endl; - } - - if(dump) { - unsplit(p_split, p); - copy(p.begin(), p.end(), ostream_iterator<double>(cerr, "\t")); - cerr << endl; - } - - } else { - typedef vector<double> state_type; - typedef symplectic_rkn_sb3a_mclachlan< - state_type , state_type , double , - state_type , state_type , double , - openmp_range_algebra - > stepper_type; - omp_set_num_threads(blocks); - - for(size_t n_run = 0 ; n_run != repeat ; n_run++) { - cpu_timer timer; - integrate_n_steps( stepper_type() , osc_chain( p_kappa , p_lambda ) , - make_pair( boost::ref(q) , boost::ref(p) ) , - 0.0 , 0.01 , steps ); - double run_time = static_cast<double>(timer.elapsed().wall) * 1.0e-9; - acc_time(run_time); - cout << N << '\t' << steps << '\t' << blocks << '\t' << run_time << endl; - } - - if(dump) { - copy(p.begin(), p.end(), ostream_iterator<double>(cerr, "\t")); - cerr << endl; - } - - } - - cout << "# mean=" << mean(acc_time) - << " median=" << median(acc_time) << endl; - - return 0; -} diff --git a/libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp b/libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp deleted file mode 100644 index d9a6c222d..000000000 --- a/libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky - Copyright 2013 Pascal Germroth - - stronlgy nonlinear hamiltonian lattice - - 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) - */ - -#ifndef SYSTEM_HPP -#define SYSTEM_HPP - -#include <vector> -#include <cmath> -#include <iostream> - -#include <omp.h> - -#include <boost/math/special_functions/sign.hpp> -#include <boost/numeric/odeint/external/openmp/openmp.hpp> - -namespace checked_math { - inline double pow( double x , double y ) - { - if( x==0.0 ) - // 0**y = 0, don't care for y = 0 or NaN - return 0.0; - using std::pow; - using std::abs; - return pow( abs(x) , y ); - } -} - -double signed_pow( double x , double k ) -{ - using boost::math::sign; - return checked_math::pow( x , k ) * sign(x); -} - -struct osc_chain { - - const double m_kap, m_lam; - - osc_chain( const double kap , const double lam ) - : m_kap( kap ) , m_lam( lam ) - { } - - // Simple case with openmp_range_algebra - void operator()( const std::vector<double> &q , - std::vector<double> &dpdt ) const - { - const size_t N = q.size(); - double coupling_lr = 0; - size_t last_i = N; - #pragma omp parallel for firstprivate(coupling_lr, last_i) lastprivate(coupling_lr) schedule(runtime) - for(size_t i = 0 ; i < N - 1 ; ++i) - { - if(i > 0 && i != last_i + 1) - coupling_lr = signed_pow( q[i-1]-q[i] , m_lam-1 ); - dpdt[i] = -signed_pow( q[i] , m_kap-1 ) + coupling_lr; - coupling_lr = signed_pow( q[i] - q[i+1] , m_lam-1 ); - dpdt[i] -= coupling_lr; - last_i = i; - } - dpdt[N-1] = -signed_pow( q[N-1] , m_kap-1 ) + coupling_lr; - } - - // Split case with openmp_algebra - void operator()( const boost::numeric::odeint::openmp_state<double> &q , - boost::numeric::odeint::openmp_state<double> &dpdt ) const - { - const size_t M = q.size(); - #pragma omp parallel for schedule(runtime) - for(size_t i = 0 ; i < M ; ++i) - { - const std::vector<double> &_q = q[i]; - std::vector<double> &_dpdt = dpdt[i]; - const size_t N = q[i].size(); - double coupling_lr = 0; - if(i > 0) coupling_lr = signed_pow( q[i-1].back() - _q[0] , m_lam-1 ); - for(size_t j = 0 ; j < N-1 ; ++j) - { - _dpdt[j] = -signed_pow( _q[j] , m_kap-1 ) + coupling_lr; - coupling_lr = signed_pow( _q[j] - _q[j+1] , m_lam-1 ); - _dpdt[j] -= coupling_lr; - } - _dpdt[N-1] = -signed_pow( _q[N-1] , m_kap-1 ) + coupling_lr; - if(i + 1 < M) _dpdt[N-1] -= signed_pow( _q[N-1] - q[i+1].front() , m_lam-1 ); - } - } - -}; - -#endif diff --git a/libs/numeric/odeint/performance/openmp/osc_chain_speedup.gnu b/libs/numeric/odeint/performance/openmp/osc_chain_speedup.gnu deleted file mode 100755 index 4d6bc95e4..000000000 --- a/libs/numeric/odeint/performance/openmp/osc_chain_speedup.gnu +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env gnuplot - -set terminal pngcairo size 1000,1000 -set output "osc_chain_speedup.png" - -set multiplot layout 2,2 - -set key left - -set xrange [1:64] -set x2range [1:64] -set x2tics 8 format "" -set grid x2tics -set yrange [0:8] - -set title "short: speedup" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-s-mul" w lp t "gcc (split)" , \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-t-mul" w lp t "gcc (simple)", \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-s-mul" w lp t "icc (split)" , \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-t-mul" w lp t "icc (simple)", \ - (x < 4 ? x : 4) lc 0 lt 0 t "target" - -unset key - -set title "long: speedup" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-s-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-t-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-s-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-t-mul" w lp, \ - (x < 4 ? x : 4) lc 0 lt 0 - -set yrange [0:*] - -set title "short: time[s]" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-s-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-t-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-s-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-t-med" w lp - -set title "long: time[s]" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-s-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-t-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-s-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-t-med" w lp - -unset multiplot diff --git a/libs/numeric/odeint/performance/openmp/osc_chain_speedup.sh b/libs/numeric/odeint/performance/openmp/osc_chain_speedup.sh deleted file mode 100755 index 9d4c91096..000000000 --- a/libs/numeric/odeint/performance/openmp/osc_chain_speedup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/zsh - -export LC_NUMERIC=en_US.UTF-8 -declare -A times - -export OMP_SCHEDULE=static -export OMP_PROC_BIND=true -repeat=2 - -function run { - n=$1 - steps=$2 - printf "# n=$n steps=$steps repeat=$repeat\n" - printf '"block"' - for b in gcc icc ; do - for s in s t ; do - for t in med mul ; do - printf "\t\"$b-$s-$t\"" - done - done - done - for block in 1 2 4 8 16 32 64; do - printf '\n%d' $block - for build in gcc-4.7 intel-linux ; do - bench="bin/$build/release/osc_chain_1d" - for split in 1 0 ; do - med=$($bench $n $block $steps $repeat $split | tail -1 | awk '{print $4}') - times[$build-$split-$block]=$med - speedup=$((${times[$build-$split-1]}/$med)) - printf '\t%f\t%f' $med $speedup - done - done - done - printf '\n\n\n' -} - -run 4096 1024 | tee osc_chain_speedup-short.dat -run 524288 10 | tee osc_chain_speedup-long.dat |