Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
sparsity.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// sparsity maps for Realm
19
20// NOTE: SparsityMap's are not intended to be manipulated directly by Realm
21// applications (including higher-level runtimes), but they make heavy use of
22// templating and inlining for performance, so the headers are "reachable" from
23// the external parts of the Realm API
24
25#ifndef REALM_SPARSITY_H
26#define REALM_SPARSITY_H
27
28#include "realm/realm_config.h"
29#include "realm/event.h"
30#include "realm/atomics.h"
31
32#include <iostream>
33#include <vector>
34
41namespace Realm {
42
43 template <int N, typename T /*= int*/>
44 struct Point;
45 template <int N, typename T /*= int*/>
46 struct Rect;
47 template <int N, typename T = int>
49
50 template <int N, typename T>
52
64 template <int N, typename T>
66 public:
69 bool operator<(const SparsityMap<N, T> &rhs) const;
70 bool operator==(const SparsityMap<N, T> &rhs) const;
71 bool operator!=(const SparsityMap<N, T> &rhs) const;
72
73 // static const SparsityMap<N,T> NO_SPACE;
74
80 bool exists(void) const;
81
93 void destroy(Event wait_on = Event::NO_EVENT, unsigned count = 1);
94
104 Event add_reference(unsigned count = 1);
105
117 void remove_reference(unsigned count = 1, Event wait_on = Event::NO_EVENT);
118
125
127
138 static SparsityMap<N, T> construct(const std::vector<Point<N, T>> &points,
139 bool always_create, bool disjoint);
141 static SparsityMap<N, T> construct(const std::vector<Rect<N, T>> &rects,
142 bool always_create, bool disjoint);
144 };
145
146 template <int N, typename T>
147 REALM_PUBLIC_API std::ostream &operator<<(std::ostream &os, SparsityMap<N, T> s);
148
149 template <int N, typename T>
155
156 template <int N, typename T>
157 REALM_PUBLIC_API std::ostream &operator<<(std::ostream &os,
158 const SparsityMapEntry<N, T> &entry);
159
170 template <int N, typename T>
172 protected:
173 // cannot be constructed directly
175
176 public:
189 Event make_valid(bool precise = true);
190
197 bool is_valid(bool precise = true);
198
208 const std::vector<SparsityMapEntry<N, T>> &get_entries(void);
209
218 const std::vector<Rect<N, T>> &get_approx_rects(void);
219
232 bool approx);
233
244 bool compute_covering(const Rect<N, T> &bounds, size_t max_rects, int max_overhead,
245 std::vector<Rect<N, T>> &covering);
246
247 protected:
248 atomic<bool> entries_valid{false}, approx_valid{false};
249 std::vector<SparsityMapEntry<N, T>> entries;
250 std::vector<Rect<N, T>> approx_rects;
251 };
252
253}; // namespace Realm
254
255#include "realm/sparsity.inl"
256
257#endif // ifndef REALM_SPARSITY_H
Definition event.h:50
Definition sparsity.h:48
Definition sparsity.h:171
std::vector< Rect< N, T > > approx_rects
Definition sparsity.h:250
REALM_PUBLIC_API bool overlaps(SparsityMapPublicImpl< N, T > *other, const Rect< N, T > &bounds, bool approx)
REALM_PUBLIC_API const std::vector< Rect< N, T > > & get_approx_rects(void)
REALM_PUBLIC_API const std::vector< SparsityMapEntry< N, T > > & get_entries(void)
REALM_PUBLIC_API bool compute_covering(const Rect< N, T > &bounds, size_t max_rects, int max_overhead, std::vector< Rect< N, T > > &covering)
REALM_PUBLIC_API Event make_valid(bool precise=true)
REALM_PUBLIC_API bool is_valid(bool precise=true)
std::vector< SparsityMapEntry< N, T > > entries
Definition sparsity.h:249
Definition sparsity.h:65
::realm_id_t id_t
Definition sparsity.h:67
bool operator!=(const SparsityMap< N, T > &rhs) const
id_t id
Definition sparsity.h:68
REALM_INTERNAL_API_EXTERNAL_LINKAGE SparsityMapPublicImpl< N, T > * impl(void) const
static REALM_INTERNAL_API_EXTERNAL_LINKAGE SparsityMap< N, T > construct(const std::vector< Point< N, T > > &points, bool always_create, bool disjoint)
bool operator==(const SparsityMap< N, T > &rhs) const
static REALM_INTERNAL_API_EXTERNAL_LINKAGE SparsityMap< N, T > construct(const std::vector< Rect< N, T > > &rects, bool always_create, bool disjoint)
bool operator<(const SparsityMap< N, T > &rhs) const
void remove_reference(unsigned count=1, Event wait_on=Event::NO_EVENT)
REALM_CUDA_HD bool exists(void) const
Event add_reference(unsigned count=1)
void destroy(Event wait_on=Event::NO_EVENT, unsigned count=1)
Definition atomics.h:31
#define REALM_INTERNAL_API_EXTERNAL_LINKAGE
Definition compiler_support.h:218
#define REALM_CUDA_HD
Definition compiler_support.h:95
#define REALM_PUBLIC_API
Definition compiler_support.h:217
Realm::Point< N, T > Point
Definition prealm.h:539
Definition activemsg.h:38
std::ostream & operator<<(std::ostream &os, const DenseRectangleList< N, T > &drl)
unsigned long long realm_id_t
Definition realm_c.h:64
Definition point.h:55
Definition point.h:143
Definition sparsity.h:150
Rect< N, T > bounds
Definition sparsity.h:151
HierarchicalBitMap< N, T > * bitmap
Definition sparsity.h:153
SparsityMap< N, T > sparsity
Definition sparsity.h:152