-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#pragma once | ||
#ifndef DISH2_RECORD_STINTROOTIDCHANGEOVERRECORDER_HPP_INCLUDE | ||
#define DISH2_RECORD_STINTROOTIDCHANGEOVERRECORDER_HPP_INCLUDE | ||
|
||
#include <string> | ||
|
||
#include "../../../third-party/bxzstr/include/bxzstr.hpp" | ||
#include "../../../third-party/conduit/include/uitsl/mpi/comm_utils.hpp" | ||
#include "../../../third-party/Empirical/include/emp/data/DataFile.hpp" | ||
#include "../../../third-party/Empirical/include/emp/tools/keyname_utils.hpp" | ||
#include "../../../third-party/Empirical/include/emp/tools/string_utils.hpp" | ||
#include "../../../third-party/signalgp-lite/include/sgpl/utility/CountingIterator.hpp" | ||
|
||
#include "../config/has_replicate.hpp" | ||
#include "../config/has_series.hpp" | ||
#include "../config/has_stint.hpp" | ||
#include "../config/thread_idx.hpp" | ||
#include "../debug/log_msg.hpp" | ||
#include "../utility/pare_keyname_filename.hpp" | ||
|
||
#include "make_filename/make_data_path.hpp" | ||
#include "make_filename/make_stint_root_id_changeover_filename.hpp" | ||
|
||
|
||
namespace dish2 { | ||
|
||
class StintRootIDChangeoverRecorder { | ||
|
||
std::string outpath; | ||
bxz::ofstream ofstream; | ||
emp::DataFile file; | ||
|
||
// thread_local so that copying/moving doesn't break DataFile refs | ||
inline static thread_local uint64_t root_id_; | ||
inline static thread_local uint64_t incoming_stint_root_id_; | ||
inline static thread_local uint64_t outgoing_stint_root_id_; | ||
|
||
public: | ||
|
||
StintRootIDChangeoverRecorder() | ||
: outpath( | ||
dish2::make_data_path( | ||
dish2::pare_keyname_filename( | ||
dish2::make_stint_root_id_changeover_filename(), | ||
dish2::make_data_path() | ||
) | ||
) | ||
) | ||
, ofstream( | ||
outpath, bxz::lzma, 6 | ||
) | ||
, file( ofstream ) { | ||
|
||
if ( dish2::has_stint() ) file.AddVal(cfg.STINT(), "Stint"); | ||
if ( dish2::has_series() ) file.AddVal(cfg.SERIES(), "Series"); | ||
if ( dish2::has_replicate() ) file.AddVal(cfg.REPLICATE(), "Replicate"); | ||
file.AddVal(cfg.TREATMENT(), "Treatment"); | ||
if ( cfg.TREATMENT().find('=') != std::string::npos ) { | ||
for ( const auto& [k, v] : emp::keyname::unpack( cfg.TREATMENT() ) ) { | ||
file.AddVal( v, emp::to_string("Treatment ", k) ); | ||
} | ||
} | ||
file.AddVal( uitsl::get_proc_id(), "proc" ); | ||
file.AddVal( dish2::thread_idx, "thread" ); | ||
|
||
file.AddVar(root_id_, "Root ID"); | ||
file.AddVar(incoming_stint_root_id_, "Incoming Stint Root ID"); | ||
file.AddVar(outgoing_stint_root_id_, "Outgoing Stint Root ID"); | ||
|
||
file.PrintHeaderKeys(); | ||
|
||
dish2::log_msg( "initialized stint_root_id record at ", outpath ); | ||
|
||
} | ||
|
||
void record_changeover( | ||
const uint64_t root_id, | ||
const uint64_t incoming_stint_root_id, | ||
const uint64_t outgoing_stint_root_id | ||
) { | ||
|
||
root_id_ = root_id; | ||
incoming_stint_root_id_ = incoming_stint_root_id; | ||
outgoing_stint_root_id_ = outgoing_stint_root_id; | ||
|
||
file.Update(); | ||
|
||
} | ||
|
||
}; | ||
|
||
} // namespace dish2 | ||
|
||
#endif // #ifndef DISH2_RECORD_STINTROOTIDCHANGEOVERRECORDER_HPP_INCLUDE |
65 changes: 65 additions & 0 deletions
65
include/dish2/record/make_filename/make_stint_root_id_changeover_filename.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma once | ||
#ifndef DISH2_RECORD_MAKE_FILENAME_MAKE_STINT_ROOT_ID_CHANGEOVER_FILENAME_HPP_INCLUDE | ||
#define DISH2_RECORD_MAKE_FILENAME_MAKE_STINT_ROOT_ID_CHANGEOVER_FILENAME_HPP_INCLUDE | ||
|
||
#include <cstdlib> | ||
#include <string> | ||
|
||
#include "../../../../third-party/conduit/include/uitsl/mpi/comm_utils.hpp" | ||
#include "../../../../third-party/Empirical/include/emp/base/macros.hpp" | ||
#include "../../../../third-party/Empirical/include/emp/tools/keyname_utils.hpp" | ||
#include "../../../../third-party/Empirical/include/emp/tools/string_utils.hpp" | ||
|
||
#include "../../config/cfg.hpp" | ||
#include "../../config/get_endeavor.hpp" | ||
#include "../../config/get_repro.hpp" | ||
#include "../../config/get_slurm_job_id.hpp" | ||
#include "../../config/has_replicate.hpp" | ||
#include "../../config/has_series.hpp" | ||
#include "../../config/has_stint.hpp" | ||
#include "../../config/thread_idx.hpp" | ||
|
||
namespace dish2 { | ||
|
||
std::string make_stint_root_id_changeover_filename() { | ||
auto keyname_attributes = emp::keyname::unpack_t{ | ||
{"a", "stint_root_id_changeover"}, | ||
{"proc", emp::to_string( uitsl::get_proc_id() )}, | ||
{"_source", EMP_STRINGIFY(DISHTINY_HASH_)}, | ||
{"thread", emp::to_string( dish2::thread_idx )}, | ||
{"_treatment", emp::keyname::demote( dish2::cfg.TREATMENT() )}, | ||
{"ext", ".csv.xz"} | ||
}; | ||
|
||
if ( dish2::get_repro() ) { | ||
keyname_attributes[ "_repro" ] = *dish2::get_repro(); | ||
} | ||
|
||
if ( dish2::has_series() ) { | ||
keyname_attributes[ "series" ] = emp::to_string( cfg.SERIES() ); | ||
} | ||
|
||
if ( dish2::has_stint() ) { | ||
keyname_attributes[ "stint" ] = emp::to_string( cfg.STINT() ); | ||
} | ||
|
||
if ( dish2::has_replicate() ) { | ||
keyname_attributes[ "replicate" ] = cfg.REPLICATE(); | ||
} | ||
|
||
if ( dish2::get_endeavor() ) { | ||
keyname_attributes[ "_endeavor" ] = emp::to_string(*dish2::get_endeavor()); | ||
} | ||
|
||
if ( dish2::get_slurm_job_id() ) { | ||
keyname_attributes[ "_slurm_job_id" ] = emp::to_string( | ||
*dish2::get_slurm_job_id() | ||
); | ||
} | ||
|
||
return emp::keyname::pack( keyname_attributes ); | ||
} | ||
|
||
} // namespace dish2 | ||
|
||
#endif // #ifndef DISH2_RECORD_MAKE_FILENAME_MAKE_STINT_ROOT_ID_CHANGEOVER_FILENAME_HPP_INCLUDE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters