Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap boost::format uses #2882

Merged
merged 3 commits into from Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/1d_stencil/1d_stencil_4_repart.cpp
Expand Up @@ -22,7 +22,6 @@
#include <hpx/include/performance_counters.hpp>

#include <boost/range/irange.hpp>
#include <boost/format.hpp>

#include <algorithm>
#include <cstddef>
Expand Down
6 changes: 2 additions & 4 deletions examples/1d_stencil/1d_stencil_4_throttle.cpp
Expand Up @@ -16,6 +16,7 @@

#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/util/format.hpp>

#include <hpx/include/parallel_algorithm.hpp>
#include <boost/range/irange.hpp>
Expand All @@ -25,8 +26,6 @@
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>

#include <boost/format.hpp>

#include <cstddef>
#include <cstdint>
#include <iostream>
Expand All @@ -49,8 +48,7 @@ hpx::naming::id_type counter_id;
id_type get_counter_id() {
// Resolve the GID of the performances counter using it's symbolic name.
std::uint32_t const prefix = hpx::get_locality_id();
boost::format active_threads(counter_name);
id_type id = get_counter(boost::str(active_threads % prefix));
id_type id = get_counter(hpx::util::format(counter_name, prefix));
return id;
}

Expand Down
42 changes: 21 additions & 21 deletions examples/1d_stencil/print_time_results.hpp
Expand Up @@ -7,7 +7,7 @@
#ifndef HPX_STENCIL_PRINT_TIME_HPP
#define HPX_STENCIL_PRINT_TIME_HPP

#include <boost/format.hpp>
#include <hpx/util/format.hpp>

#include <cstdint>
#include <iostream>
Expand All @@ -30,15 +30,15 @@ void print_time_results(
"Points_per_Partition,Partitions,Time_Steps\n"
<< std::flush;

std::string const locs_str = boost::str(boost::format("%u,") % num_localities);
std::string const threads_str = boost::str(boost::format("%lu,") % num_os_threads);
std::string const nx_str = boost::str(boost::format("%lu,") % nx);
std::string const np_str = boost::str(boost::format("%lu,") % np);
std::string const nt_str = boost::str(boost::format("%lu ") % nt);
std::string const locs_str = hpx::util::format("%u,", num_localities);
std::string const threads_str = hpx::util::format("%lu,", num_os_threads);
std::string const nx_str = hpx::util::format("%lu,", nx);
std::string const np_str = hpx::util::format("%lu,", np);
std::string const nt_str = hpx::util::format("%lu ", nt);

std::cout << ( boost::format("%-6s %-6s %.14g, %-21s %-21s %-21s\n")
% locs_str % threads_str % (elapsed / 1e9) %nx_str % np_str
% nt_str) << std::flush;
hpx::util::format_to(std::cout, "%-6s %-6s %.14g, %-21s %-21s %-21s\n",
locs_str, threads_str, elapsed / 1e9, nx_str, np_str,
nt_str) << std::flush;
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -56,14 +56,14 @@ void print_time_results(
"Points_per_Partition,Partitions,Time_Steps\n"
<< std::flush;

std::string const threads_str = boost::str(boost::format("%lu,") % num_os_threads);
std::string const nx_str = boost::str(boost::format("%lu,") % nx);
std::string const np_str = boost::str(boost::format("%lu,") % np);
std::string const nt_str = boost::str(boost::format("%lu ") % nt);
std::string const threads_str = hpx::util::format("%lu,", num_os_threads);
std::string const nx_str = hpx::util::format("%lu,", nx);
std::string const np_str = hpx::util::format("%lu,", np);
std::string const nt_str = hpx::util::format("%lu ", nt);

std::cout << ( boost::format("%-21s %.14g, %-21s %-21s %-21s\n")
% threads_str % (elapsed / 1e9) %nx_str % np_str
% nt_str) << std::flush;
hpx::util::format_to(std::cout, "%-21s %.14g, %-21s %-21s %-21s\n",
threads_str, elapsed / 1e9, nx_str, np_str,
nt_str) << std::flush;
}

void print_time_results(
Expand All @@ -79,12 +79,12 @@ void print_time_results(
"Grid_Points,Time_Steps\n"
<< std::flush;

std::string const threads_str = boost::str(boost::format("%lu,") % num_os_threads);
std::string const nx_str = boost::str(boost::format("%lu,") % nx);
std::string const nt_str = boost::str(boost::format("%lu ") % nt);
std::string const threads_str = hpx::util::format("%lu,", num_os_threads);
std::string const nx_str = hpx::util::format("%lu,", nx);
std::string const nt_str = hpx::util::format("%lu ", nt);

std::cout << ( boost::format("%-21s %10.12s, %-21s %-21s\n")
% threads_str % (elapsed / 1e9) %nx_str % nt_str) << std::flush;
hpx::util::format_to(std::cout, "%-21s %10.12s, %-21s %-21s\n",
threads_str, elapsed / 1e9, nx_str, nt_str) << std::flush;
}

#endif
2 changes: 0 additions & 2 deletions examples/allgather/ag/server/allgather.cpp
Expand Up @@ -10,8 +10,6 @@

#include "allgather.hpp"

#include <boost/format.hpp>

#include <cstddef>
#include <fstream>
#include <iostream>
Expand Down
2 changes: 0 additions & 2 deletions examples/allgather/ag/server/allgather_and_gate.cpp
Expand Up @@ -12,8 +12,6 @@

#include "allgather_and_gate.hpp"

#include <boost/format.hpp>

#include <cstddef>
#include <fstream>
#include <iostream>
Expand Down
6 changes: 2 additions & 4 deletions examples/apex/apex_balance.cpp
Expand Up @@ -9,8 +9,8 @@

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/util.hpp>

#include <apex_api.hpp>

Expand All @@ -21,8 +21,6 @@
#include <random>
#include <vector>

#include <boost/format.hpp>

double do_work(std::uint64_t n);

HPX_PLAIN_ACTION(do_work, do_work_action);
Expand Down Expand Up @@ -87,7 +85,7 @@ int hpx_main(boost::program_options::variables_map& vm)


char const* fmt = "elapsed time: %1% [s]\n";
std::cout << (boost::format(fmt) % t.elapsed());
hpx::util::format_to(std::cout, fmt, t.elapsed());

return hpx::finalize(); // Handles HPX shutdown
}
Expand Down
4 changes: 1 addition & 3 deletions examples/apex/apex_fibonacci.cpp
Expand Up @@ -17,8 +17,6 @@
#include <iostream>
#include <set>

#include <boost/format.hpp>

///////////////////////////////////////////////////////////////////////////////
//[fib_action
// forward declaration of the Fibonacci function
Expand Down Expand Up @@ -69,7 +67,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::uint64_t r = fib(hpx::find_here(), n);

char const* fmt = "fibonacci(%1%) == %2%\nelapsed time: %3% [s]\n";
std::cout << (boost::format(fmt) % n % r % t.elapsed());
hpx::util::format_to(std::cout, fmt, n, r, t.elapsed());
}

