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

celerity / celerity-runtime / 10325124557

09 Aug 2024 08:11PM UTC coverage: 95.087% (+0.02%) from 95.07%
10325124557

push

github

fknorr
Update benchmark results for Tracy integration

3014 of 3414 branches covered (88.28%)

Branch coverage included in aggregate %.

6624 of 6722 relevant lines covered (98.54%)

1474033.76 hits per line

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

92.77
/src/runtime.cc
1
#include "runtime.h"
2

3
#include <limits>
4
#include <string>
5

6
#ifdef _MSC_VER
7
#include <process.h>
8
#else
9
#include <unistd.h>
10
#endif
11

12
#include <mpi.h>
13

14
#if CELERITY_USE_MIMALLOC
15
// override default new/delete operators to use the mimalloc memory allocator
16
#include <mimalloc-new-delete.h>
17
#endif
18

19
#include "affinity.h"
20
#include "backend/sycl_backend.h"
21
#include "cgf_diagnostics.h"
22
#include "device_selection.h"
23
#include "distributed_graph_generator.h"
24
#include "dry_run_executor.h"
25
#include "host_object.h"
26
#include "instruction_graph_generator.h"
27
#include "live_executor.h"
28
#include "log.h"
29
#include "mpi_communicator.h"
30
#include "print_graph.h"
31
#include "reduction.h"
32
#include "scheduler.h"
33
#include "system_info.h"
34
#include "task_manager.h"
35
#include "tracy.h"
36
#include "version.h"
37

