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

celerity / celerity-runtime / 11251914715

09 Oct 2024 09:13AM UTC coverage: 95.051% (-0.05%) from 95.102%
11251914715

push

github

fknorr
Update changelog for new queue APIs

3021 of 3426 branches covered (88.18%)

Branch coverage included in aggregate %.

6659 of 6758 relevant lines covered (98.54%)

1492206.97 hits per line

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

91.84
/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
#if CELERITY_USE_MIMALLOC
13
// override default new/delete operators to use the mimalloc memory allocator
14
#include <mimalloc-new-delete.h>
15
#endif
16

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

35
#if CELERITY_ENABLE_MPI
36
#include "mpi_communicator.h"
37
#include <mpi.h>
38
#else
39
#include "local_communicator.h"
40
#endif
41

42

43
namespace celerity {
44
namespace detail {
45

46
        std::unique_ptr<runtime> runtime::s_instance = nullptr;
47

48
        void runtime::mpi_initialize_once(int* argc, char*** argv) {
56✔
49
#if CELERITY_ENABLE_MPI
50
                CELERITY_DETAIL_TRACY_ZONE_SCOPED_V("mpi::init", LightSkyBlue, "MPI_Init");
51
                assert(!s_mpi_initialized);
56✔
52
                int provided;
56✔
53
                MPI_Init_thread(argc, argv, MPI_THREAD_MULTIPLE, &provided);
56✔
54
                assert(provided == MPI_THREAD_MULTIPLE);
56✔
55
#endif // CELERITY_ENABLE_MPI
56
                s_mpi_initialized = true;
56✔
57
        }
56✔
58

59
        void runtime::mpi_finalize_once() {
56✔
60
#if CELERITY_ENABLE_MPI
61
                CELERITY_DETAIL_TRACY_ZONE_SCOPED_V("mpi::finalize", LightSkyBlue, "MPI_Finalize");
62
                assert(s_mpi_initialized && !s_mpi_finalized && (!s_test_mode || !s_instance));
56✔
63
                MPI_Finalize();
56✔
64
#endif // CELERITY_ENABLE_MPI
65
                s_mpi_finalized = true;
56✔
66
        }
56✔
67

68
        void runtime::init(int* argc, char** argv[], const devices_or_selector& user_devices_or_selector) {
228✔
69
                assert(!s_instance);
228✔
70
                s_instance = std::unique_ptr<runtime>(new runtime(argc, argv, user_devices_or_selector));
228!
71
                if(!s_test_mode) { atexit(shutdown); }
228✔
72
        }
228✔
73

74
        runtime& runtime::get_instance() {
5,782✔
75
                if(s_instance == nullptr) { throw std::runtime_error("Runtime has not been initialized"); }
5,782!
76
                return *s_instance;
5,782✔
77
        }
78

79
        void runtime::shutdown() { s_instance.reset(); }
49✔
80

81
        static auto get_pid() {
228✔
82
#ifdef _MSC_VER
83
                return _getpid();
84
#else
85
                return getpid();
228✔
86
#endif
87
        }
88

89
        static std::string get_version_string() {
228✔
90
                using namespace celerity::version;
91
                return fmt::format("{}.{}.{} {}{}", major, minor, patch, git_revision, git_dirty ? "-dirty" : "");
456!
92
        }
93

94
        static const char* get_build_type() {
228✔
95
#if CELERITY_DETAIL_ENABLE_DEBUG
96
                return "debug";
228✔
97
#else
98
                return "release";
99
#endif
100
        }
101

102
        static const char* get_mimalloc_string() {
228✔
103
#if CELERITY_USE_MIMALLOC
104
                return "using mimalloc";
105
#else
106
                return "using the default allocator";
228✔
107
#endif
108
        }
109

110
        static std::string get_sycl_version() {
228✔
111
#if CELERITY_SYCL_IS_ACPP
112
                return fmt::format("AdaptiveCpp {}.{}.{}", HIPSYCL_VERSION_MAJOR, HIPSYCL_VERSION_MINOR, HIPSYCL_VERSION_PATCH);
113
#elif CELERITY_SYCL_IS_DPCPP
114
                return "DPC++ / Clang " __clang_version__;
115
#elif CELERITY_SYCL_IS_SIMSYCL
116
                return "SimSYCL " SIMSYCL_VERSION;
684✔
117
#else
118
#error "unknown SYCL implementation"
119
#endif
120
        }
121

122
        static std::string get_mpi_version() {
228✔
123
#if CELERITY_ENABLE_MPI
124
                char version[MPI_MAX_LIBRARY_VERSION_STRING];
228✔
125
                int len = -1;
228✔
126
                MPI_Get_library_version(version, &len);
228✔
127
                // try shortening the human-readable version string (so far tested on OpenMPI)
128
                if(const auto brk = /* find last of */ strpbrk(version, ",;")) { len = static_cast<int>(brk - version); }
228!
129
                return std::string(version, static_cast<size_t>(len));
912✔
130
#else
131
                return "single node";
132
#endif
133
        }
134

135
        static host_config get_mpi_host_config() {
222✔
136
#if CELERITY_ENABLE_MPI
137
                // Determine the "host config", i.e., how many nodes are spawned on this host,
138
                // and what this node's local rank is. We do this by finding all world-ranks
139
                // that can use a shared-memory transport (if running on OpenMPI, use the
140
                // per-host split instead).
141
#ifdef OPEN_MPI
142
#define SPLIT_TYPE OMPI_COMM_TYPE_HOST
143
#else
144
                // TODO: Assert that shared memory is available (i.e. not explicitly disabled)
145
#define SPLIT_TYPE MPI_COMM_TYPE_SHARED
146
#endif
147
                MPI_Comm host_comm = nullptr;
222✔
148
                MPI_Comm_split_type(MPI_COMM_WORLD, SPLIT_TYPE, 0, MPI_INFO_NULL, &host_comm);
222✔
149

150
                int local_rank = 0;
222✔
151
                MPI_Comm_rank(host_comm, &local_rank);
222✔
152

153
                int node_count = 0;
222✔
154
                MPI_Comm_size(host_comm, &node_count);
222✔
155

156
                host_config host_cfg;
222✔
157
                host_cfg.local_rank = local_rank;
222✔
158
                host_cfg.node_count = node_count;
222✔
159

160
                MPI_Comm_free(&host_comm);
222✔
161

162
                return host_cfg;
444✔
163
#else  // CELERITY_ENABLE_MPI
164
                return host_config{1, 0};
165
#endif // CELERITY_ENABLE_MPI
166
        }
167

168
        runtime::runtime(int* argc, char** argv[], const devices_or_selector& user_devices_or_selector) {
228✔
169
                m_application_thread = std::this_thread::get_id();
228✔
170

171
                m_cfg = std::make_unique<config>(argc, argv);
228✔
172

173
                CELERITY_DETAIL_IF_TRACY_SUPPORTED(tracy_detail::g_tracy_mode = m_cfg->get_tracy_mode());
174
                CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::startup", DarkGray);
175

176
                if(s_test_mode) {
228✔
177
                        assert(s_test_active && "initializing the runtime from a test without a runtime_fixture");
185✔
178
                        s_test_runtime_was_instantiated = true;
185✔
179
                } else {
180
                        mpi_initialize_once(argc, argv);
43✔
181
                }
182

183
                int world_size = 1;
228✔
184
                int world_rank = 0;
228✔
185
#if CELERITY_ENABLE_MPI
186
                MPI_Comm_size(MPI_COMM_WORLD, &world_size);
228✔
187
                MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
228✔
188
#endif
189

190
                host_config host_cfg;
228✔
191
                if(m_cfg->is_dry_run()) {
228✔
192
                        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!
193
                        m_num_nodes = static_cast<size_t>(m_cfg->get_dry_run_nodes());
6✔
194
                        m_local_nid = 0;
6✔
195
                        host_cfg.node_count = 1;
6✔
196
                        host_cfg.local_rank = 0;
6✔
197
                } else {
198
                        m_num_nodes = static_cast<size_t>(world_size);
222✔
199
                        m_local_nid = static_cast<node_id>(world_rank);
222✔
200
                        host_cfg = get_mpi_host_config();
222✔
201
                }
202

203
                // Do not touch logger settings in tests, where the full (trace) logs are captured
204
                if(!s_test_mode) {
228✔
205
                        spdlog::set_level(m_cfg->get_log_level());
43✔
206
                        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✔
207
                }
208

209
                CELERITY_INFO("Celerity runtime version {} running on {} / {}. PID = {}, build type = {}, {}", get_version_string(), get_sycl_version(),
228✔
210
                    get_mpi_version(), get_pid(), get_build_type(), get_mimalloc_string());
211

212
#ifndef __APPLE__
213
                if(const uint32_t cores = affinity_cores_available(); cores < min_cores_needed) {
228!
214
                        CELERITY_WARN("Celerity has detected that only {} logical cores are available to this process. It is recommended to assign at least {} "
×
215
                                      "logical cores. Performance may be negatively impacted.",
216
                            cores, min_cores_needed);
217
                }
218
#endif
219

220
                if(!s_test_mode && m_cfg->get_tracy_mode() != tracy_mode::off) {
228!
221
                        if constexpr(CELERITY_TRACY_SUPPORT) {
222
                                CELERITY_WARN("Profiling with Tracy is enabled. Performance may be negatively impacted.");
223
                        } else {
224
                                CELERITY_WARN("CELERITY_TRACY is set, but Celerity was compiled without Tracy support. Ignoring.");
×
225
                        }
226
                }
227

228
                cgf_diagnostics::make_available();
228✔
229

230
                std::vector<sycl::device> devices;
228✔
231
                {
232
                        CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::pick_devices", PaleVioletRed);
233
                        devices = std::visit([&](const auto& value) { return pick_devices(host_cfg, value, sycl::platform::get_platforms()); }, user_devices_or_selector);
456✔
234
                        assert(!devices.empty()); // postcondition of pick_devices
228✔
235
                }
236

237
                auto backend = make_sycl_backend(select_backend(sycl_backend_enumerator{}, devices), devices, m_cfg->should_enable_device_profiling());
228✔
238
                const auto system = backend->get_system_info(); // backend is about to be moved
228✔
239

240
                if(m_cfg->is_dry_run()) {
228✔
241
                        m_exec = std::make_unique<dry_run_executor>(static_cast<executor::delegate*>(this));
6✔
242
                } else {
243
#if CELERITY_ENABLE_MPI
244
                        auto comm = std::make_unique<mpi_communicator>(collective_clone_from, MPI_COMM_WORLD);
222✔
245
#else
246
                        auto comm = std::make_unique<local_communicator>();
247
#endif
248
                        m_exec = std::make_unique<live_executor>(std::move(backend), std::move(comm), static_cast<executor::delegate*>(this));
222✔
249
                }
222✔
250

251
                if(m_cfg->should_record()) {
228✔
252
                        m_task_recorder = std::make_unique<task_recorder>();
16✔
253
                        m_command_recorder = std::make_unique<command_recorder>();
16✔
254
                        m_instruction_recorder = std::make_unique<instruction_recorder>();
16✔
255
                }
256

257
                task_manager::policy_set task_mngr_policy;
228✔
258
                // 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
259
                // first iteration of a submit-loop. We could get rid of this case by making access-modes a runtime property of accessors (cf
260
                // https://github.com/celerity/meta/issues/74).
261
                task_mngr_policy.uninitialized_read_error = CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_warning : error_policy::ignore;
228✔
262

263
                m_task_mngr = std::make_unique<task_manager>(m_num_nodes, m_task_recorder.get(), task_mngr_policy);
228✔
264
                if(m_cfg->get_horizon_step()) m_task_mngr->set_horizon_step(m_cfg->get_horizon_step().value());
228!
265
                if(m_cfg->get_horizon_max_parallelism()) m_task_mngr->set_horizon_max_parallelism(m_cfg->get_horizon_max_parallelism().value());
228!
266

267
                scheduler::policy_set schdlr_policy;
228✔
268
                // Any uninitialized read that is observed on CDAG generation was already logged on task generation, unless we have a bug.
269
                schdlr_policy.command_graph_generator.uninitialized_read_error = error_policy::ignore;
228✔
270
                schdlr_policy.instruction_graph_generator.uninitialized_read_error = error_policy::ignore;
228✔
271
                schdlr_policy.command_graph_generator.overlapping_write_error = CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_error : error_policy::ignore;
228✔
272
                schdlr_policy.instruction_graph_generator.overlapping_write_error =
228✔
273
                    CELERITY_ACCESS_PATTERN_DIAGNOSTICS ? error_policy::log_error : error_policy::ignore;
274
                schdlr_policy.instruction_graph_generator.unsafe_oversubscription_error = error_policy::log_warning;
228✔
275

276
                m_schdlr = std::make_unique<scheduler>(m_num_nodes, m_local_nid, system, *m_task_mngr, static_cast<abstract_scheduler::delegate*>(this),
912✔
277
                    m_command_recorder.get(), m_instruction_recorder.get(), schdlr_policy);
684✔
278
                m_task_mngr->register_task_callback([this](const task* tsk) { m_schdlr->notify_task_created(tsk); });
5,577✔
279

280
                m_num_local_devices = system.devices.size();
228✔
281
        }
456✔
282

283
        void runtime::require_call_from_application_thread() const {
6,163✔
284
                if(std::this_thread::get_id() != m_application_thread) {
6,163✔
285
                        utils::panic("Celerity runtime, queue, handler, buffer and host_object types must only be constructed, used, and destroyed from the "
40✔
286
                                     "application thread. Make sure that you did not accidentally capture one of these types in a host_task.");
287
                }
288
        }
6,153✔
289

290
        runtime::~runtime() {
228✔
291
                // LCOV_EXCL_START
292
                if(!is_unreferenced()) {
293
                        // this call might originate from static destruction - we cannot assume spdlog to still be around
294
                        utils::panic("Detected an attempt to destroy runtime while at least one queue, buffer or host_object was still alive. This likely means "
295
                                     "that one of these objects was leaked, or at least its lifetime extended beyond the scope of main(). This is undefined.");
296
                }
297
                // LCOV_EXCL_STOP
298

299
                require_call_from_application_thread();
228✔
300

301
                CELERITY_DETAIL_TRACY_ZONE_SCOPED("runtime::shutdown", DimGray);
302

303
                // Create and await the shutdown epoch
304
                sync(epoch_action::shutdown);
228✔
305

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

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

314
                // Since scheduler and executor threads are gone, task_manager::epoch_monitor is not shared across threads anymore
315
                m_task_mngr.reset();
228✔
316

317
                // With scheduler and executor threads gone, all recorders can be safely accessed from the runtime / application thread
318
                if(spdlog::should_log(log_level::info) && m_cfg->should_print_graphs()) {
228!
319
                        if(m_local_nid == 0) { // It's the same across all nodes
16✔
320
                                assert(m_task_recorder.get() != nullptr);
8✔
321
                                const auto tdag_str = detail::print_task_graph(*m_task_recorder);
24✔
322
                                CELERITY_INFO("Task graph:\n\n{}\n", tdag_str);
8!
323
                        }
8✔
324

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

329
                        if(m_local_nid == 0) {
16✔
330
                                // Avoid racing on stdout with other nodes (funneled through mpirun)
331
                                if(!is_dry_run()) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); }
8!
332
                                CELERITY_INFO("Command graph:\n\n{}\n", cdag_str);
8!
333
                        }
334

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

343
                m_instruction_recorder.reset();
228✔
344
                m_command_recorder.reset();
228✔
345
                m_task_recorder.reset();
228✔
346

347
                cgf_diagnostics::teardown();
228✔
348

349
                if(!s_test_mode) { mpi_finalize_once(); }
228✔
350
        }
228✔
351

352
        task_id runtime::sync(epoch_action action) {
566✔
353
                require_call_from_application_thread();
566✔
354

355
                const auto epoch = m_task_mngr->generate_epoch_task(action);
565✔
356
                m_task_mngr->await_epoch(epoch);
565✔
357
                return epoch;
565✔
358
        }
359

360
        task_manager& runtime::get_task_manager() const {
3,976✔
361
                require_call_from_application_thread();
3,976✔
362
                return *m_task_mngr;
3,974✔
363
        }
364

365
        std::string gather_command_graph(const std::string& graph_str, const size_t num_nodes, const node_id local_nid) {
18✔
366
#if CELERITY_ENABLE_MPI
367
                const auto comm = MPI_COMM_WORLD;
18✔
368
                const int tag = 0xCDA6; // aka 'CDAG' - Celerity does not perform any other peer-to-peer communication over MPI_COMM_WORLD
18✔
369

370
                // Send local graph to rank 0 on all other nodes
371
                if(local_nid != 0) {
18✔
372
                        const uint64_t usize = graph_str.size();
9✔
373
                        assert(usize < std::numeric_limits<int32_t>::max());
9✔
374
                        const int32_t size = static_cast<int32_t>(usize);
9✔
375
                        MPI_Send(&size, 1, MPI_INT32_T, 0, tag, comm);
9✔
376
                        if(size > 0) MPI_Send(graph_str.data(), static_cast<int32_t>(size), MPI_BYTE, 0, tag, comm);
9!
377
                        return "";
27✔
378
                }
379
                // On node 0, receive and combine
380
                std::vector<std::string> graphs;
9✔
381
                graphs.push_back(graph_str);
9✔
382
                for(node_id peer = 1; peer < num_nodes; ++peer) {
18✔
383
                        int32_t size = 0;
9✔
384
                        MPI_Recv(&size, 1, MPI_INT32_T, static_cast<int>(peer), tag, comm, MPI_STATUS_IGNORE);
9✔
385
                        if(size > 0) {
9!
386
                                std::string graph;
9✔
387
                                graph.resize(size);
9✔
388
                                MPI_Recv(graph.data(), size, MPI_BYTE, static_cast<int>(peer), tag, comm, MPI_STATUS_IGNORE);
9✔
389
                                graphs.push_back(std::move(graph));
9✔
390
                        }
9✔
391
                }
392
                return combine_command_graphs(graphs);
27✔
393
#else  // CELERITY_ENABLE_MPI
394
                assert(num_nodes == 1 && local_nid == 0);
395
                return graph_str;
396
#endif // CELERITY_ENABLE_MPI
397
        }
9✔
398

399
        // scheduler::delegate
400

401
        void runtime::flush(std::vector<const instruction*> instructions, std::vector<outbound_pilot> pilots) {
6,396✔
402
                // thread-safe
403
                assert(m_exec != nullptr);
6,396✔
404
                m_exec->submit(std::move(instructions), std::move(pilots));
6,396✔
405
        }
6,396✔
406

407
        // executor::delegate
408

409
        void runtime::horizon_reached(const task_id horizon_tid) {
839✔
410
                assert(m_task_mngr != nullptr);
839✔
411
                m_task_mngr->notify_horizon_reached(horizon_tid); // thread-safe
839✔
412

413
                // The two-horizon logic is duplicated from task_manager::notify_horizon_reached. TODO move epoch_monitor from task_manager to runtime.
414
                assert(m_schdlr != nullptr);
839✔
415
                if(m_latest_horizon_reached.has_value()) { m_schdlr->notify_epoch_reached(*m_latest_horizon_reached); }
839✔
416
                m_latest_horizon_reached = horizon_tid;
839✔
417
        }
839✔
418

419
        void runtime::epoch_reached(const task_id epoch_tid) {
565✔
420
                assert(m_task_mngr != nullptr);
565✔
421
                m_task_mngr->notify_epoch_reached(epoch_tid); // thread-safe
565✔
422

423
                assert(m_schdlr != nullptr);
565✔
424
                m_schdlr->notify_epoch_reached(epoch_tid);
565✔
425
                m_latest_horizon_reached = std::nullopt; // Any non-applied horizon is now behind the epoch and will therefore never become an epoch itself
565✔
426
        }
565✔
427

428
        void runtime::create_queue() {
223✔
429
                require_call_from_application_thread();
223✔
430
                ++m_num_live_queues;
222✔
431
        }
222✔
432

433
        void runtime::destroy_queue() {
223✔
434
                require_call_from_application_thread();
223✔
435

436
                assert(m_num_live_queues > 0);
222✔
437
                --m_num_live_queues;
222✔
438
        }
222✔
439

440
        allocation_id runtime::create_user_allocation(void* const ptr) {
109✔
441
                require_call_from_application_thread();
109✔
442
                const auto aid = allocation_id(user_memory_id, m_next_user_allocation_id++);
108✔
443
                m_exec->track_user_allocation(aid, ptr);
108✔
444
                return aid;
108✔
445
        }
446

447
        buffer_id runtime::create_buffer(const range<3>& range, const size_t elem_size, const size_t elem_align, const allocation_id user_aid) {
341✔
448
                require_call_from_application_thread();
341✔
449

450
                const auto bid = m_next_buffer_id++;
340✔
451
                m_live_buffers.emplace(bid);
340✔
452
                m_task_mngr->notify_buffer_created(bid, range, user_aid != null_allocation_id);
340✔
453
                m_schdlr->notify_buffer_created(bid, range, elem_size, elem_align, user_aid);
340✔
454
                return bid;
680✔
455
        }
456

457
        void runtime::set_buffer_debug_name(const buffer_id bid, const std::string& debug_name) {
23✔
458
                require_call_from_application_thread();
23✔
459

460
                assert(utils::contains(m_live_buffers, bid));
23✔
461
                m_task_mngr->notify_buffer_debug_name_changed(bid, debug_name);
23✔
462
                m_schdlr->notify_buffer_debug_name_changed(bid, debug_name);
23✔
463
        }
23✔
464

465
        void runtime::destroy_buffer(const buffer_id bid) {
341✔
466
                require_call_from_application_thread();
341✔
467

468
                assert(utils::contains(m_live_buffers, bid));
340✔
469
                m_schdlr->notify_buffer_destroyed(bid);
340✔
470
                m_task_mngr->notify_buffer_destroyed(bid);
340✔
471
                m_live_buffers.erase(bid);
340✔
472
        }
340✔
473

474
        host_object_id runtime::create_host_object(std::unique_ptr<host_object_instance> instance) {
34✔
475
                require_call_from_application_thread();
34✔
476

477
                const auto hoid = m_next_host_object_id++;
33✔
478
                m_live_host_objects.emplace(hoid);
33✔
479
                const bool owns_instance = instance != nullptr;
33✔
480
                if(owns_instance) { m_exec->track_host_object_instance(hoid, std::move(instance)); }
33✔
481
                m_task_mngr->notify_host_object_created(hoid);
33✔
482
                m_schdlr->notify_host_object_created(hoid, owns_instance);
33✔
483
                return hoid;
66✔
484
        }
485

486
        void runtime::destroy_host_object(const host_object_id hoid) {
34✔
487
                require_call_from_application_thread();
34✔
488

489
                assert(utils::contains(m_live_host_objects, hoid));
33✔
490
                m_schdlr->notify_host_object_destroyed(hoid);
33✔
491
                m_task_mngr->notify_host_object_destroyed(hoid);
33✔
492
                m_live_host_objects.erase(hoid);
33✔
493
        }
33✔
494

495

496
        reduction_id runtime::create_reduction(std::unique_ptr<reducer> reducer) {
65✔
497
                require_call_from_application_thread();
65✔
498

499
                const auto rid = m_next_reduction_id++;
65✔
500
                m_exec->track_reducer(rid, std::move(reducer));
65✔
501
                return rid;
130✔
502
        }
503

504
        bool runtime::is_unreferenced() const { return m_num_live_queues == 0 && m_live_buffers.empty() && m_live_host_objects.empty(); }
228!
505

506
} // namespace detail
507
} // 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

© 2026 Coveralls, Inc