From 2d9e9ebc8ced1389e3408759d89fb5da5d9d5a63 Mon Sep 17 00:00:00 2001 From: FacuMH Date: Wed, 25 Jan 2023 14:14:32 +0100 Subject: [PATCH] Deprecated env vars handling --- include/config.h | 3 ++- src/config.cc | 23 +++++++++++++++-------- test/runtime_tests.cc | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/config.h b/include/config.h index 4a8d1206f..ad71428c0 100644 --- a/include/config.h +++ b/include/config.h @@ -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 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 diff --git a/src/config.cc b/src/config.cc index f98918a57..efa10de47 100644 --- a/src/config.cc +++ b/src/config.cc @@ -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{}(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; } @@ -86,9 +86,9 @@ namespace detail { devices.push_back(env::default_parser{}(split_str[i])); } if(devices.size() < 2) - throw env::validation_error{ - "Found " + std::to_string(devices.size()) - + "\nExpected the following format: CELERITY_DEVICES=\" ... \""}; + throw env::validation_error{fmt::format( + "Found {} IDs.\nExpected the following format: CELERITY_DEVICES=\" ... \"", + std::to_string(devices.size()))}; if(static_cast(m_host_cfg.local_rank) > static_cast(devices.size()) - 2) { throw env::validation_error{fmt::format( @@ -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[]) { @@ -146,7 +151,9 @@ namespace detail { const auto env_dry_run_nodes = pref.register_variable("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("FORCE_WG", [this](const std::string_view str) { return parse_validate_forge_wg(str); }); + pref.register_variable("FORCE_WG", [this](const std::string_view str) { return parse_validate_force_wg(str); }); + [[maybe_unused]] const auto env_profile_ocl = + pref.register_variable("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()) { diff --git a/test/runtime_tests.cc b/test/runtime_tests.cc index 9f199eb0e..6ebe3da61 100644 --- a/test/runtime_tests.cc +++ b/test/runtime_tests.cc @@ -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]") {