38
namespace celerity {
39
namespace detail {
40

41
        std::unique_ptr<runtime> runtime::s_instance = nullptr;
42

43
        void runtime::mpi_initialize_once(int* argc, char*** argv) {
56✔
44
                CELERITY_DETAIL_TRACY_ZONE_SCOPED_V("mpi::init", LightSkyBlue, "MPI_Init");
45
                assert(!s_mpi_initialized);
56✔
46
                int provided;
56✔
47
                MPI_Init_thread(argc, argv, MPI_THREAD_MULTIPLE, &provided);
56✔
48
                assert(provided == MPI_THREAD_MULTIPLE);
56✔
49
                s_mpi_initialized = true;
56✔
50
        }
56✔
51

52
        void runtime::mpi_finalize_once() {
56✔
53
                CELERITY_DETAIL_TRACY_ZONE_SCOPED_V("mpi::finalize", LightSkyBlue, "MPI_Finalize");
54
                assert(s_mpi_initialized && !s_mpi_finalized && (!s_test_mode || !s_instance));
56✔
55
                MPI_Finalize();
56✔
56
                s_mpi_finalized = true;
56✔
57
        }
56✔
58

59
        void runtime::init(int* argc, char** argv[], const devices_or_selector& user_devices_or_selector) {
223✔
60
                assert(!s_instance);
223✔
61
                s_instance = std::unique_ptr<runtime>(new runtime(argc, argv, user_devices_or_selector));
223!
62
        }
223✔
63

64
        runtime& runtime::get_instance() {
5,493✔
65
                if(s_instance == nullptr) { throw std::runtime_error("Runtime has not been initialized"); }
5,493!
66
                return *s_instance;
5,493✔
67
        }
68

69
        static auto get_pid() {
223✔
70
#ifdef _MSC_VER
71
                return _getpid();
72
#else
73
                return getpid();
223✔
74
#endif
75
        }
76

77
        static std::string get_version_string() {
223✔
78
                using namespace celerity::version;
79
                return fmt::format("{}.{}.{} {}{}", major, minor, patch, git_revision, git_dirty ? "-dirty" : "");
446!
80
        }
81

82
        static const char* get_build_type() {
223✔
83
#if defined(CELERITY_DETAIL_ENABLE_DEBUG)
84
                return "debug";
223✔
85
#else
86
                return "release";
87
#endif
88
        }
89

90
        static const char* get_mimalloc_string() {
223✔
91
#if CELERITY_USE_MIMALLOC
92
                return "using mimalloc";
93
#else
94
                return "using the default allocator";
223✔
95
#endif
96
        }
97

98
        static std::string get_sycl_version() {
223✔
99
#if defined(__HIPSYCL__) || defined(__HIPSYCL_TRANSFORM__)
100
                return fmt::format("AdaptiveCpp {}.{}.{}", HIPSYCL_VERSION_MAJOR, HIPSYCL_VERSION_MINOR, HIPSYCL_VERSION_PATCH);
101
#elif CELERITY_DPCPP
102
                return "DPC++ / Clang " __clang_version__;
103
#elif CELERITY_SIMSYCL
104
                return "SimSYCL " SIMSYCL_VERSION;
669✔
105
#else
106
#error "unknown SYCL implementation"
107
#endif
108
        }
109

110
        static host_config get_mpi_host_config() {
217✔
111
                // Determine the "host config", i.e., how many nodes are spawned on this host,
112
                // and what this node's local rank is. We do this by finding all world-ranks
113
                // that can use a shared-memory transport (if running on OpenMPI, use the
114
                // per-host split instead).
115
#ifdef OPEN_MPI
116
#define SPLIT_TYPE OMPI_COMM_TYPE_HOST
117
#else
118
                // TODO: Assert that shared memory is available (i.e. not explicitly disabled)
119
#define SPLIT_TYPE MPI_COMM_TYPE_SHARED
120
#endif
121
                MPI_Comm host_comm = nullptr;
217✔
122
                MPI_Comm_split_type(MPI_COMM_WORLD, SPLIT_TYPE, 0, MPI_INFO_NULL, &host_comm);
217✔
123

124
                int local_rank = 0;
217✔
125
                MPI_Comm_rank(host_comm, &local_rank);
217✔
126

127
                int node_count = 0;
217✔
128
                MPI_Comm_size(host_comm, &node_count);
217✔
129

130
                host_config host_cfg;
217✔
131
                host_cfg.local_rank = local_rank;
217✔
132
                host_cfg.node_count = node_count;
217✔
133

134
                MPI_Comm_free(&host_comm);
217✔
135

136
                return host_cfg;
434✔
137
        }
138

139
        runtime::runtime(int* argc, char** argv[], const devices_or_selector& user_devices_or_selector) {
223✔
140
                m_application_thread = std::this_thread::get_id();
223✔
141

142
                m_cfg = std::make_unique<config>(argc, argv);
223✔
143

144
                CELERITY_DETAIL_IF_TRACY_SUPPORTED(tracy_detail::g_tracy_mode = m_cfg->get_tracy_mode());
145
                CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::startup", DarkGray);
146

147
                if(s_test_mode) {
223✔
148
                        assert(s_test_active && "initializing the runtime from a test without a runtime_fixture");
180✔
149
                        s_test_runtime_was_instantiated = true;
180✔
150
                } else {
151
                        mpi_initialize_once(argc, argv);
43✔
152
                }
153

154
                int world_size = -1;
223✔
155
                int world_rank = -1;
223✔
156
                MPI_Comm_size(MPI_COMM_WORLD, &world_size);
223✔
157
                MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
223✔
158

159
                host_config host_cfg;
223✔
160
                if(m_cfg->is_dry_run()) {
223✔
161
                        if(world_size != 1) throw std::runtime_error("In order to run with CELERITY_DRY_RUN_NODES a single MPI process/rank must be used.");
6!
162
                        m_num_nodes = static_cast<size_t>(m_cfg->get_dry_run_nodes());
6✔
163
                        m_local_nid = 0;
6✔
164
                        host_cfg.node_count = 1;
6✔
165
                        host_cfg.local_rank = 0;
6✔
166
                } else {
167
                        m_num_nodes = static_cast<size_t>(world_size);
217✔
168
                        m_local_nid = static_cast<node_id>(world_rank);
217✔
169
                        host_cfg = get_mpi_host_config();
217✔
170
                }
171

172
                // Do not touch logger settings in tests, where the full (trace) logs are captured
173
                if(!s_test_mode) {
223✔
174
                        spdlog::set_level(m_cfg->get_log_level());
43✔
175
                        spdlog::set_pattern(fmt::format("[%Y-%m-%d %H:%M:%S.%e] [{:0{}}] [%^%l%$] %v", m_local_nid, int(ceil(log10(double(m_num_nodes))))));
86✔
176
                }
177

178
                CELERITY_INFO("Celerity runtime version {} running on {}. PID = {}, build type = {}, {}", get_version_string(), get_sycl_version(), get_pid(),
223✔
179
                    get_build_type(), get_mimalloc_string());
180

181
#ifndef __APPLE__
182
                if(const uint32_t cores = affinity_cores_available(); cores < min_cores_needed) {
223!
183
                        CELERITY_WARN("Celerity has detected that only {} logical cores are available to this process. It is recommended to assign at least {} "
×
184
                                      "logical cores. Performance may be negatively impacted.",
185
                            cores, min_cores_needed);
186
                }
187
#endif
188

189
                if(!s_test_mode && m_cfg->get_tracy_mode() != tracy_mode::off) {
223!
190
                        if constexpr(CELERITY_TRACY_SUPPORT) {
191
                                CELERITY_WARN("Profiling with Tracy is enabled. Performance may be negatively impacted.");
192
                        } else {
193
                                CELERITY_WARN("CELERITY_TRACY is set, but Celerity was compiled without Tracy support. Ignoring.");
×
194
                        }
195
                }
196

197
                cgf_diagnostics::make_available();
223✔
198

199
                std::vector<sycl::device> devices;
223✔
200
                {
201
                        CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::pick_devices", PaleVioletRed);
202
                        devices = std::visit([&](const auto& value) { return pick_devices(host_cfg, value, sycl::platform::get_platforms()); }, user_devices_or_selector);
446✔
203
                        assert(!devices.empty()); // postcondition of pick_devices
223✔
204
                }
205

206
                auto backend = make_sycl_backend(select_backend(sycl_backend_enumerator{}, devices), devices, m_cfg->should_enable_device_profiling());
223✔
207
                const auto system = backend->get_system_info(); // backend is about to be moved
223✔
208

209
                if(m_cfg->is_dry_run()) {
223✔
210
                        m_exec = std::make_unique<dry_run_executor>(static_cast<executor::delegate*>(this));
6✔
211
                } else {
212
                        auto comm = std::make_unique<mpi_communicator>(collective_clone_from, MPI_COMM_WORLD);
217✔
213
                        m_exec = std::make_unique<live_executor>(std::move(backend), std::move(comm), static_cast<executor::delegate*>(this));
217✔
214
                }
217✔
215

216
                if(m_cfg->should_record()) {
223✔
217
                        m_task_recorder = std::make_unique<task_recorder>();
16✔
218
                        m_command_recorder = std::make_unique<command_recorder>();
16✔
219
                        m_instruction_recorder = std::make_unique<instruction_recorder>();
16✔
220
                }
221

222
                task_manager::policy_set task_mngr_policy;
223✔
223
                // Merely _declaring_ an uninitialized read is legitimate as long as the kernel does not actually perform the read at runtime - this might happen in the
224
                // first iteration of a submit-loop. We could get rid of this case by making access-modes a runtime property of accessors (cf
225
                // https://github.com/celerity/meta/issues/74).
226
                task_mngr_policy.uninitialized_read_error = CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_warning : error_policy::ignore;
223✔
227

228
                m_task_mngr = std::make_unique<task_manager>(m_num_nodes, m_task_recorder.get(), task_mngr_policy);
223✔
229
                if(m_cfg->get_horizon_step()) m_task_mngr->set_horizon_step(m_cfg->get_horizon_step().value());
223!
230
                if(m_cfg->get_horizon_max_parallelism()) m_task_mngr->set_horizon_max_parallelism(m_cfg->get_horizon_max_parallelism().value());
223!
231

232
                scheduler::policy_set schdlr_policy;
223✔
233
                // Any uninitialized read that is observed on CDAG generation was already logged on task generation, unless we have a bug.
234
                schdlr_policy.command_graph_generator.uninitialized_read_error = error_policy::ignore;
223✔
235
                schdlr_policy.instruction_graph_generator.uninitialized_read_error = error_policy::ignore;
223✔
236
                schdlr_policy.command_graph_generator.overlapping_write_error = CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_error : error_policy::ignore;
223✔
237
                schdlr_policy.instruction_graph_generator.overlapping_write_error =
223✔
238
                    CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_error : error_policy::ignore;
239
                schdlr_policy.instruction_graph_generator.unsafe_oversubscription_error = error_policy::log_warning;
223✔
240

241
                m_schdlr = std::make_unique<scheduler>(m_num_nodes, m_local_nid, system, *m_task_mngr, static_cast<abstract_scheduler::delegate*>(this),
892✔
242
                    m_command_recorder.get(), m_instruction_recorder.get(), schdlr_policy);
669✔
243
                m_task_mngr->register_task_callback([this](const task* tsk) { m_schdlr->notify_task_created(tsk); });
5,302✔
244

245
                m_num_local_devices = system.devices.size();
223✔
246
        }
446✔
247

248
        void runtime::require_call_from_application_thread() const {
5,864✔
249
                if(std::this_thread::get_id() != m_application_thread) {
5,864✔
250
                        utils::panic("Celerity runtime, distr_queue, handler, buffer and host_object types must only be constructed, used, and destroyed from the "
40✔
251
                                     "application thread. Make sure that you did not accidentally capture one of these types in a host_task.");
252
                }
253
        }
5,854✔
254

255
        runtime::~runtime() {
223✔
256
                // LCOV_EXCL_START
257
                if(!is_unreferenced()) {
258
                        // this call might originate from static destruction - we cannot assume spdlog to still be around
259
                        utils::panic("Detected an attempt to destroy runtime while at least one distr_queue, buffer or host_object was still alive. This likely means "
260
                                     "that one of these objects was leaked, or at least its lifetime extended beyond the scope of main(). This is undefined.");
261
                }
262
                // LCOV_EXCL_STOP
263

264
                require_call_from_application_thread();
223✔
265

266
                CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::shutdown", DimGray);
267

268
                // Create and await the shutdown epoch
269
                sync(epoch_action::shutdown);
223✔
270

271
                // The shutdown epoch is, by definition, the last task (and command / instruction) issued. Since it has now completed, no more scheduler -> executor
272
                // traffic will occur, and `runtime` can stop functioning as a scheduler_delegate (which would require m_exec to be live).
273
                m_exec.reset();
223✔
274

275
                // ~executor() joins its thread after notifying the scheduler that the shutdown epoch has been reached, which means that this notification is
276
                // sequenced-before the destructor return, and `runtime` can now stop functioning as an executor_delegate (which would require m_schdlr to be live).
277
                m_schdlr.reset();
223✔
278

279
                // Since scheduler and executor threads are gone, task_manager::epoch_monitor is not shared across threads anymore
280
                m_task_mngr.reset();
223✔
281

282
                // With scheduler and executor threads gone, all recorders can be safely accessed from the runtime / application thread
283
                if(spdlog::should_log(log_level::info) && m_cfg->should_print_graphs()) {
223!
284
                        if(m_local_nid == 0) { // It's the same across all nodes
16✔
285
                                assert(m_task_recorder.get() != nullptr);
8✔
286
                                const auto tdag_str = detail::print_task_graph(*m_task_recorder);
24✔
287
                                CELERITY_INFO("Task graph:\n\n{}\n", tdag_str);
8!
288
                        }
8✔
289

290
                        assert(m_command_recorder.get() != nullptr);
16✔
291
                        auto cdag_str = print_command_graph(m_local_nid, *m_command_recorder);
48✔
292
                        if(!is_dry_run()) { cdag_str = gather_command_graph(cdag_str, m_num_nodes, m_local_nid); } // must be called on all nodes
16!
293

294
                        if(m_local_nid == 0) {
16✔
295
                                // Avoid racing on stdout with other nodes (funneled through mpirun)
296
                                if(!is_dry_run()) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); }
8!
297
                                CELERITY_INFO("Command graph:\n\n{}\n", cdag_str);
8!
298
                        }
299

300
                        // IDAGs become unreadable when all nodes print them at the same time - TODO attempt gathering them as well?
301
                        if(m_local_nid == 0) {
16✔
302
                                // we are allowed to deref m_instruction_recorder / m_command_recorder because the scheduler thread has exited at this point
303
                                const auto idag_str = detail::print_instruction_graph(*m_instruction_recorder, *m_command_recorder, *m_task_recorder);
24✔
304
                                CELERITY_INFO("Instruction graph on node 0:\n\n{}\n", idag_str);
8!
305
                        }
8✔
306
                }
16✔
307

308
                m_instruction_recorder.reset();
223✔
309
                m_command_recorder.reset();
223✔
310
                m_task_recorder.reset();
223✔
311

312
                cgf_diagnostics::teardown();
223✔
313

314
                if(!s_test_mode) { mpi_finalize_once(); }
223✔
315
        }
