• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

celerity / celerity-runtime / 11970970296

22 Nov 2024 10:35AM UTC coverage: 94.911% (+0.1%) from 94.802%
11970970296

Pull #298

github

web-flow
Merge 7621d2b92 into 28eadd65d
Pull Request #298: Add scheduler lookahead to elide buffer resizes

3189 of 3626 branches covered (87.95%)

Branch coverage included in aggregate %.

233 of 234 new or added lines in 6 files covered. (99.57%)

1 existing line in 1 file now uncovered.

7049 of 7161 relevant lines covered (98.44%)

1254159.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.21
/src/config.cc
1
#include "config.h"
2

3
#include <cstdlib>
4
#include <string_view>
5

6
#include "affinity.h"
7
#include "log.h"
8

9
#include <spdlog/sinks/sink.h>
10

11
#include <libenvpp/env.hpp>
12

13
namespace env {
14

15
template <>
16
struct default_parser<celerity::detail::log_level> {
17
        celerity::detail::log_level operator()(const std::string_view str) const {
5✔
18
                const std::vector<std::pair<celerity::detail::log_level, std::string>> possible_values = {
5✔
19
                    {celerity::detail::log_level::trace, "trace"},
5✔
20
                    {celerity::detail::log_level::debug, "debug"},
5✔
21
                    {celerity::detail::log_level::info, "info"},
5✔
22
                    {celerity::detail::log_level::warn, "warn"},
5✔
23
                    {celerity::detail::log_level::err, "err"},
5✔
24
                    {celerity::detail::log_level::critical, "critical"},
5✔
25
                    {celerity::detail::log_level::off, "off"},
5✔
26
                };
55!
27

28
                auto lvl = celerity::detail::log_level::info;
5✔
29
                bool valid = false;
5✔
30
                for(const auto& pv : possible_values) {
16✔
31
                        if(str == pv.second) {
15✔
32
                                lvl = pv.first;
4✔
33
                                valid = true;
4✔
34
                                break;
4✔
35
                        }
36
                }
37
                auto err_msg = fmt::format("Unable to parse '{}'. Possible values are:", str);
5✔
38
                for(size_t i = 0; i < possible_values.size(); ++i) {
40✔
39
                        err_msg += fmt::format(" {}{}", possible_values[i].second, (i < possible_values.size() - 1 ? ", " : "."));
70✔
40
                }
41
                if(!valid) throw parser_error{err_msg};
5✔
42

43
                return lvl;
4✔
44
        }
11✔
45
};
46

47
template <>
48
struct default_parser<celerity::detail::tracy_mode> {
49
        celerity::detail::tracy_mode operator()(const std::string_view str) const {
4✔
50
                if(str == "off") {
4✔
51
                        return celerity::detail::tracy_mode::off;
1✔
52
                } else if(str == "fast") {
3✔
53
                        return celerity::detail::tracy_mode::fast;
1✔
54
                } else if(str == "full") {
2✔
55
                        return celerity::detail::tracy_mode::full;
1✔
56
                } else {
57
                        throw parser_error{fmt::format("Unable to parse '{}'. Possible values are: off, fast, full.", str)};
2✔
58
                }
59
        }
60
};
61

62
template <>
63
struct default_parser<celerity::experimental::lookahead> {
64
        celerity::experimental::lookahead operator()(const std::string_view str) const {
3✔
65
                if(str == "none") {
3✔
66
                        return celerity::experimental::lookahead::none;
1✔
67
                } else if(str == "auto") {
2✔
68
                        return celerity::experimental::lookahead::automatic;
1✔
69
                } else if(str == "infinite") {
1!
70
                        return celerity::experimental::lookahead::infinite;
1✔
71
                } else {
NEW
72
                        throw parser_error{fmt::format("Unable to parse '{}'. Possible values are: none, auto, infinite.", str)};
×
73
                }
74
        }
75
};
76

77
} // namespace env
78

79
namespace {
80

81
bool parse_validate_profile_kernel(const std::string_view str) {
4✔
82
        const auto pk = env::default_parser<bool>{}(str);
4✔
83
        CELERITY_DEBUG("CELERITY_PROFILE_KERNEL={}.", pk ? "on" : "off");
3✔
84
        return pk;
3✔
85
}
86

87
size_t parse_validate_dry_run_nodes(const std::string_view str) {
10✔
88
        const size_t drn = env::default_parser<size_t>{}(str);
10✔
89
        CELERITY_WARN("Performing a dry run with {} simulated nodes", drn);
9!
90
        return drn;
9✔
91
}
92

93
} // namespace
94

