DCGPUBU-44: Added arbitrary envvars to file/dir names. Squashed some fixes.
- Added arbitrary env-vars - Fixed some UBs with atomic variables - Fixed loading of file plugin - ATT vs. kernel-trace off by one Change-Id: I69c75f66f722e4085b5279f41afd05813628846d
This commit is contained in:
@@ -95,8 +95,6 @@ class file_plugin_t {
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
output_file_name = replace_MPI_macros(output_file_name);
|
||||
|
||||
ss << output_file_name << GetPid() << "_" << name_;
|
||||
stream_.open(output_prefix / ss.str());
|
||||
}
|
||||
@@ -104,28 +102,6 @@ class file_plugin_t {
|
||||
bool is_open() const { return stream_.is_open(); }
|
||||
bool fail() const { return stream_.fail(); }
|
||||
|
||||
// Returns a string with the MPI %macro replaced with the corresponding envvar
|
||||
std::string replace_MPI_macros(std::string output_file_name) {
|
||||
std::unordered_map<const char*, const char*> MPI_BUILTINS = {
|
||||
{"MPI_RANK", "%rank"},
|
||||
{"OMPI_COMM_WORLD_RANK", "%rank"},
|
||||
{"MV2_COMM_WORLD_RANK", "%rank"}};
|
||||
|
||||
for (const auto& [envvar, key] : MPI_BUILTINS) {
|
||||
size_t key_find = output_file_name.rfind(key);
|
||||
if (key_find == std::string::npos) continue; // Does not contain a %?rank var
|
||||
|
||||
const char* env_var_set = getenv(envvar);
|
||||
if (env_var_set == nullptr) continue; // MPI_COMM_WORLD_x var is does not exist
|
||||
|
||||
int rank = atoi(env_var_set);
|
||||
output_file_name = output_file_name.substr(0, key_find) + std::to_string(rank) +
|
||||
output_file_name.substr(key_find + std::string(key).size());
|
||||
}
|
||||
|
||||
return output_file_name;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string name_;
|
||||
std::ofstream stream_;
|
||||
|
||||
Reference in New Issue
Block a user