223✔
316

317
        task_id runtime::sync(epoch_action action) {
297✔
318
                require_call_from_application_thread();
297✔
319

320
                const auto epoch = m_task_mngr->generate_epoch_task(action);
296✔
321
                m_task_mngr->await_epoch(epoch);
296✔
322
                return epoch;
296✔
323
        }
324

325
        task_manager& runtime::get_task_manager() const {
3,975✔
326
                require_call_from_application_thread();
3,975✔
327
                return *m_task_mngr;
3,973✔
328
        }
329

330
        std::string gather_command_graph(const std::string& graph_str, const size_t num_nodes, const node_id local_nid) {
18✔
331
                const auto comm = MPI_COMM_WORLD;
18✔
332
                const int tag = 0xCDA6; // aka 'CDAG' - Celerity does not perform any other peer-to-peer communication over MPI_COMM_WORLD
18✔
333

334
                // Send local graph to rank 0 on all other nodes
335
                if(local_nid != 0) {
18✔
336
                        const uint64_t usize = graph_str.size();
9✔
337
                        assert(usize < std::numeric_limits<int32_t>::max());
9✔
338
                        const int32_t size = static_cast<int32_t>(usize);
9✔
339
                        MPI_Send(&size, 1, MPI_INT32_T, 0, tag, comm);
9✔
340
                        if(size > 0) MPI_Send(graph_str.data(), static_cast<int32_t>(size), MPI_BYTE, 0, tag, comm);
9!
341
                        return "";
27✔
342
                }
343
                // On node 0, receive and combine
344
                std::vector<std::string> graphs;
9✔
345
                graphs.push_back(graph_str);
9✔
346
                for(node_id peer = 1; peer < num_nodes; ++peer) {
18✔
347
                        int32_t size = 0;
9✔
348
                        MPI_Recv(&size, 1, MPI_INT32_T, static_cast<int>(peer), tag, comm, MPI_STATUS_IGNORE);
9✔
349
                        if(size > 0) {
9!
350
                                std::string graph;
9✔
351
                                graph.resize(size);
9✔
352
                                MPI_Recv(graph.data(), size, MPI_BYTE, static_cast<int>(peer), tag, comm, MPI_STATUS_IGNORE);
9✔
353
                                graphs.push_back(std::move(graph));
9✔
354
                        }
9✔
355
                }
356
                return combine_command_graphs(graphs);
27✔
357
        }
9✔
358

359
        // scheduler::delegate
360

361
        void runtime::flush(std::vector<const instruction*> instructions, std::vector<outbound_pilot> pilots) {
6,120✔
362
                // thread-safe
363
                assert(m_exec != nullptr);
6,120✔
364
                m_exec->submit(std::move(instructions), std::move(pilots));
6,120✔
365
        }
6,120✔
366

367
        // executor::delegate
368

369
        void runtime::horizon_reached(const task_id horizon_tid) {
839✔
370
                assert(m_task_mngr != nullptr);
839✔
371
                m_task_mngr->notify_horizon_reached(horizon_tid); // thread-safe
839✔
372

373
                // The two-horizon logic is duplicated from task_manager::notify_horizon_reached. TODO move epoch_monitor from task_manager to runtime.
374
                assert(m_schdlr != nullptr);
839✔
375
                if(m_latest_horizon_reached.has_value()) { m_schdlr->notify_epoch_reached(*m_latest_horizon_reached); }
839✔
376
                m_latest_horizon_reached = horizon_tid;
839✔
377
        }
839✔
378

379
        void runtime::epoch_reached(const task_id epoch_tid) {
296✔
380
                assert(m_task_mngr != nullptr);
296✔
381
                m_task_mngr->notify_epoch_reached(epoch_tid); // thread-safe
296✔
382

383
                assert(m_schdlr != nullptr);
296✔
384
                m_schdlr->notify_epoch_reached(epoch_tid);
296✔
385
                m_latest_horizon_reached = std::nullopt; // Any non-applied horizon is now behind the epoch and will therefore never become an epoch itself
296✔
386
        }