95
namespace celerity {
96
namespace detail {
97

98
        config::config(int* argc, char** argv[]) {
241✔
99
                // TODO: At some point we might want to parse arguments from argv as well
100

101
                auto pref = env::prefix("CELERITY");
241✔
102
                const auto env_log_level = pref.register_option<log_level>(
482✔
103
                    "LOG_LEVEL", {log_level::trace, log_level::debug, log_level::info, log_level::warn, log_level::err, log_level::critical, log_level::off});
241✔
104
                const auto env_profile_kernel = pref.register_variable<bool>("PROFILE_KERNEL", parse_validate_profile_kernel);
241✔
105
                const auto env_backend_device_submission_threads = pref.register_variable<bool>("BACKEND_DEVICE_SUBMISSION_THREADS");
241✔
106
                const auto env_thread_pinning = pref.register_variable<thread_pinning::environment_configuration>("THREAD_PINNING", thread_pinning::parse_validate_env);
241✔
107
                const auto env_print_graphs = pref.register_variable<bool>("PRINT_GRAPHS");
241✔
108
                const auto env_dry_run_num_nodes = pref.register_variable<size_t>("DRY_RUN_NODES", parse_validate_dry_run_nodes);
241✔
109
                constexpr int horizon_max = 1024 * 64;
241✔
110
                const auto env_horizon_step = pref.register_range<int>("HORIZON_STEP", 1, horizon_max);
241✔
111
                const auto env_horizon_max_para = pref.register_range<int>("HORIZON_MAX_PARALLELISM", 1, horizon_max);
241✔
112
                const auto env_lookahead = pref.register_option<experimental::lookahead>(
482✔
113
                    "LOOKAHEAD", {experimental::lookahead::none, experimental::lookahead::automatic, experimental::lookahead::infinite});
241✔
114
                const auto env_tracy_mode = pref.register_option<tracy_mode>("TRACY", {tracy_mode::off, tracy_mode::fast, tracy_mode::full});
241✔
115

116
                pref.register_deprecated("FORCE_WG", "Support for CELERITY_FORCE_WG has been removed with Celerity 0.3.0.");
241✔
117
                pref.register_deprecated("PROFILE_OCL", "CELERITY_PROFILE_OCL has been renamed to CELERITY_PROFILE_KERNEL with Celerity 0.3.0.");
241✔
118
                pref.register_deprecated("GRAPH_PRINT_MAX_VERTS", "Support for CELERITY_GRAPH_PRINT_MAX_VERTS has been removed with Celerity 0.5.0.\n"
241✔
119
                                                                  "Opt into graph printing by setting CELERITY_PRINT_GRAPHS=1.");
120
                pref.register_deprecated("DEVICES", "Support for CELERITY_DEVICES has been removed with Celerity 0.6.0.\n"
241✔
121
                                                    "Please use SYCL or vendor specific means to limit device visibility.");
122

123
                const auto parsed_and_validated_envs = pref.parse_and_validate();
241✔
124
                if(parsed_and_validated_envs.ok()) {
241✔
125
#if CELERITY_DETAIL_ENABLE_DEBUG
126
                        m_log_lvl = parsed_and_validated_envs.get_or(env_log_level, log_level::debug);
233✔
127
#else
128
                        m_log_lvl = parsed_and_validated_envs.get_or(env_log_level, log_level::info);
129
#endif
130

131
                        const auto has_profile_kernel = parsed_and_validated_envs.get(env_profile_kernel);
233✔
132
                        if(has_profile_kernel) { m_enable_device_profiling = *has_profile_kernel; }
233✔
133

134
                        m_enable_backend_device_submission_threads = parsed_and_validated_envs.get_or(env_backend_device_submission_threads, true);
233✔
135
#if CELERITY_WORKAROUND(SIMSYCL)
136
                        // SimSYCL is not thread safe
137
                        if(m_enable_backend_device_submission_threads) {
233!
138
                                CELERITY_WARN("CELERITY_BACKEND_DEVICE_SUBMISSION_THREADS=on is not supported with SimSYCL. Disabling worker threads.");
466✔
139
                                m_enable_backend_device_submission_threads = false;
233✔
140
                        }
141
#endif // CELERITY_WORKAROUND(SIMSYCL)
142

143
                        m_thread_pinning_config = parsed_and_validated_envs.get_or(env_thread_pinning, {});
233✔
144

145
                        const auto dry_run_num_nodes = parsed_and_validated_envs.get(env_dry_run_num_nodes);
233✔
146
                        if(dry_run_num_nodes) { m_dry_run_num_nodes = static_cast<int>(*dry_run_num_nodes); }
233✔
147

148
                        m_should_print_graphs = parsed_and_validated_envs.get_or(env_print_graphs, false);
233✔
149

150
                        m_horizon_step = parsed_and_validated_envs.get(env_horizon_step);
233✔
151
                        m_horizon_max_parallelism = parsed_and_validated_envs.get(env_horizon_max_para);
233✔
152
                        m_lookahead = parsed_and_validated_envs.get_or(env_lookahead, experimental::lookahead::automatic);
233✔
153

154
                        m_tracy_mode = parsed_and_validated_envs.get_or(env_tracy_mode, tracy_mode::off);
233✔
155
                } else {
156
                        for(const auto& warn : parsed_and_validated_envs.warnings()) {
8!
157
                                CELERITY_ERROR("{}", warn.what());
×
158
                        }
159
                        for(const auto& err : parsed_and_validated_envs.errors()) {
16✔
160
                                CELERITY_ERROR("{}", err.what());
8!
161
                        }
162
                        throw std::runtime_error("Failed to parse/validate environment variables.");
8✔
163
                }
164
        }
490✔
165
} // namespace detail
166
} // namespace celerity
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc