Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
mem_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// Memory implementations for Realm
19
20#ifndef REALM_MEMORY_IMPL_H
21#define REALM_MEMORY_IMPL_H
22
23#include "realm/memory.h"
24#include "realm/id.h"
25#include "realm/network.h"
26
27#include "realm/activemsg.h"
28#include "realm/operation.h"
29#include "realm/profiling.h"
30#include "realm/sampling.h"
31
32#include "realm/event_impl.h"
33#include "realm/rsrv_impl.h"
34
35#include <filesystem>
36
37namespace Realm {
38
39 namespace Config {
40 // if true, Realm memories attempt to satisfy instance allocation requests
41 // on the basis of deferred instance destructions
43 }; // namespace Config
44
45 class RegionInstanceImpl;
46 class NetworkModule;
47 class NetworkSegment;
48 class ByteArray;
49
51 public:
53 {
54 MKIND_SYSMEM, // directly accessible from CPU
55 MKIND_GLOBAL, // accessible via GASnet (spread over all nodes)
56 MKIND_RDMA, // remote, but accessible via RDMA
57 MKIND_REMOTE, // not accessible
58
59 // defined even if REALM_USE_CUDA isn't
60 // TODO: make kinds more extensible
61 MKIND_GPUFB, // GPU framebuffer memory (accessible via cudaMemcpy)
62 MKIND_MANAGED, // memory that is coherent for both CPU and GPU
63
64 MKIND_ZEROCOPY, // CPU memory, pinned for GPU access
65 MKIND_DISK, // disk memory accessible by owner node
66 MKIND_FILE, // file memory accessible by owner node
67#ifdef REALM_USE_HDF5
68 MKIND_HDF, // HDF memory accessible by owner node
69#endif
70 };
71
72 MemoryImpl(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, MemoryKind _kind,
73 Memory::Kind _lowlevel_kind, NetworkSegment *_segment);
74
75 virtual ~MemoryImpl(void);
76
77 // looks up an instance based on ID - creates a proxy object for
78 // unknown IDs (metadata must be requested explicitly)
80
81 // adds a new instance to this memory, to be filled in by caller
83
84 // releases a deleted instance so that it can be reused
86
87 // attempt to allocate storage for the specified instance
97
99 std::vector<RegionInstanceImpl *> &new_insts)
100 {
101 assert(0);
102 }
103
104 // default implementation falls through (directly or indirectly) to
105 // allocate_storage_immediate - method need only be overridden by
106 // memories that support deferred allocation
108 bool need_alloc_result,
109 Event precondition);
110
111 // release storage associated with an instance - this falls through to
112 // release_storage_immediate similarly to the above
113 virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition);
114
115 // reuse storage associated with an instance
116 virtual AllocationResult
118 std::vector<RegionInstanceImpl *> &new_insts,
119 Event precondition);
120
121 // should only be called by RegionInstance::DeferredCreate or from
122 // allocate_storage_deferrable
124 bool need_alloc_result,
125 bool poisoned,
126 TimeLimit work_until) = 0;
127
128 // should only be called by RegionInstance::DeferredDestroy or from
129 // release_storage_deferrable
130 virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned,
131 TimeLimit work_until) = 0;
132
133 virtual AllocationResult
135 std::vector<RegionInstanceImpl *> &new_insts, bool poisoned,
136 TimeLimit work_until);
137
138 // helpers used by the above when an instance being allocated or released
139 // is using an external resource
141 size_t &inst_offset);
143
144 // for re-registration purposes, generate an ExternalInstanceResource *
145 // (if possible) for a given instance, or a subset of one
148 span<const FieldID> fields, bool read_only);
149
150 // TODO: try to rip these out?
151 virtual void get_bytes(off_t offset, void *dst, size_t size) = 0;
152 virtual void put_bytes(off_t offset, const void *src, size_t size) = 0;
153
154 virtual void *get_direct_ptr(off_t offset, size_t size) = 0;
155
156 virtual void *get_inst_ptr(RegionInstanceImpl *inst, off_t offset, size_t size);
157
158 // gets info related to rdma access from other nodes
159 const ByteArray *get_rdma_info(NetworkModule *network) const;
160
161 // rdma transfers need to use LocalAddress and RemoteAddress helper objects
162 // rather than raw pointers
163 virtual bool get_local_addr(off_t offset, LocalAddress &local_addr);
164 virtual bool get_remote_addr(off_t offset, RemoteAddress &remote_addr);
165
166 // gets the network segment info for potential registration
168
170
171 // A helper function to get the kind of a memory when we only have the memory ID
172 static Memory::Kind get_memory_kind(const RuntimeImpl *runtime_impl, Memory memory);
173
174 // A helper function to get the size of a memory when we only have the memory ID
175 static size_t get_memory_size(const RuntimeImpl *runtime_impl, Memory memory);
176
177 // TODO: lift into a helper superclass?
178 template <typename T>
180 template <typename T>
181 const T *find_module_specific() const;
182
184
185 RuntimeImpl *get_runtime_impl() const { return runtime_impl; }
186
188 std::vector<RegionInstanceImpl *> instances;
189 std::vector<size_t> free_list;
191 };
192
193 public:
195 size_t size{0};
197 Memory::Kind lowlevel_kind{Memory::Kind::NO_MEMKIND};
198 NetworkSegment *segment{nullptr};
199 ModuleSpecificInfo *module_specific{nullptr};
200
201 // we keep a dedicated instance list for locally created
202 // instances, but we use a map indexed by creator node for others,
203 // and protect lookups in it with its own mutex
204 std::map<NodeID, InstanceList *> instances_by_creator;
207
208 protected:
209 RuntimeImpl *runtime_impl{nullptr};
210 };
211
213 public:
215 virtual ~MemSpecificInfo() {}
216
218 };
219
221 public:
222 PendingIBRequests(NodeID _sender, uintptr_t _req_op, unsigned _count,
223 unsigned _first_req, unsigned _current_req);
224 PendingIBRequests(NodeID _sender, uintptr_t _req_op, unsigned _count,
225 unsigned _first_req, unsigned _current_req, const Memory *_memories,
226 const size_t *_sizes, const off_t *_offsets);
227
230 uintptr_t req_op;
231 unsigned count;
232 unsigned first_req;
233 unsigned current_req;
234 std::vector<Memory> memories;
235 std::vector<size_t> sizes;
236 std::vector<off_t> offsets;
237 };
238
239 // manages a basic free list of ranges (using range type RT) and allocated
240 // ranges, which are tagged (tag type TT)
241 // NOT thread-safe - must be protected from outside
242 template <typename RT, typename TT>
244 public:
245 struct Range {
246 // Range(RT _first, RT _last);
247
248 RT first, last; // half-open range: [first, last)
249 unsigned prev, next; // double-linked list of all ranges (by index)
250 unsigned prev_free, next_free; // double-linked list of just free ranges
251 };
252
253 std::map<TT, unsigned> allocated; // direct lookup of allocated ranges by tag
254#ifdef DEBUG_REALM
255 std::map<RT, unsigned> by_first; // direct lookup of all ranges by first
256 // TODO: sized-based lookup of free ranges
257#endif
258
259 static const unsigned SENTINEL = 0;
260 // TODO: small (medium?) vector opt
261 std::vector<Range> ranges;
262
265
269 BasicRangeAllocator &operator=(BasicRangeAllocator &&) noexcept = default;
270
271 void swap(BasicRangeAllocator<RT, TT> &swap_with);
272
273 void add_range(RT first, RT last);
274 bool can_allocate(TT tag, RT size, RT alignment);
275 bool allocate(TT tag, RT size, RT alignment, RT &first);
276 void deallocate(TT tag, bool missing_ok = false);
277
278 bool lookup(TT tag, RT &first, RT &size);
279 size_t split_range(TT old_tag, const std::vector<TT> &new_tags,
280 const std::vector<RT> &sizes, const std::vector<RT> &alignment,
281 std::vector<RT> &allocs_first, bool missing_ok = false);
282
283 // TODO(apryakhin@): consider ifdefing for debug builds only
293
294 protected:
296 unsigned alloc_range(RT first, RT last);
297 void deallocate(unsigned del_idx);
298 void free_range(unsigned index);
299 };
300
301 // An alternative memory allocator that keeps track of free ranges grouped
302 // by sizes, these free lists can optionally be kept in sorted order
303 template <typename RT, typename TT, bool SORTED>
305 public:
308
312 SizedRangeAllocator &operator=(SizedRangeAllocator &&) noexcept = default;
313
314 void swap(SizedRangeAllocator<RT, TT, SORTED> &swap_with);
315
316 void add_range(RT first, RT last);
317 bool can_allocate(TT tag, RT size, RT alignment);
318 bool allocate(TT tag, RT size, RT alignment, RT &first);
319 void deallocate(TT tag, bool missing_ok = false);
320 size_t split_range(TT old_tag, const std::vector<TT> &new_tags,
321 const std::vector<RT> &sizes, const std::vector<RT> &alignment,
322 std::vector<RT> &allocs_first, bool missing_ok = false);
323
324 static constexpr unsigned SENTINEL = BasicRangeAllocator<RT, TT>::SENTINEL;
325 using Range = typename BasicRangeAllocator<RT, TT>::Range;
326 void add_to_free_list(unsigned index, Range &range);
327 void remove_from_free_list(unsigned index, Range &range);
328 void grow_hole(unsigned index, Range &range, RT bound, bool before);
329
331
332 static unsigned floor_log2(uint64_t size);
333
334 protected:
335 // Free lists associated with a specific sizes by powers of 2
336 // entry[0] = sizes from [2^0,2^1)
337 // entry[1] = sizes from [2^1,2^2)
338 // entry[2] = sizes from [2^2,2^3)
339 // ...
340 std::vector<unsigned> size_based_free_lists;
341 };
342
343 // a memory that manages its own allocations
345 public:
346 LocalManagedMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size,
347 MemoryKind _kind, size_t _alignment, Memory::Kind _lowlevel_kind,
348 NetworkSegment *_segment);
349
350 virtual ~LocalManagedMemory(void);
351
353 bool need_alloc_result,
354 Event precondition);
355
356 virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition);
357
358 virtual AllocationResult
360 std::vector<RegionInstanceImpl *> &new_insts,
361 Event precondition);
362
364 bool need_alloc_result,
365 bool poisoned,
366 TimeLimit work_until);
367
368 virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned,
369 TimeLimit work_until);
370
371 virtual AllocationResult
373 std::vector<RegionInstanceImpl *> &new_insts, bool poisoned,
374 TimeLimit work_until);
375
376 protected:
377 // for internal use by allocation routines - must be called with
378 // allocator_mutex held!
380 size_t alignment, size_t &inst_offset);
381
382 // attempts to satisfy pending allocations based on reordering releases to
383 // move the ready ones first - assumes 'release_allocator' has been
384 // properly maintained
386 std::vector<std::pair<RegionInstanceImpl *, size_t>> &successful_allocs);
387
389 std::vector<RegionInstanceImpl *> &failed_allocs);
390
391 public:
392 size_t alignment;
393
395 // we keep up to three heap states:
396 // current: always valid - tracks all completed allocations and all
397 // releases that can be applied without risking deadlock
398 // future: valid if pending_allocs exist - tracks heap state including
399 // all pending allocs and releases
400 // release: valid if pending_allocs exist - models heap state with
401 // completed allocations and any ready releases
402
403 // Pick which kind of range allocator we want to use
405 // using RangeAllocator = SizedRangeAllocator<size_t, RegionInstance, false>;
406
407 RangeAllocator current_allocator, future_allocator, release_allocator;
411 size_t bytes, alignment;
413 PendingAlloc(RegionInstanceImpl *_inst, size_t _bytes, size_t _align,
414 unsigned _release_seqid);
415 };
418 std::vector<RegionInstance> redistrict_tags;
419 std::vector<size_t> redistrict_sizes;
420 std::vector<size_t> redistrict_alignments;
422 unsigned seqid;
423
424 PendingRelease(RegionInstanceImpl *_inst, bool _ready, unsigned _seqid);
425 void record_redistrict(const std::vector<RegionInstanceImpl *> &insts);
426 void release(RangeAllocator &allocator, bool missing_ok = false);
427 size_t release(RangeAllocator &allocator, std::vector<size_t> &offsets,
428 bool missing_ok = false);
429 };
430 std::deque<PendingAlloc> pending_allocs;
431 std::deque<PendingRelease> pending_releases;
433 };
434
436 public:
437 static const size_t ALIGNMENT = 256;
438
439 LocalCPUMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, int numa_node,
440 Memory::Kind _lowlevel_kind, void *prealloc_base = 0,
441 NetworkSegment *_segment = 0, bool enable_ipc = true);
442
443 virtual ~LocalCPUMemory(void);
444
445 // LocalCPUMemory supports ExternalMemoryResource
447 size_t &inst_offset);
449
450 // for re-registration purposes, generate an ExternalInstanceResource *
451 // (if possible) for a given instance, or a subset of one
454 span<const FieldID> fields, bool read_only);
455
456 virtual void get_bytes(off_t offset, void *dst, size_t size);
457 virtual void put_bytes(off_t offset, const void *src, size_t size);
458 virtual void *get_direct_ptr(off_t offset, size_t size);
459
460 public:
461 const int numa_node;
462
463 public: // protected:
464 char *base, *base_orig;
467 };
468
470 public:
471 static const size_t ALIGNMENT = 256;
472
473 DiskMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size,
474 const std::filesystem::path &_file);
475
476 virtual ~DiskMemory(void);
477
478 virtual void get_bytes(off_t offset, void *dst, size_t size);
479
480 virtual void put_bytes(off_t offset, const void *src, size_t size);
481
482 virtual void *get_direct_ptr(off_t offset, size_t size);
483
486 span<const FieldID> fields, bool read_only);
487
489 size_t &inst_offset);
491
492 public:
493 int fd; // file descriptor
494 std::filesystem::path file; // file name
495 };
496
497 class FileMemory : public MemoryImpl {
498 public:
499 FileMemory(RuntimeImpl *_runtime_impl, Memory _me);
500
501 virtual ~FileMemory(void);
502
503 virtual void get_bytes(off_t offset, void *dst, size_t size);
504 void get_bytes(ID::IDType inst_id, off_t offset, void *dst, size_t size);
505
506 virtual void put_bytes(off_t offset, const void *src, size_t size);
507 void put_bytes(ID::IDType inst_id, off_t offset, const void *src, size_t size);
508 virtual void *get_direct_ptr(off_t offset, size_t size);
509
512 span<const FieldID> fields, bool read_only);
513
515 bool need_alloc_result,
516 bool poisoned,
517 TimeLimit work_until);
518
519 virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned,
520 TimeLimit work_until);
521
522 // FileMemory supports ExternalFileResource
524 size_t &inst_offset);
526
527 // the 'mem_specific' data for a file instance contains OpenFileInfo
529 public:
530 int fd;
531 size_t offset;
532 };
533 };
534
536 public:
537 RemoteMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, Memory::Kind k,
538 MemoryKind mk = MKIND_REMOTE);
539 virtual ~RemoteMemory(void);
540
542 bool need_alloc_result,
543 Event precondition);
544
545 virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition);
546
547 virtual AllocationResult
549 std::vector<RegionInstanceImpl *> &new_insts,
550 Event precondition);
551
553 bool need_alloc_result,
554 bool poisoned,
555 TimeLimit work_until);
556
557 virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned,
558 TimeLimit work_until);
559
560 virtual AllocationResult
562 std::vector<RegionInstanceImpl *> &new_insts, bool poisoned,
563 TimeLimit work_until);
564
565 // these are disallowed on a remote memory
566 virtual off_t alloc_bytes_local(size_t size);
567 virtual void free_bytes_local(off_t offset, size_t size);
568
569 virtual void get_bytes(off_t offset, void *dst, size_t size);
570 virtual void put_bytes(off_t offset, const void *src, size_t size);
571 virtual void *get_direct_ptr(off_t offset, size_t size);
572
573 private:
574 // For mapped remote memory, this is non-null
575 void *base;
576 };
577
578 // active messages
579
585
586 static void handle_message(NodeID sender, const MemStorageAllocRequest &msg,
587 const void *data, size_t datalen);
588 };
589
592 size_t offset;
594
595 static void handle_message(NodeID sender, const MemStorageAllocResponse &msg,
596 const void *data, size_t datalen, TimeLimit work_until);
597 };
598
603
604 static void handle_message(NodeID sender, const MemStorageReleaseRequest &msg,
605 const void *data, size_t datalen);
606 };
607
610
611 static void handle_message(NodeID sender, const MemStorageReleaseResponse &msg,
612 const void *data, size_t datalen);
613 };
614
619 std::string get_shm_name(realm_id_t id);
620
621}; // namespace Realm
622
623#endif // ifndef REALM_MEM_IMPL_H
624
625#include "realm/mem_impl.inl"
Definition mem_impl.h:243
void deallocate(unsigned del_idx)
bool allocate(TT tag, RT size, RT alignment, RT &first)
void deallocate(TT tag, bool missing_ok=false)
bool can_allocate(TT tag, RT size, RT alignment)
void swap(BasicRangeAllocator< RT, TT > &swap_with)
unsigned alloc_range(RT first, RT last)
unsigned first_free_range
Definition mem_impl.h:295
void add_range(RT first, RT last)
static const unsigned SENTINEL
Definition mem_impl.h:259
void free_range(unsigned index)
BasicRangeAllocator(const BasicRangeAllocator &)=default
std::map< TT, unsigned > allocated
Definition mem_impl.h:253
std::vector< Range > ranges
Definition mem_impl.h:261
MemoryStats get_allocator_stats()
bool lookup(TT tag, RT &first, RT &size)
BasicRangeAllocator & operator=(const BasicRangeAllocator &)=default
size_t split_range(TT old_tag, const std::vector< TT > &new_tags, const std::vector< RT > &sizes, const std::vector< RT > &alignment, std::vector< RT > &allocs_first, bool missing_ok=false)
BasicRangeAllocator(BasicRangeAllocator &&) noexcept=default
Definition bytearray.h:53
Definition mem_impl.h:469
virtual void unregister_external_resource(RegionInstanceImpl *inst)
int fd
Definition mem_impl.h:493
virtual bool attempt_register_external_resource(RegionInstanceImpl *inst, size_t &inst_offset)
std::filesystem::path file
Definition mem_impl.h:494
virtual ~DiskMemory(void)
virtual void * get_direct_ptr(off_t offset, size_t size)
virtual ExternalInstanceResource * generate_resource_info(RegionInstanceImpl *inst, const IndexSpaceGeneric *subspace, span< const FieldID > fields, bool read_only)
virtual void put_bytes(off_t offset, const void *src, size_t size)
virtual void get_bytes(off_t offset, void *dst, size_t size)
DiskMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, const std::filesystem::path &_file)
Definition event.h:50
Definition instance.h:405
Definition mem_impl.h:528
int fd
Definition mem_impl.h:530
size_t offset
Definition mem_impl.h:531
Definition mem_impl.h:497
virtual ~FileMemory(void)
virtual void * get_direct_ptr(off_t offset, size_t size)
virtual void unregister_external_resource(RegionInstanceImpl *inst)
virtual AllocationResult allocate_storage_immediate(RegionInstanceImpl *inst, bool need_alloc_result, bool poisoned, TimeLimit work_until)
virtual ExternalInstanceResource * generate_resource_info(RegionInstanceImpl *inst, const IndexSpaceGeneric *subspace, span< const FieldID > fields, bool read_only)
virtual void get_bytes(off_t offset, void *dst, size_t size)
FileMemory(RuntimeImpl *_runtime_impl, Memory _me)
void get_bytes(ID::IDType inst_id, off_t offset, void *dst, size_t size)
virtual bool attempt_register_external_resource(RegionInstanceImpl *inst, size_t &inst_offset)
void put_bytes(ID::IDType inst_id, off_t offset, const void *src, size_t size)
virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned, TimeLimit work_until)
virtual void put_bytes(off_t offset, const void *src, size_t size)
Definition id.h:30
::realm_id_t IDType
Definition id.h:32
Definition indexspace.h:1115
Definition mem_impl.h:435
LocalCPUMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, int numa_node, Memory::Kind _lowlevel_kind, void *prealloc_base=0, NetworkSegment *_segment=0, bool enable_ipc=true)
virtual void unregister_external_resource(RegionInstanceImpl *inst)
const int numa_node
Definition mem_impl.h:461
virtual bool attempt_register_external_resource(RegionInstanceImpl *inst, size_t &inst_offset)
NetworkSegment local_segment
Definition mem_impl.h:466
virtual void put_bytes(off_t offset, const void *src, size_t size)
virtual ~LocalCPUMemory(void)
virtual void get_bytes(off_t offset, void *dst, size_t size)
virtual void * get_direct_ptr(off_t offset, size_t size)
bool prealloced
Definition mem_impl.h:465
virtual ExternalInstanceResource * generate_resource_info(RegionInstanceImpl *inst, const IndexSpaceGeneric *subspace, span< const FieldID > fields, bool read_only)
char * base
Definition mem_impl.h:464
Definition mem_impl.h:344
virtual AllocationResult allocate_storage_deferrable(RegionInstanceImpl *inst, bool need_alloc_result, Event precondition)
virtual AllocationResult reuse_storage_immediate(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, bool poisoned, TimeLimit work_until)
size_t alignment
Definition mem_impl.h:392
unsigned cur_release_seqid
Definition mem_impl.h:408
virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned, TimeLimit work_until)
void remove_pending_release(RegionInstanceImpl *inst, std::vector< RegionInstanceImpl * > &failed_allocs)
ProfilingGauges::AbsoluteGauge< size_t > peak_footprint
Definition mem_impl.h:432
std::deque< PendingRelease > pending_releases
Definition mem_impl.h:431
bool attempt_release_reordering(std::vector< std::pair< RegionInstanceImpl *, size_t > > &successful_allocs)
virtual AllocationResult allocate_storage_immediate(RegionInstanceImpl *inst, bool need_alloc_result, bool poisoned, TimeLimit work_until)
LocalManagedMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, MemoryKind _kind, size_t _alignment, Memory::Kind _lowlevel_kind, NetworkSegment *_segment)
virtual AllocationResult reuse_storage_deferrable(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, Event precondition)
virtual ~LocalManagedMemory(void)
AllocationResult attempt_deferrable_allocation(RegionInstanceImpl *inst, size_t bytes, size_t alignment, size_t &inst_offset)
Mutex allocator_mutex
Definition mem_impl.h:394
RangeAllocator current_allocator
Definition mem_impl.h:407
std::deque< PendingAlloc > pending_allocs
Definition mem_impl.h:430
virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition)
Definition mem_impl.h:212
MemSpecificInfo * next
Definition mem_impl.h:217
virtual ~MemSpecificInfo()
Definition mem_impl.h:215
Definition mem_impl.h:50
virtual AllocationResult reuse_storage_deferrable(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, Event precondition)
MemoryKind
Definition mem_impl.h:53
@ MKIND_DISK
Definition mem_impl.h:65
@ MKIND_REMOTE
Definition mem_impl.h:57
@ MKIND_GPUFB
Definition mem_impl.h:61
@ MKIND_MANAGED
Definition mem_impl.h:62
@ MKIND_FILE
Definition mem_impl.h:66
@ MKIND_RDMA
Definition mem_impl.h:56
@ MKIND_ZEROCOPY
Definition mem_impl.h:64
@ MKIND_GLOBAL
Definition mem_impl.h:55
@ MKIND_SYSMEM
Definition mem_impl.h:54
virtual void * get_direct_ptr(off_t offset, size_t size)=0
const T * find_module_specific() const
virtual void get_bytes(off_t offset, void *dst, size_t size)=0
void add_module_specific(ModuleSpecificInfo *info)
virtual ~MemoryImpl(void)
virtual void unregister_external_resource(RegionInstanceImpl *inst)
T * find_module_specific()
AllocationResult
Definition mem_impl.h:89
@ ALLOC_EVENTUAL_FAILURE
Definition mem_impl.h:94
@ ALLOC_EVENTUAL_SUCCESS
Definition mem_impl.h:93
@ ALLOC_DEFERRED
Definition mem_impl.h:92
@ ALLOC_INSTANT_SUCCESS
Definition mem_impl.h:90
@ ALLOC_INSTANT_FAILURE
Definition mem_impl.h:91
RuntimeImpl * get_runtime_impl() const
Definition mem_impl.h:185
RegionInstanceImpl * get_instance(ID id)
Memory::Kind get_kind(void) const
virtual bool attempt_register_external_resource(RegionInstanceImpl *inst, size_t &inst_offset)
static size_t get_memory_size(const RuntimeImpl *runtime_impl, Memory memory)
const ByteArray * get_rdma_info(NetworkModule *network) const
virtual bool get_local_addr(off_t offset, LocalAddress &local_addr)
MemoryImpl(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, MemoryKind _kind, Memory::Kind _lowlevel_kind, NetworkSegment *_segment)
virtual AllocationResult allocate_storage_deferrable(RegionInstanceImpl *inst, bool need_alloc_result, Event precondition)
void release_instance(RegionInstance inst)
virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned, TimeLimit work_until)=0
MemoryKind kind
Definition mem_impl.h:196
std::map< NodeID, InstanceList * > instances_by_creator
Definition mem_impl.h:204
virtual ExternalInstanceResource * generate_resource_info(RegionInstanceImpl *inst, const IndexSpaceGeneric *subspace, span< const FieldID > fields, bool read_only)
static Memory::Kind get_memory_kind(const RuntimeImpl *runtime_impl, Memory memory)
NetworkSegment * get_network_segment()
Mutex instance_map_mutex
Definition mem_impl.h:205
virtual void put_bytes(off_t offset, const void *src, size_t size)=0
virtual void * get_inst_ptr(RegionInstanceImpl *inst, off_t offset, size_t size)
virtual void reuse_allocated_range(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts)
Definition mem_impl.h:98
virtual bool get_remote_addr(off_t offset, RemoteAddress &remote_addr)
RegionInstanceImpl * new_instance(const ProfilingRequestSet &prs)
InstanceList local_instances
Definition mem_impl.h:206
virtual AllocationResult allocate_storage_immediate(RegionInstanceImpl *inst, bool need_alloc_result, bool poisoned, TimeLimit work_until)=0
virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition)
virtual AllocationResult reuse_storage_immediate(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, bool poisoned, TimeLimit work_until)
Definition memory.h:33
Kind
Definition memory.h:59
Definition module.h:100
Definition network.h:144
Definition network.h:262
Definition mem_impl.h:220
PendingIBRequests * next_req
Definition mem_impl.h:228
NodeID sender
Definition mem_impl.h:229
PendingIBRequests(NodeID _sender, uintptr_t _req_op, unsigned _count, unsigned _first_req, unsigned _current_req, const Memory *_memories, const size_t *_sizes, const off_t *_offsets)
unsigned current_req
Definition mem_impl.h:233
std::vector< off_t > offsets
Definition mem_impl.h:236
std::vector< size_t > sizes
Definition mem_impl.h:235
PendingIBRequests(NodeID _sender, uintptr_t _req_op, unsigned _count, unsigned _first_req, unsigned _current_req)
unsigned count
Definition mem_impl.h:231
unsigned first_req
Definition mem_impl.h:232
std::vector< Memory > memories
Definition mem_impl.h:234
uintptr_t req_op
Definition mem_impl.h:230
Definition profiling.h:363
Definition mutex.h:398
Definition inst_impl.h:54
Definition instance.h:66
Definition mem_impl.h:535
virtual off_t alloc_bytes_local(size_t size)
virtual void release_storage_immediate(RegionInstanceImpl *inst, bool poisoned, TimeLimit work_until)
virtual ~RemoteMemory(void)
virtual void free_bytes_local(off_t offset, size_t size)
virtual AllocationResult allocate_storage_immediate(RegionInstanceImpl *inst, bool need_alloc_result, bool poisoned, TimeLimit work_until)
virtual AllocationResult reuse_storage_deferrable(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, Event precondition)
virtual void get_bytes(off_t offset, void *dst, size_t size)
virtual AllocationResult reuse_storage_immediate(RegionInstanceImpl *old_inst, std::vector< RegionInstanceImpl * > &new_insts, bool poisoned, TimeLimit work_until)
RemoteMemory(RuntimeImpl *_runtime_impl, Memory _me, size_t _size, Memory::Kind k, MemoryKind mk=MKIND_REMOTE)
virtual AllocationResult allocate_storage_deferrable(RegionInstanceImpl *inst, bool need_alloc_result, Event precondition)
virtual void * get_direct_ptr(off_t offset, size_t size)
virtual void release_storage_deferrable(RegionInstanceImpl *inst, Event precondition)
virtual void put_bytes(off_t offset, const void *src, size_t size)
Definition runtime_impl.h:264
Definition mem_impl.h:304
void swap(SizedRangeAllocator< RT, TT, SORTED > &swap_with)
BasicRangeAllocator< RT, TT >::MemoryStats get_allocator_stats()
static unsigned floor_log2(uint64_t size)
void deallocate(TT tag, bool missing_ok=false)
bool can_allocate(TT tag, RT size, RT alignment)
typename BasicRangeAllocator< RT, TT >::Range Range
Definition mem_impl.h:325
void add_range(RT first, RT last)
size_t split_range(TT old_tag, const std::vector< TT > &new_tags, const std::vector< RT > &sizes, const std::vector< RT > &alignment, std::vector< RT > &allocs_first, bool missing_ok=false)
void remove_from_free_list(unsigned index, Range &range)
std::vector< unsigned > size_based_free_lists
Definition mem_impl.h:340
void grow_hole(unsigned index, Range &range, RT bound, bool before)
void add_to_free_list(unsigned index, Range &range)
bool allocate(TT tag, RT size, RT alignment, RT &first)
SizedRangeAllocator(SizedRangeAllocator &&) noexcept=default
static constexpr unsigned SENTINEL
Definition mem_impl.h:324
SizedRangeAllocator & operator=(const SizedRangeAllocator &)=default
SizedRangeAllocator(const SizedRangeAllocator &)=default
Definition timers.h:129
Definition mutex.h:223
Definition utils.h:84
#define REALM_INTERNAL_API_EXTERNAL_LINKAGE
Definition compiler_support.h:218
bool deferred_instance_allocation
Definition activemsg.h:38
int NodeID
Definition nodeset.h:40
std::string get_shm_name(realm_id_t id)
Returns the full path for use in SharedMemoryInfo::create and SharedMemoryInfo::open given the realm ...
Definition indexspace.h:1279
unsigned long long realm_id_t
Definition realm_c.h:64
#define REALM_NO_MEM
Definition realm_c.h:166
size_t largest_free_blocksize
Definition mem_impl.h:288
size_t total_used_size
Definition mem_impl.h:287
size_t total_size
Definition mem_impl.h:285
size_t total_free_size
Definition mem_impl.h:286
Definition mem_impl.h:245
unsigned next
Definition mem_impl.h:249
unsigned prev_free
Definition mem_impl.h:250
unsigned prev
Definition mem_impl.h:249
RT last
Definition mem_impl.h:248
unsigned next_free
Definition mem_impl.h:250
RT first
Definition mem_impl.h:248
Definition network.h:58
size_t alignment
Definition mem_impl.h:411
PendingAlloc(RegionInstanceImpl *_inst, size_t _bytes, size_t _align, unsigned _release_seqid)
RegionInstanceImpl * inst
Definition mem_impl.h:410
unsigned last_release_seqid
Definition mem_impl.h:412
unsigned seqid
Definition mem_impl.h:422
std::vector< size_t > redistrict_alignments
Definition mem_impl.h:420
bool is_ready
Definition mem_impl.h:421
RegionInstanceImpl * inst
Definition mem_impl.h:417
size_t release(RangeAllocator &allocator, std::vector< size_t > &offsets, bool missing_ok=false)
void record_redistrict(const std::vector< RegionInstanceImpl * > &insts)
std::vector< RegionInstance > redistrict_tags
Definition mem_impl.h:418
PendingRelease(RegionInstanceImpl *_inst, bool _ready, unsigned _seqid)
std::vector< size_t > redistrict_sizes
Definition mem_impl.h:419
void release(RangeAllocator &allocator, bool missing_ok=false)
Definition mem_impl.h:580
bool need_alloc_result
Definition mem_impl.h:583
Memory memory
Definition mem_impl.h:581
RegionInstance inst
Definition mem_impl.h:582
Event precondition
Definition mem_impl.h:584
static void handle_message(NodeID sender, const MemStorageAllocRequest &msg, const void *data, size_t datalen)
Definition mem_impl.h:590
RegionInstance inst
Definition mem_impl.h:591
MemoryImpl::AllocationResult result
Definition mem_impl.h:593
static void handle_message(NodeID sender, const MemStorageAllocResponse &msg, const void *data, size_t datalen, TimeLimit work_until)
size_t offset
Definition mem_impl.h:592
Definition mem_impl.h:599
Event precondition
Definition mem_impl.h:602
static void handle_message(NodeID sender, const MemStorageReleaseRequest &msg, const void *data, size_t datalen)
Memory memory
Definition mem_impl.h:600
RegionInstance inst
Definition mem_impl.h:601
Definition mem_impl.h:608
static void handle_message(NodeID sender, const MemStorageReleaseResponse &msg, const void *data, size_t datalen)
RegionInstance inst
Definition mem_impl.h:609
Definition mem_impl.h:187
RWLock mutex
Definition mem_impl.h:190
std::vector< size_t > free_list
Definition mem_impl.h:189
std::vector< RegionInstanceImpl * > instances
Definition mem_impl.h:188
Definition network.h:46
NodeID src
Definition ucp_internal.h:1