return hpx::finalize(); // Handles HPX shutdown
Expand Down
16 changes: 7 additions & 9 deletions examples/apex/apex_policy_engine_active_thread_count.cpp
Expand Up @@ -8,19 +8,17 @@
// Naive SMP version implemented with futures.

#include <hpx/hpx_init.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/include/util.hpp>

#include <apex_api.hpp>

#include <cstdint>
#include <iostream>

#include <boost/format.hpp>

///////////////////////////////////////////////////////////////////////////////
// forward declaration of the Fibonacci function
std::uint64_t fibonacci(std::uint64_t n);
Expand Down Expand Up @@ -65,11 +63,11 @@ id_type get_counter_id() {
// Resolve the GID of the performances counter using it's symbolic name.
std::uint32_t const prefix = hpx::get_locality_id();
/*
boost::format
active_threads("/threads{locality#%d/total}/count/instantaneous/active");
id_type id = get_counter(hpx::util::format(
"/threads{locality#%d/total}/count/instantaneous/active",
prefix));
*/
boost::format active_threads(counter_name);
id_type id = get_counter(boost::str(active_threads % prefix));
id_type id = get_counter(hpx::util::format(counter_name, prefix));
return id;
}

Expand Down Expand Up @@ -107,7 +105,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::uint64_t r = fib(hpx::find_here(), n);

char const* fmt = "fibonacci(%1%) == %2%\nelapsed time: %3% [s]\n";
std::cout << (boost::format(fmt) % n % r % t.elapsed());
hpx::util::format_to(std::cout, fmt, n, r, t.elapsed());
}

return hpx::finalize(); // Handles HPX shutdown
Expand Down
6 changes: 2 additions & 4 deletions examples/apex/apex_policy_engine_events.cpp
Expand Up @@ -9,17 +9,15 @@

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/util.hpp>

#include <apex_api.hpp>

#include <cstdint>
#include <iostream>

#include <boost/format.hpp>

