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

Move run_as_os_thread from hpx::threads to hpx:: #476

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions octotiger/radiation/kernel_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace octotiger { namespace radiation {
static std::atomic_size_t next_index(0);
std::size_t index = next_index++;

hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
dumper::save_case_args(index, opts().eos, opts().problem,
opts().dual_energy_sw1, opts().dual_energy_sw2, physcon().A,
physcon().B, physcon().c, fgamma, dt, clightinv, er_i, fx_i,
Expand All @@ -176,7 +176,7 @@ namespace octotiger { namespace radiation {
tau, fgamma, U, mmw, X_spc, Z_spc, dt, clightinv);

#if defined(OCTOTIGER_DUMP_RADIATION_CASES)
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
dumper::save_case_outs(index, sx, sy, sz, egas, tau, U);
}).get();
#endif
Expand Down
2 changes: 1 addition & 1 deletion octotiger/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int file_copy(const char* fin, const char* fout);
template<class... Args>
int lprint( const char* log, const char* str, Args&&...args) {
// run output on separate thread
auto f = hpx::threads::run_as_os_thread([&]() -> int
auto f = hpx::run_as_os_thread([&]() -> int
{
if(!opts().disable_output) {
FILE* fp = fopen (log, "at");
Expand Down
18 changes: 9 additions & 9 deletions src/io/silo_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void load_options_from_silo(std::string fname, DBfile *db) {
}
};
if (db == nullptr) {
GET(hpx::threads::run_as_os_thread(func));
GET(hpx::run_as_os_thread(func));
} else {
func();
}
Expand All @@ -135,7 +135,7 @@ void load_options_from_silo(std::string fname, DBfile *db) {
void load_open(std::string fname, dir_map_type map) {
// printf("LOAD OPENED on proc %i\n", hpx::get_locality_id());
load_options_from_silo(fname, db_); /**/
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
db_ = DBOpenReal(fname.c_str(), DB_UNKNOWN, DB_READ);
read_silo_var<real> rr;
silo_output_time() = rr(db_, "cgs_time"); /**/
Expand Down Expand Up @@ -187,7 +187,7 @@ node_server::node_server(const node_location &loc) :
static const auto hydro_names = grid::get_hydro_field_names();
load.vars.resize(hydro_names.size());
load.outflows.resize(hydro_names.size());
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
static std::mutex mtx;
std::lock_guard<std::mutex> lock(mtx);
const auto this_file = iter->second.filename;
Expand Down Expand Up @@ -264,27 +264,27 @@ void load_data_from_silo(std::string fname, node_server *root_ptr, hpx::id_type

const integer nprocs = opts().all_localities.size();
static int sz = localities.size();
DBfile *db = GET(hpx::threads::run_as_os_thread(DBOpenReal, fname.c_str(), DB_UNKNOWN, DB_READ));
silo_epoch() = GET(hpx::threads::run_as_os_thread(read_silo_var<integer>(), db, "epoch"));
DBfile *db = GET(hpx::run_as_os_thread(DBOpenReal, fname.c_str(), DB_UNKNOWN, DB_READ));
silo_epoch() = GET(hpx::run_as_os_thread(read_silo_var<integer>(), db, "epoch"));
silo_epoch()++;std
::vector<node_location::node_id> node_list;
std::vector<integer> positions;
std::vector<hpx::future<void>> futs;
int node_count;
if (db != nullptr) {
DBmultimesh *master_mesh = GET(hpx::threads::run_as_os_thread([&]() {
DBmultimesh *master_mesh = GET(hpx::run_as_os_thread([&]() {
return DBGetMultimesh(db, "quadmesh");
}));
const int chunk_size = std::ceil(real(master_mesh->nblocks) / real(sz));
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
const read_silo_var<integer> ri;
node_count = ri(db, "node_count");
node_list.resize(node_count);
positions.resize(node_count);
DBReadVar(db, "node_list", node_list.data());
DBReadVar(db, "node_positions", positions.data());
}).get();
GET(hpx::threads::run_as_os_thread(DBClose, db));
GET(hpx::run_as_os_thread(DBClose, db));
std::map<node_location::node_id, std::string> load_locs;
for (int i = 0; i < master_mesh->nblocks; i++) {
load_locs.insert(split_mesh_id(master_mesh->meshnames[i]));
Expand All @@ -307,7 +307,7 @@ void load_data_from_silo(std::string fname, node_server *root_ptr, hpx::id_type
// printf("Sending LOAD OPEN to %i\n", i);
futs.push_back(hpx::async < load_open_action > (opts().all_localities[i], fname, this_dir));
}
GET(hpx::threads::run_as_os_thread(DBFreeMultimesh, master_mesh));
GET(hpx::run_as_os_thread(DBFreeMultimesh, master_mesh));
for (auto &f : futs) {
GET(f);
}
Expand Down
6 changes: 3 additions & 3 deletions src/io/silo_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void output_stage3(std::string fname, int cycle, int gn, int gb, int ge) {
const auto dir = opts().data_dir;
std::string this_fname = dir + fname + ".silo.data/" + std::to_string(gn) + std::string(".silo");
double dtime = silo_output_rotation_time();
hpx::threads::run_as_os_thread([&this_fname, this_id, &dtime, gb, gn, ge](integer cycle) {
hpx::run_as_os_thread([&this_fname, this_id, &dtime, gb, gn, ge](integer cycle) {
DBfile *db;
if (this_id == gb) {
// printf( "Create %s %i %i %i %i\n", this_fname.c_str(), this_id, gn, gb, ge);
Expand Down Expand Up @@ -259,7 +259,7 @@ void output_stage4(std::string fname, int cycle) {
std::string this_fname = opts().data_dir + "/" + fname + std::string(".silo");
double dtime = silo_output_rotation_time();
double rtime = silo_output_rotation_time();
hpx::threads::run_as_os_thread([&this_fname, fname, nfields, &rtime](int cycle) {
hpx::run_as_os_thread([&this_fname, fname, nfields, &rtime](int cycle) {
auto *db = DBCreateReal(this_fname.c_str(), DB_CLOBBER, DB_LOCAL, "Octo-tiger", SILO_DRIVER);
double dtime = silo_output_time();
float ftime = dtime;
Expand Down Expand Up @@ -518,7 +518,7 @@ void output_all(node_server *root_ptr, std::string fname, int cycle, bool block)
}

std::string dir = opts().data_dir + "/" + fname + ".silo.data";
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {
auto rc = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (rc != 0 && errno != EEXIST) {
printf("Could not create directory for SILO file. mkdir failed with error. code: %i name: %s", errno, std::strerror(errno));
Expand Down
10 changes: 5 additions & 5 deletions src/node_server_actions_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void node_server::execute_solver(bool scf, node_count_type ngrids) {

// run output on separate thread
if (!opts().disable_output) {
hpx::threads::run_as_os_thread([=]() {
hpx::run_as_os_thread([=]() {
FILE *fp = fopen((opts().data_dir + "step.dat").c_str(), "at");
if (fp == NULL) {
printf( "Unable to open step.dat for writing %s\n", std::strerror(errno));
Expand All @@ -430,7 +430,7 @@ void node_server::execute_solver(bool scf, node_count_type ngrids) {
}); // do not wait for it to finish
}

/* hpx::threads::run_as_os_thread( */
/* hpx::run_as_os_thread( */
/* [=]() { */
{
const auto vr = sqrt(sqr(dt_.ur[sx_i]) + sqr(dt_.ur[sy_i]) + sqr(dt_.ur[sz_i])) / dt_.ur[0];
Expand All @@ -457,7 +457,7 @@ void node_server::execute_solver(bool scf, node_count_type ngrids) {
ngrids = regrid(me.get_gid(), omega, new_floor, false);

// run output on separate thread
auto need_break = hpx::threads::run_as_os_thread([&]() {
auto need_break = hpx::run_as_os_thread([&]() {
// set_omega_and_pivot();
bench_stop = hpx::chrono::high_resolution_clock::now() / 1e9;
if (scf || opts().bench) {
Expand Down Expand Up @@ -502,7 +502,7 @@ void node_server::execute_solver(bool scf, node_count_type ngrids) {
}

if (opts().bench && !opts().disable_output) {
hpx::threads::run_as_os_thread([&]() {
hpx::run_as_os_thread([&]() {

FILE *fp = fopen((opts().data_dir + "scaling.dat").c_str(), "at");
const auto nproc = options::all_localities.size();
Expand Down Expand Up @@ -678,7 +678,7 @@ future<real> node_server::local_step(integer steps) {
if (opts().print_times_per_timestep)
timestep_util::add_time_per_timestep(time_elapsed);

hpx::threads::run_as_os_thread([=]() {
hpx::run_as_os_thread([=]() {
printf("%i %e %e %e %e\n", local_step_num, double(current_time), double(dt_.dt), time_elapsed, rotational_time);
}); // do not wait for output to finish
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ real LambertW(real z) {

int file_copy(const char* fin, const char* fout) {
// run output on separate thread
auto f = hpx::threads::run_as_os_thread([&]()
auto f = hpx::run_as_os_thread([&]()
{
constexpr size_t chunk_size = BUFSIZ;
char buffer[chunk_size];
Expand Down