Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
comp_queue_impl.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Stanford University, NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef REALM_COMP_QUEUE_IMPL_H
19#define REALM_COMP_QUEUE_IMPL_H
20
21#include "realm/event.h"
22#include "realm/id.h"
23#include <realm/activemsg.h>
24#include "realm/event_impl.h"
25
26#include <vector>
27
28namespace Realm {
29
31 public:
32 CompQueueImpl() = default;
34
35 void init(ID _me, int _owner);
36
37 static ID make_id(const CompQueueImpl &dummy, int owner, ID::IDType index)
38 {
39 return ID::make_compqueue(owner, index);
40 }
41
42 void set_capacity(size_t _max_size, bool _resizable);
43 size_t get_capacity() const;
44 size_t get_pending_events() const;
45
46 void destroy(void);
47
48 void add_event(Event event, bool faultaware);
49 void add_event(Event event, EventImpl *ev_impl, bool faultaware);
50
53
54 size_t pop_events(Event *events, size_t max_to_pop);
55
57 int owner;
59
61 public:
62 void defer(CompQueueImpl *_cq, Event wait_on);
63 virtual void event_triggered(bool poisoned, TimeLimit work_until);
64 virtual void print(std::ostream &os) const;
65 virtual Event get_finish_event(void) const;
66
67 protected:
69 };
71
72 // used to track pending remote pop requests
74 public:
75 RemotePopRequest(Event *_events, size_t _capacity);
76
80 size_t count, capacity;
82 };
83
84 protected:
86 public:
87 virtual void event_triggered(bool poisoned, TimeLimit work_until);
88 virtual void print(std::ostream &os) const;
89 virtual Event get_finish_event(void) const;
90
95 };
96
97 void add_completed_event(Event event, CompQueueWaiter *waiter, TimeLimit work_until);
98
99 static const size_t CQWAITER_BATCH_SIZE = 16;
108
109 Mutex mutex; // protects everything below here
110
111 bool resizable = false;
112 size_t max_events = 0;
116
119 size_t cur_events = 0;
120
121 std::unique_ptr<Event[]> completed_events = nullptr;
122
126 std::vector<Event> remote_progress_events;
129 };
130}; // namespace Realm
131
132#endif // ifndef REALM_COMP_QUEUE_IMPL_H
Definition comp_queue_impl.h:100
CompQueueWaiterBatch * next_batch
Definition comp_queue_impl.h:106
CompQueueWaiterBatch(CompQueueImpl *cq, CompQueueWaiterBatch *_next)
CompQueueWaiter waiters[CQWAITER_BATCH_SIZE]
Definition comp_queue_impl.h:105
Definition comp_queue_impl.h:85
CompQueueImpl * cq
Definition comp_queue_impl.h:91
virtual void print(std::ostream &os) const
Event wait_on
Definition comp_queue_impl.h:92
CompQueueWaiter * next_free
Definition comp_queue_impl.h:94
virtual Event get_finish_event(void) const
virtual void event_triggered(bool poisoned, TimeLimit work_until)
bool faultaware
Definition comp_queue_impl.h:93
Definition comp_queue_impl.h:60
void defer(CompQueueImpl *_cq, Event wait_on)
virtual void event_triggered(bool poisoned, TimeLimit work_until)
virtual void print(std::ostream &os) const
virtual Event get_finish_event(void) const
CompQueueImpl * cq
Definition comp_queue_impl.h:68
Definition comp_queue_impl.h:73
Event * events
Definition comp_queue_impl.h:81
size_t capacity
Definition comp_queue_impl.h:80
Mutex::CondVar condvar
Definition comp_queue_impl.h:78
size_t count
Definition comp_queue_impl.h:80
bool completed
Definition comp_queue_impl.h:79
RemotePopRequest(Event *_events, size_t _capacity)
Mutex mutex
Definition comp_queue_impl.h:77
Definition comp_queue_impl.h:30
size_t pop_events(Event *events, size_t max_to_pop)
GenEventImpl * local_progress_event
Definition comp_queue_impl.h:124
atomic< size_t > pending_events
Definition comp_queue_impl.h:115
CompletionQueue me
Definition comp_queue_impl.h:56
atomic< CompQueueWaiter * > first_free_waiter
Definition comp_queue_impl.h:127
Event get_local_progress_event(void)
void add_event(Event event, bool faultaware)
atomic< size_t > rd_ptr
Definition comp_queue_impl.h:114
Mutex mutex
Definition comp_queue_impl.h:109
void add_remote_progress_event(Event event)
int owner
Definition comp_queue_impl.h:57
std::unique_ptr< Event[]> completed_events
Definition comp_queue_impl.h:121
void init(ID _me, int _owner)
atomic< size_t > consume_ptr
Definition comp_queue_impl.h:118
void set_capacity(size_t _max_size, bool _resizable)
atomic< size_t > wr_ptr
Definition comp_queue_impl.h:113
CompQueueImpl * next_free
Definition comp_queue_impl.h:58
std::vector< Event > remote_progress_events
Definition comp_queue_impl.h:126
CompQueueWaiterBatch * batches
Definition comp_queue_impl.h:128
atomic< size_t > commit_ptr
Definition comp_queue_impl.h:117
void add_completed_event(Event event, CompQueueWaiter *waiter, TimeLimit work_until)
bool resizable
Definition comp_queue_impl.h:111
EventImpl::gen_t local_progress_event_gen
Definition comp_queue_impl.h:125
size_t get_capacity() const
atomic< bool > has_progress_events
Definition comp_queue_impl.h:123
size_t get_pending_events() const
size_t max_events
Definition comp_queue_impl.h:112
static const size_t CQWAITER_BATCH_SIZE
Definition comp_queue_impl.h:99
size_t cur_events
Definition comp_queue_impl.h:119
void add_event(Event event, EventImpl *ev_impl, bool faultaware)
DeferredDestroy deferred_destroy
Definition comp_queue_impl.h:70
static ID make_id(const CompQueueImpl &dummy, int owner, ID::IDType index)
Definition comp_queue_impl.h:37
Definition event.h:338
Definition event_impl.h:85
unsigned gen_t
Definition event_impl.h:87
Definition event_impl.h:49
Definition event.h:50
Definition event_impl.h:198
Definition id.h:30
static ID make_compqueue(unsigned owner_node, unsigned cq_idx)
::realm_id_t IDType
Definition id.h:32
Definition timers.h:129
Definition mutex.h:325
Definition mutex.h:223
Definition atomics.h:31
Definition activemsg.h:38