///////////////////////////////////////////////////////////////////////////////
// forward declaration of the Fibonacci function
std::uint64_t fibonacci(std::uint64_t n);
Expand Down Expand Up @@ -65,7 +63,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::uint64_t r = fib(hpx::find_here(), n);

char const* fmt = "fibonacci(%1%) == %2%\nelapsed time: %3% [s]\n";
std::cout << (boost::format(fmt) % n % r % t.elapsed());
hpx::util::format_to(std::cout, fmt, n, r, t.elapsed());
}

return hpx::finalize(); // Handles HPX shutdown
Expand Down
6 changes: 2 additions & 4 deletions examples/apex/apex_policy_engine_periodic.cpp
Expand Up @@ -9,17 +9,15 @@

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/util.hpp>

#include <apex_api.hpp>

#include <cstdint>
#include <iostream>

#include <boost/format.hpp>

///////////////////////////////////////////////////////////////////////////////
// forward declaration of the Fibonacci function
std::uint64_t fibonacci(std::uint64_t n);
Expand Down Expand Up @@ -65,7 +63,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::uint64_t r = fib(hpx::find_here(), n);

char const* fmt = "fibonacci(%1%) == %2%\nelapsed time: %3% [s]\n";
std::cout << (boost::format(fmt) % n % r % t.elapsed());
hpx::util::format_to(std::cout, fmt, n, r, t.elapsed());
}

return hpx::finalize(); // Handles HPX shutdown
Expand Down
17 changes: 9 additions & 8 deletions examples/balancing/os_thread_num.cpp
Expand Up @@ -8,6 +8,7 @@
#include <hpx/include/iostreams.hpp>
#include <hpx/lcos/local/barrier.hpp>
#include <hpx/util/bind.hpp>
#include <hpx/util/format.hpp>
#include <boost/lockfree/queue.hpp>

#include <cstddef>
Expand Down Expand Up @@ -111,15 +112,15 @@ int hpx_main(variables_map& vm)
for (sorter::value_type const& result : sort)
{
if (csv)
cout << ( boost::format("%1%,%2%\n")
% result.second
% result.first)
<< flush;
hpx::util::format_to(cout,
"%1%,%2%\n",
result.second,
result.first) << flush;
else
cout << ( boost::format("OS-thread %1% ran %2% PX-threads\n")
% result.second
% result.first)
<< flush;
hpx::util::format_to(cout,
"OS-thread %1% ran %2% PX-threads\n",
result.second,
result.first) << flush;
}
}

Expand Down
26 changes: 13 additions & 13 deletions examples/heartbeat/heartbeat.cpp
Expand Up @@ -14,8 +14,7 @@
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/state.hpp>

#include <boost/format.hpp>
#include <hpx/util/format.hpp>

#include <cstdint>
#include <iostream>
Expand Down Expand Up @@ -45,18 +44,18 @@ int monitor(double runfor, std::string const& name, std::uint64_t pause)
hpx::naming::id_type id = hpx::performance_counters::get_counter(name);
if (!id)
{
std::cout << (boost::format(
"error: performance counter not found (%s)")
% name) << std::endl;
hpx::util::format_to(std::cout,
"error: performance counter not found (%s)",
name) << std::endl;
return 1;
}

std::uint32_t const locality_id = hpx::get_locality_id();
if (locality_id == hpx::naming::get_locality_id_from_gid(id.get_gid()))
{
std::cout << (boost::format(
"error: cannot query performance counters on its own locality (%s)")
% name) << std::endl;
hpx::util::format_to(std::cout,
"error: cannot query performance counters on its own locality (%s)",
name) << std::endl;
return 1;
}

Expand Down Expand Up @@ -86,11 +85,12 @@ int monitor(double runfor, std::string const& name, std::uint64_t pause)
if (!zero_time)
zero_time = value.time_;

std::cout << (boost::format(" %s,%d,%d[s],%d\n")
% name
% value.count_
% double((value.time_ - zero_time) * 1e-9)
% value.value_);
hpx::util::format_to(std::cout,
" %s,%d,%d[s],%d\n",
name,
value.count_,
double((value.time_ - zero_time) * 1e-9),
value.value_);

#if defined(HPX_WINDOWS) && HPX_USE_WINDOWS_PERFORMANCE_COUNTERS != 0
update_windows_counters(value.value_);
Expand Down
2 changes: 0 additions & 2 deletions examples/performance_counters/sine/sine.cpp
Expand Up @@ -9,8 +9,6 @@
#include <hpx/include/performance_counters.hpp>
#include <hpx/util/bind.hpp>

#include <boost/format.hpp>

#include <cstdint>

#include "server/sine.hpp"
Expand Down