296✔
387

388
        void runtime::create_queue() {
213✔
389
                require_call_from_application_thread();
213✔
390

391
                if(m_has_live_queue) { throw std::runtime_error("Only one celerity::distr_queue can be created per process (but it can be copied!)"); }
212✔
392
                m_has_live_queue = true;
211✔
393
        }
211✔
394

395
        void runtime::destroy_queue() {
212✔
396
                require_call_from_application_thread();
212✔
397

398
                assert(m_has_live_queue);
211✔
399
                m_has_live_queue = false;
211✔
400
                destroy_instance_if_unreferenced();
211✔
401
        }
211✔
402

403
        allocation_id runtime::create_user_allocation(void* const ptr) {
108✔
404
                require_call_from_application_thread();
108✔
405
                const auto aid = allocation_id(user_memory_id, m_next_user_allocation_id++);
107✔
406
                m_exec->track_user_allocation(aid, ptr);
107✔
407
                return aid;
107✔
408
        }
409

410
        buffer_id runtime::create_buffer(const range<3>& range, const size_t elem_size, const size_t elem_align, const allocation_id user_aid) {
340✔
411
                require_call_from_application_thread();
340✔
412

413
                const auto bid = m_next_buffer_id++;
339✔
414
                m_live_buffers.emplace(bid);
339✔
415
                m_task_mngr->notify_buffer_created(bid, range, user_aid != null_allocation_id);
339✔
416
                m_schdlr->notify_buffer_created(bid, range, elem_size, elem_align, user_aid);
339✔
417
                return bid;
678✔
418
        }
