Skip to content

Commit

Permalink
Deprecated env vars handling
Browse files Browse the repository at this point in the history
  • Loading branch information
facuMH committed Feb 22, 2023
1 parent 948d73b commit 5604c07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ namespace detail {
bool parse_validate_profile_kernel(const std::string_view str);
size_t parse_validate_dry_run_nodes(const std::string_view str);
std::vector<size_t> parse_validate_devices(const std::string_view str);
int parse_validate_forge_wg(const std::string_view str);
bool parse_validate_force_wg(const std::string_view str);
bool parse_validate_profile_ocl(const std::string_view str);
};

} // namespace detail
Expand Down
23 changes: 15 additions & 8 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace detail {

size_t config::parse_validate_dry_run_nodes(const std::string_view str) {
const size_t drn = env::default_parser<size_t>{}(str);
if(m_host_cfg.node_count != 1) throw std::runtime_error("In order to run with CELERITY_DRY_RUN_NODES a single MPI process/rank must be used.\n");
if(m_host_cfg.node_count != 1) throw std::runtime_error("In order to run with CELERITY_DRY_RUN_NODES a single MPI process/rank must be used.");
CELERITY_WARN("Performing a dry run with {} simulated nodes", drn);
return drn;
}
Expand All @@ -86,9 +86,9 @@ namespace detail {
devices.push_back(env::default_parser<size_t>{}(split_str[i]));
}
if(devices.size() < 2)
throw env::validation_error{
"Found " + std::to_string(devices.size())
+ "\nExpected the following format: CELERITY_DEVICES=\"<platform_id> <first device_id> <second device_id> ... <nth device_id>\""};
throw env::validation_error{fmt::format(
"Found {} IDs.\nExpected the following format: CELERITY_DEVICES=\"<platform_id> <first device_id> <second device_id> ... <nth device_id>\"",
std::to_string(devices.size()))};

if(static_cast<long>(m_host_cfg.local_rank) > static_cast<long>(devices.size()) - 2) {
throw env::validation_error{fmt::format(
Expand All @@ -102,9 +102,14 @@ namespace detail {
return devices;
}

int config::parse_validate_forge_wg(const std::string_view str) {
CELERITY_WARN("Support for CELERITY_FORCE_WG has been removed with Celerity 0.3.0.");
return 0;
bool config::parse_validate_force_wg(const std::string_view str) {
throw env::validation_error{fmt::format("Support for CELERITY_FORCE_WG has been removed with Celerity 0.3.0.")};
return false;
}

bool config::parse_validate_profile_ocl(const std::string_view str) {
throw env::validation_error{fmt::format("CELERITY_PROFILE_OCL has been renamed to CELERITY_PROFILE_KERNEL with Celerity 0.3.0.")};
return false;
}

config::config(int* argc, char** argv[]) {
Expand Down Expand Up @@ -146,7 +151,9 @@ namespace detail {
const auto env_dry_run_nodes =
pref.register_variable<size_t>("DRY_RUN_NODES", [this](const std::string_view str) { return parse_validate_dry_run_nodes(str); });
[[maybe_unused]] const auto env_force_wg =
pref.register_variable<int>("FORCE_WG", [this](const std::string_view str) { return parse_validate_forge_wg(str); });
pref.register_variable<bool>("FORCE_WG", [this](const std::string_view str) { return parse_validate_force_wg(str); });
[[maybe_unused]] const auto env_profile_ocl =
pref.register_variable<bool>("PROFILE_OCL", [this](const std::string_view str) { return parse_validate_profile_ocl(str); });

const auto parsed_and_validated_envs = pref.parse_and_validate();
if(parsed_and_validated_envs.ok()) {
Expand Down
1 change: 1 addition & 0 deletions test/runtime_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ namespace detail {
const auto has_prof = cfg.get_enable_device_profiling();
REQUIRE(has_prof.has_value());
REQUIRE((*has_prof) == true);
REQUIRE(cfg.get_dry_run_nodes() == 4);
}

TEST_CASE_METHOD(test_utils::mpi_fixture, "Config reports incorrect environment varibles", "[env-vars]") {
Expand Down

0 comments on commit 5604c07

Please sign in to comment.