419

420
        void runtime::set_buffer_debug_name(const buffer_id bid, const std::string& debug_name) {
23✔
421
                require_call_from_application_thread();
23✔
422

423
                assert(utils::contains(m_live_buffers, bid));
23✔
424
                m_task_mngr->notify_buffer_debug_name_changed(bid, debug_name);
23✔
425
                m_schdlr->notify_buffer_debug_name_changed(bid, debug_name);
23✔
426
        }
23✔
427

428
        void runtime::destroy_buffer(const buffer_id bid) {
340✔
429
                require_call_from_application_thread();
340✔
430

431
                assert(utils::contains(m_live_buffers, bid));
339✔
432
                m_schdlr->notify_buffer_destroyed(bid);
339✔
433
                m_task_mngr->notify_buffer_destroyed(bid);
339✔
434
                m_live_buffers.erase(bid);
339✔
435
                destroy_instance_if_unreferenced();
339✔
436
        }
339✔
437

438
        host_object_id runtime::create_host_object(std::unique_ptr<host_object_instance> instance) {
34✔
439
                require_call_from_application_thread();
34✔
440

441
                const auto hoid = m_next_host_object_id++;
33✔
442
                m_live_host_objects.emplace(hoid);
33✔
443
                const bool owns_instance = instance != nullptr;
33✔
444
                if(owns_instance) { m_exec->track_host_object_instance(hoid, std::move(instance)); }
33✔
445
                m_task_mngr->notify_host_object_created(hoid);
33✔
446
                m_schdlr->notify_host_object_created(hoid, owns_instance);
33✔
447
                return hoid;
66✔
448
        }
449

450
        void runtime::destroy_host_object(const host_object_id hoid) {
34✔
451
                require_call_from_application_thread();
34✔
452

453
                assert(utils::contains(m_live_host_objects, hoid));
33✔
454
                m_schdlr->notify_host_object_destroyed(hoid);
33✔
455
                m_task_mngr->notify_host_object_destroyed(hoid);
33✔
456
                m_live_host_objects.erase(hoid);
33✔
457
                destroy_instance_if_unreferenced();
33✔
458
        }
33✔
459

460

461
        reduction_id runtime::create_reduction(std::unique_ptr<reducer> reducer) {
65✔
462
                require_call_from_application_thread();
65✔
463

464
                const auto rid = m_next_reduction_id++;
65✔
465
                m_exec->track_reducer(rid, std::move(reducer));
65✔
466
                return rid;
130✔
467
        }
468

469
        bool runtime::is_unreferenced() const { return !m_has_live_queue && m_live_buffers.empty() && m_live_host_objects.empty(); }
806✔
470

471
        void runtime::destroy_instance_if_unreferenced() {
583✔
472
                if(s_instance == nullptr) return;
583!
473
                if(s_instance->is_unreferenced()) { s_instance.reset(); }
583✔
474
        }
475

476
} // namespace detail
477
} // 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