From cb5795456afd64bae33480fd39ff8eb5326f22c1 Mon Sep 17 00:00:00 2001 From: Wei Wu Date: Thu, 6 Nov 2025 12:22:29 -0800 Subject: [PATCH 1/4] checkpoint --- src/realm/faults.cc | 5 +-- src/realm/fragmented_message.cc | 4 +-- src/realm/hardware_topology.cc | 16 +++++----- src/realm/idx_impl.cc | 12 ++++---- src/realm/indexspace.inl | 54 ++++++++++++++++----------------- src/realm/nodeset.cc | 34 ++++++++++----------- src/realm/nodeset.inl | 18 +++++------ src/realm/nvtx.cc | 4 +-- 8 files changed, 74 insertions(+), 73 deletions(-) diff --git a/src/realm/faults.cc b/src/realm/faults.cc index 7744a6eeb7e..38061f22aaa 100644 --- a/src/realm/faults.cc +++ b/src/realm/faults.cc @@ -147,7 +147,8 @@ namespace Realm { #else // allocate space for the result of backtrace(), including the stuff on // the front we're going to skip - assert(sizeof(void *) == sizeof(intptr_t)); + static_assert(sizeof(void *) == sizeof(intptr_t), + "void* and intptr_t must be the same size"); pcs.clear(); pcs.resize(max_depth + skip, 0); #ifdef REALM_ON_WINDOWS @@ -155,7 +156,7 @@ namespace Realm { #else int count = backtrace((void **)pcs.data(), max_depth + skip); #endif - assert(count >= 0); + REALM_ASSERT(count >= 0); if(count > skip) { pcs.erase(pcs.begin() + count, pcs.end()); diff --git a/src/realm/fragmented_message.cc b/src/realm/fragmented_message.cc index 4719824986e..33f24c63396 100644 --- a/src/realm/fragmented_message.cc +++ b/src/realm/fragmented_message.cc @@ -17,9 +17,9 @@ #include "realm/realm_config.h" #include "realm/fragmented_message.h" +#include "realm/logging.h" #include -#include namespace Realm { @@ -45,7 +45,7 @@ namespace Realm { bool FragmentedMessage::is_complete() const { - assert(received_count <= total_chunks); + REALM_ASSERT(received_count <= total_chunks); return received_count == total_chunks; } diff --git a/src/realm/hardware_topology.cc b/src/realm/hardware_topology.cc index b223d2abb19..380849c7535 100644 --- a/src/realm/hardware_topology.cc +++ b/src/realm/hardware_topology.cc @@ -203,7 +203,7 @@ namespace Realm { if(memory_size_kB > 0) { memories.emplace_back(HardwareTopology::MemoryInfo{ memory_size_kB << 10, static_cast(numa_node)}); - assert(static_cast(numa_node) == mem_node_id); + REALM_ASSERT(static_cast(numa_node) == mem_node_id); } } break; @@ -320,9 +320,9 @@ namespace Realm { return REALM_TOPOLOGY_ERROR_WIN32_NO_PROC_INFO; } proc_info = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)malloc(proc_info_size); - assert(proc_info != 0); + REALM_ASSERT(proc_info != 0); rc = GetLogicalProcessorInformation(proc_info, &proc_info_size); - assert(rc == TRUE); + REALM_ASSERT(rc == TRUE); // populate _all_procs map for(int i = 0; (i < sizeof(DWORD_PTR) * 8) && ((DWORD_PTR(1) << i) <= process_mask); @@ -539,13 +539,13 @@ namespace Realm { // system memory hwloc_obj_t root_obj = hwloc_get_root_obj(topo); - assert(root_obj != nullptr); + REALM_ASSERT(root_obj != nullptr); // cross check with numa memory size_t system_mem = 0; for(const HardwareTopology::MemoryInfo &memory : memories) { system_mem += memory.bytes; } - assert(system_mem == root_obj->total_memory); + REALM_ASSERT(system_mem == root_obj->total_memory); host_memory = root_obj->total_memory; return REALM_SUCCESS; @@ -758,8 +758,8 @@ namespace Realm { const std::vector &memories, const size_t host_memory) { - assert(logical_cores.size() > 0); - assert(memories.size() > 0); + REALM_ASSERT(logical_cores.size() > 0); + REALM_ASSERT(memories.size() > 0); // ------ Step 1: construct numa memory for(const MemoryInfo &memory : memories) { by_domain[memory.domain].memory_size = memory.bytes; @@ -898,7 +898,7 @@ namespace Realm { rr.push_back(x); } } - assert(pm.size() == all_procs.size()); + REALM_ASSERT(pm.size() == all_procs.size()); return pm; } diff --git a/src/realm/idx_impl.cc b/src/realm/idx_impl.cc index 1506aa576c6..90d5b094ca7 100644 --- a/src/realm/idx_impl.cc +++ b/src/realm/idx_impl.cc @@ -80,14 +80,14 @@ namespace Realm { template IndexSpaceGeneric::IndexSpaceGeneric(const IndexSpace ©_from) { - assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); + static_assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); impl = new(raw_storage) IndexSpaceGenericImplTyped(copy_from); } template IndexSpaceGeneric::IndexSpaceGeneric(const Rect ©_from) { - assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); + static_assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); impl = new(raw_storage) IndexSpaceGenericImplTyped(copy_from); } @@ -113,7 +113,7 @@ namespace Realm { template IndexSpaceGeneric &IndexSpaceGeneric::operator=(const IndexSpace ©_from) { - assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); + static_assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); if(impl) impl->~IndexSpaceGenericImpl(); impl = new(raw_storage) IndexSpaceGenericImplTyped(copy_from); @@ -123,7 +123,7 @@ namespace Realm { template IndexSpaceGeneric &IndexSpaceGeneric::operator=(const Rect ©_from) { - assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); + static_assert(STORAGE_BYTES >= sizeof(IndexSpaceGenericImplTyped)); if(impl) impl->~IndexSpaceGenericImpl(); impl = new(raw_storage) IndexSpaceGenericImplTyped(copy_from); @@ -137,7 +137,7 @@ namespace Realm { { IndexSpaceGenericImplTyped *typed = dynamic_cast *>(impl); - assert(typed != 0); + REALM_ASSERT(typed != 0); return typed->space; } @@ -199,7 +199,7 @@ namespace Realm { Event wait_on, int priority) const { // TODO: move to transfer.cc for indirection goodness - assert(indirect_len == 0); + REALM_ASSERT(indirect_len == 0); return space.copy(srcs, dsts, requests, wait_on, priority); } diff --git a/src/realm/indexspace.inl b/src/realm/indexspace.inl index d26b3f85fe4..84b8f2d5f5f 100644 --- a/src/realm/indexspace.inl +++ b/src/realm/indexspace.inl @@ -563,7 +563,7 @@ namespace Realm { static size_t bsearch_map_entries(const std::vector> &entries, const Point &p) { - assert(N == 1); + REALM_ASSERT(N == 1); // search range at any given time is [lo, hi) int lo = 0; int hi = entries.size(); @@ -607,10 +607,10 @@ namespace Realm { return false; if(e.sparsity.exists()) { - assert(0); + abort(); } if(e.bitmap != 0) { - assert(0); + abort(); } return true; } else { @@ -620,9 +620,9 @@ namespace Realm { if(!it->bounds.contains(p)) continue; if(it->sparsity.exists()) { - assert(0); + abort(); } else if(it->bitmap != 0) { - assert(0); + abort(); } else { return true; } @@ -651,9 +651,9 @@ namespace Realm { if(!it->bounds.overlaps(r)) continue; if(it->sparsity.exists()) { - assert(0); + abort(); } else if(it->bitmap != 0) { - assert(0); + abort(); } else { Rect isect = it->bounds.intersection(r); total_volume += isect.volume(); @@ -685,9 +685,9 @@ namespace Realm { if(!it->bounds.overlaps(r)) continue; if(it->sparsity.exists()) { - assert(0); + abort(); } else if(it->bitmap != 0) { - assert(0); + abort(); } else { return true; } @@ -738,9 +738,9 @@ namespace Realm { if(isect.empty()) continue; if(it->sparsity.exists()) { - assert(0); + abort(); } else if(it->bitmap != 0) { - assert(0); + abort(); } else { total += isect.volume(); } @@ -792,7 +792,7 @@ namespace Realm { if(it->contains(r)) return true; if(it->overlaps(r)) - assert(0); + abort(); } // no entries matched, so the point is definitely not contained in this space @@ -877,7 +877,7 @@ namespace Realm { srcs.resize(dsts.size()); size_t offset = 0; for(size_t i = 0; i < dsts.size(); i++) { - assert((offset + dsts[i].size) <= fill_value_size); + REALM_ASSERT((offset + dsts[i].size) <= fill_value_size); srcs[i].set_fill(reinterpret_cast(fill_value) + offset, dsts[i].size); // special case: if a field uses all of the fill value, the next // field (if any) is allowed to use the same value @@ -962,8 +962,8 @@ namespace Realm { // TODO(apryakhin): For now we just support building a general structured // transform from an affince transform. This will be extended later // to support more transform types. - assert(typeid(transform) == typeid(AffineTransform) || - typeid(transform) == typeid(TranslationTransform)); + REALM_ASSERT(typeid(transform) == typeid(AffineTransform) || + typeid(transform) == typeid(TranslationTransform)); return create_subspaces_by_image(DomainTransform(transform), sources, images, reqs, wait_on); } @@ -1057,8 +1057,8 @@ namespace Realm { // TODO(apryakhin): For now we just support building a general structured // transform from an affince transform. This will be extended later // to support more transform types. - assert(typeid(transform) == typeid(AffineTransform) || - typeid(transform) == typeid(TranslationTransform)); + REALM_ASSERT(typeid(transform) == typeid(AffineTransform) || + typeid(transform) == typeid(TranslationTransform)); return create_subspaces_by_preimage(DomainTransform(transform), targets, preimages, reqs, wait_on); } @@ -1314,7 +1314,7 @@ namespace Realm { template inline void IndexSpaceIterator::reset_sparse(SparsityMapPublicImpl *_s_impl) { - assert(_s_impl); + REALM_ASSERT(_s_impl); s_impl = _s_impl; rect = Rect::make_empty(); @@ -1329,8 +1329,8 @@ namespace Realm { const SparsityMapEntry &e = entries[cur_entry]; rect = restriction.intersection(e.bounds); if(!rect.empty()) { - assert(!e.sparsity.exists()); - assert(e.bitmap == 0); + REALM_ASSERT(!e.sparsity.exists()); + REALM_ASSERT(e.bitmap == 0); valid = true; return; } @@ -1344,7 +1344,7 @@ namespace Realm { template inline bool IndexSpaceIterator::step(void) { - assert(valid); // can't step an interator that's already done + REALM_ASSERT(valid); // can't step an interator that's already done // a dense space is covered in the first step if(!s_impl) { @@ -1369,8 +1369,8 @@ namespace Realm { continue; } - assert(!e.sparsity.exists()); - assert(e.bitmap == 0); + REALM_ASSERT(!e.sparsity.exists()); + REALM_ASSERT(e.bitmap == 0); return true; } @@ -1400,14 +1400,14 @@ namespace Realm { template inline LinearizedIndexSpace &LinearizedIndexSpaceIntfc::as_dim(void) { - assert((dim == N) && (idxtype == int(sizeof(T)))); + REALM_ASSERT((dim == N) && (idxtype == int(sizeof(T)))); return *static_cast *>(this); } template inline const LinearizedIndexSpace &LinearizedIndexSpaceIntfc::as_dim(void) const { - assert((dim == N) && (idxtype == int(sizeof(T)))); + REALM_ASSERT((dim == N) && (idxtype == int(sizeof(T)))); return *static_cast *>(this); } @@ -1450,7 +1450,7 @@ namespace Realm { s *= bounds.hi[i] - bounds.lo[i] + 1; } } - assert(s == ptrdiff_t(volume)); + REALM_ASSERT(s == ptrdiff_t(volume)); } else { offset = 0; for(int i = 0; i < N; i++) @@ -1476,7 +1476,7 @@ namespace Realm { size_t x = 0; for(int i = 0; i < N; i++) x += p[i] * strides[i]; - assert(x >= offset); + REALM_ASSERT(x >= offset); return x - offset; } diff --git a/src/realm/nodeset.cc b/src/realm/nodeset.cc index 3755a4f34ee..d132fbf4ad1 100644 --- a/src/realm/nodeset.cc +++ b/src/realm/nodeset.cc @@ -18,9 +18,9 @@ // dynamic node set implementation for Realm #include "realm/nodeset.h" +#include "realm/logging.h" #include -#include #ifdef REALM_ON_WINDOWS #include @@ -178,7 +178,7 @@ namespace Realm { // have to switch to a bitmask convert_to_bitmask(); count -= data.bitmask->clear_range(lo, hi); - assert(count > 0); // shouldn't clear everything + REALM_ASSERT(count > 0); // shouldn't clear everything return; } } else { @@ -218,7 +218,7 @@ namespace Realm { void NodeSet::convert_to_bitmask() { - assert(count > 0); + REALM_ASSERT(count > 0); NodeSetBitmask *newmask = NodeSetBitmask::acquire_bitmask(); switch(enc_format) { @@ -235,7 +235,7 @@ namespace Realm { break; } default: - assert(0); + abort(); } data.bitmask = newmask; enc_format = ENC_BITMASK; @@ -249,7 +249,7 @@ namespace Realm { { #ifdef DEBUG_REALM_NODESET for(size_t i = 0; i < (bitset_elements + bitset_twolevel); i++) - assert(bits[i] == 0); + REALM_ASSERT(bits[i] == 0); #endif } @@ -270,7 +270,7 @@ namespace Realm { void *raw_base = calloc(1 + (bitset_elements + bitset_twolevel) * bitsets_per_chunk, sizeof(bitmask_elem_t)); // printf("CALLOC = %p\n", raw_base); - assert(raw_base != 0); + REALM_ASSERT(raw_base != 0); bitmask_elem_t *chunk_base = reinterpret_cast(raw_base); // first bitset is one we'll use base = reinterpret_cast(&chunk_base[1]); @@ -311,7 +311,7 @@ namespace Realm { if(already_empty) { #ifdef DEBUG_REALM_NODESET for(size_t i = 0; i < (bitset_elements + bitset_twolevel); i++) - assert(bitmask->bits[i] == 0); + REALM_ASSERT(bitmask->bits[i] == 0); #endif } else { // clear things out so the next reuse starts fresh @@ -328,7 +328,7 @@ namespace Realm { size_t NodeSetBitmask::set_bit(NodeID id) { #ifdef DEBUG_REALM - assert((id >= 0) && (id <= max_node_id)); + REALM_ASSERT((id >= 0) && (id <= max_node_id)); #endif size_t elmt_idx = id / BITS_PER_ELEM; size_t elmt_ofs = id % BITS_PER_ELEM; @@ -345,7 +345,7 @@ namespace Realm { size_t NodeSetBitmask::clear_bit(NodeID id) { #ifdef DEBUG_REALM - assert((id >= 0) && (id <= max_node_id)); + REALM_ASSERT((id >= 0) && (id <= max_node_id)); #endif size_t elmt_idx = id / BITS_PER_ELEM; size_t elmt_ofs = id % BITS_PER_ELEM; @@ -362,7 +362,7 @@ namespace Realm { size_t NodeSetBitmask::set_range(NodeID lo, NodeID hi) { #ifdef DEBUG_REALM - assert((lo >= 0) && (hi <= max_node_id)); + REALM_ASSERT((lo >= 0) && (hi <= max_node_id)); #endif if(lo > hi) return 0; // empty range @@ -422,7 +422,7 @@ namespace Realm { size_t NodeSetBitmask::clear_range(NodeID lo, NodeID hi) { #ifdef DEBUG_REALM - assert((lo >= 0) && (hi <= max_node_id)); + REALM_ASSERT((lo >= 0) && (hi <= max_node_id)); #endif if(lo > hi) return 0; // empty range @@ -482,7 +482,7 @@ namespace Realm { bool NodeSetBitmask::is_set(NodeID id) const { #ifdef DEBUG_REALM - assert((id >= 0) && (id <= max_node_id)); + REALM_ASSERT((id >= 0) && (id <= max_node_id)); #endif size_t elmt_idx = id / BITS_PER_ELEM; size_t elmt_ofs = id % BITS_PER_ELEM; @@ -496,14 +496,14 @@ namespace Realm { if(bitset_twolevel) { int found = l2_find(0); #ifdef DEBUG_REALM - assert(found >= 0); + REALM_ASSERT(found >= 0); #endif elmt_idx = found; } else { while(bits[elmt_idx] == 0) { elmt_idx++; #ifdef DEBUG_REALM - assert(elmt_idx < bitset_elements); + REALM_ASSERT(elmt_idx < bitset_elements); #endif } } @@ -514,7 +514,7 @@ namespace Realm { NodeID NodeSetBitmask::next_set(NodeID after) const { #ifdef DEBUG_REALM - assert((after >= 0) && (after <= max_node_id)); + REALM_ASSERT((after >= 0) && (after <= max_node_id)); #endif if(after == max_node_id) return -1; @@ -531,7 +531,7 @@ namespace Realm { return -1; elmt_idx = found; #ifdef DEBUG_REALM - assert(bits[elmt_idx] != 0); + REALM_ASSERT(bits[elmt_idx] != 0); #endif elmt_ofs = ctz(bits[elmt_idx]); return (elmt_idx * BITS_PER_ELEM + elmt_ofs); @@ -602,7 +602,7 @@ namespace Realm { { // can't reconfigure with a different node count if(max_node_id != -1) { - assert(max_node_id == _max_node_id); + REALM_ASSERT(max_node_id == _max_node_id); return; } diff --git a/src/realm/nodeset.inl b/src/realm/nodeset.inl index 002babe94b0..724d5f824fb 100644 --- a/src/realm/nodeset.inl +++ b/src/realm/nodeset.inl @@ -105,7 +105,7 @@ namespace Realm { inline bool NodeSet::empty() const { #ifdef DEBUG_REALM_NODESET - assert((count == 0) == reference_set.empty()); + REALM_ASSERT((count == 0) == reference_set.empty()); #endif return (count == 0); } @@ -113,7 +113,7 @@ namespace Realm { inline size_t NodeSet::size() const { #ifdef DEBUG_REALM_NODESET - assert(count == reference_set.size()); + REALM_ASSERT(count == reference_set.size()); #endif return count; } @@ -307,7 +307,7 @@ namespace Realm { { if(count == 0) { #ifdef DEBUG_REALM_NODESET - assert(reference_set.count(id) == 0); + REALM_ASSERT(reference_set.count(id) == 0); #endif return false; } @@ -318,7 +318,7 @@ namespace Realm { for(short i = 0; i < short(count); i++) if(data.values[i] == id) { #ifdef DEBUG_REALM_NODESET - assert(reference_set.count(id) > 0); + REALM_ASSERT(reference_set.count(id) > 0); #endif return true; } @@ -330,7 +330,7 @@ namespace Realm { for(short i = 0; i < range_count; i++) if((data.ranges[i].lo <= id) && (id <= data.ranges[i].hi)) { #ifdef DEBUG_REALM_NODESET - assert(reference_set.count(id) > 0); + REALM_ASSERT(reference_set.count(id) > 0); #endif return true; } @@ -341,7 +341,7 @@ namespace Realm { { if(data.bitmask->is_set(id)) { #ifdef DEBUG_REALM_NODESET - assert(reference_set.count(id) > 0); + REALM_ASSERT(reference_set.count(id) > 0); #endif return true; } @@ -350,7 +350,7 @@ namespace Realm { } #ifdef DEBUG_REALM_NODESET - assert(reference_set.count(id) == 0); + REALM_ASSERT(reference_set.count(id) == 0); #endif return false; } @@ -421,7 +421,7 @@ namespace Realm { inline NodeID NodeSetIterator::operator*() const { #ifdef DEBUG_REALM_NODESET - assert(nodeset->reference_set.count(cur_node) > 0); + REALM_ASSERT(nodeset->reference_set.count(cur_node) > 0); #endif return cur_node; } @@ -429,7 +429,7 @@ namespace Realm { inline const NodeID *NodeSetIterator::operator->() const { #ifdef DEBUG_REALM_NODESET - assert(nodeset->reference_set.count(cur_node) > 0); + REALM_ASSERT(nodeset->reference_set.count(cur_node) > 0); #endif return &cur_node; } diff --git a/src/realm/nvtx.cc b/src/realm/nvtx.cc index d2bd4b51b21..a26b86bf8f6 100644 --- a/src/realm/nvtx.cc +++ b/src/realm/nvtx.cc @@ -16,8 +16,8 @@ */ #include "realm/nvtx.h" +#include "realm/logging.h" -#include #include #ifdef REALM_ON_WINDOWS #include @@ -168,7 +168,7 @@ namespace Realm { { std::map::iterator it; for(it = nvtx_categories->begin(); it != nvtx_categories->end(); it++) { - assert(it->second != nullptr); + REALM_ASSERT(it->second != nullptr); delete it->second; } delete nvtx_categories; From 8982931998b0b30cf5f53b31bcd0fa21e7c50d55 Mon Sep 17 00:00:00 2001 From: Wei Wu Date: Thu, 6 Nov 2025 14:15:41 -0800 Subject: [PATCH 2/4] checkpoint --- src/realm/interval_tree.inl | 8 +- src/realm/kokkos_interop.cc | 16 ++-- src/realm/lists.inl | 82 ++++++++++---------- src/realm/mem_impl.cc | 145 ++++++++++++++++++------------------ src/realm/mem_impl.h | 2 +- src/realm/mem_impl.inl | 50 +++++-------- src/realm/metadata.cc | 30 ++++---- src/realm/module.cc | 13 ++-- src/realm/module_config.cc | 2 +- src/realm/mutex.cc | 68 ++++++++--------- src/realm/mutex.inl | 18 ++--- src/realm/network.cc | 15 ++-- 12 files changed, 220 insertions(+), 229 deletions(-) diff --git a/src/realm/interval_tree.inl b/src/realm/interval_tree.inl index ef17b2c9a81..ead681b14fc 100644 --- a/src/realm/interval_tree.inl +++ b/src/realm/interval_tree.inl @@ -240,7 +240,7 @@ namespace Realm { int offset, int count, MARKER &marker) const { - assert(count > 0); + REALM_ASSERT(count > 0); #ifdef DEBUG_INTERVALS std::cout << "START " << count; @@ -430,20 +430,20 @@ namespace Realm { template inline void IntervalTree::remove_interval(IT iv_start, IT iv_end, LT iv_label) { - assert(0); + abort(); } template template inline void IntervalTree::remove_intervals(const IR &iv_ranges, LT iv_label) { - assert(0); + abort(); } template inline void IntervalTree::remove_by_label(LT iv_label) { - assert(0); + abort(); } template diff --git a/src/realm/kokkos_interop.cc b/src/realm/kokkos_interop.cc index a6e04524d80..2a8b8d7f927 100644 --- a/src/realm/kokkos_interop.cc +++ b/src/realm/kokkos_interop.cc @@ -164,8 +164,8 @@ namespace Realm { log_kokkos.info() << "doing cuda init on proc " << p; ProcessorImpl *impl = get_runtime()->get_processor_impl(p); - assert(impl != nullptr && "invalid processor handle"); - assert(impl->kind == Processor::TOC_PROC); + REALM_ASSERT(impl != nullptr); + REALM_ASSERT(impl->kind == Processor::TOC_PROC); Cuda::GPUProcessor *gpu = checked_cast(impl); #ifdef REALM_USE_KOKKOS_INITIALIZATION_SETTINGS @@ -220,8 +220,8 @@ namespace Realm { log_kokkos.info() << "doing hip init on proc " << p; ProcessorImpl *impl = get_runtime()->get_processor_impl(p); - assert(impl != nullptr && "invalid processor handle"); - assert(impl->kind == Processor::TOC_PROC); + REALM_ASSERT(impl != nullptr); + REALM_ASSERT(impl->kind == Processor::TOC_PROC); Hip::GPUProcessor *gpu = checked_cast(impl); #ifdef REALM_USE_KOKKOS_INITIALIZATION_SETTINGS @@ -453,8 +453,8 @@ namespace Realm { { #ifdef REALM_USE_CUDA ProcessorImpl *impl = get_runtime()->get_processor_impl(p); - assert(impl != nullptr && "invalid processor handle"); - assert(impl->kind == Processor::TOC_PROC); + REALM_ASSERT(impl != nullptr); + REALM_ASSERT(impl->kind == Processor::TOC_PROC); Cuda::GPUProcessor *gpu = checked_cast(impl); cudaStream_t stream = gpu->gpu->get_null_task_stream()->get_stream(); log_kokkos.info() << "handing back stream " << stream; @@ -489,8 +489,8 @@ namespace Realm { { #ifdef REALM_USE_HIP ProcessorImpl *impl = get_runtime()->get_processor_impl(p); - assert(impl != nullptr && "invalid processor handle"); - assert(impl->kind == Processor::TOC_PROC); + REALM_ASSERT(impl != nullptr); + REALM_ASSERT(impl->kind == Processor::TOC_PROC); Hip::GPUProcessor *gpu = checked_cast(impl); hipStream_t stream = gpu->gpu->get_null_task_stream()->get_stream(); log_kokkos.info() << "handing back stream " << stream; diff --git a/src/realm/lists.inl b/src/realm/lists.inl index 2f8fb5224ff..9f3391410ea 100644 --- a/src/realm/lists.inl +++ b/src/realm/lists.inl @@ -42,8 +42,8 @@ namespace Realm { { #ifdef DEBUG_REALM_LISTS // should not be deleted while in a list - assert(next == 0); - assert(current_list == 0); + REALM_ASSERT(next == 0); + REALM_ASSERT(current_list == 0); #endif } @@ -64,7 +64,7 @@ namespace Realm { #ifdef DEBUG_REALM_LISTS lock.lock(); // lists should be empty when deleted - assert(head.next == 0); + REALM_ASSERT(head.next == 0); #endif } @@ -74,7 +74,7 @@ namespace Realm { inline IntrusiveList::IntrusiveList( const IntrusiveList ©_from) { - assert(copy_from.empty()); + REALM_ASSERT(copy_from.empty()); head.next = 0; lastlink = &head; } @@ -83,8 +83,8 @@ namespace Realm { inline IntrusiveList & IntrusiveList::operator=(const IntrusiveList ©_from) { - assert(empty()); - assert(copy_from.empty()); + REALM_ASSERT(empty()); + REALM_ASSERT(copy_from.empty()); return *this; } @@ -105,11 +105,11 @@ namespace Realm { #ifdef DEBUG_REALM_LISTS // fix current_list references for(T *pos = head.next; pos; pos = REALM_PMTA_DEREF(pos, LINK).next) { - assert(REALM_PMTA_DEREF(pos, LINK).current_list == &swap_with); + REALM_ASSERT(REALM_PMTA_DEREF(pos, LINK).current_list == &swap_with); REALM_PMTA_DEREF(pos, LINK).current_list = this; } for(T *pos = swap_with.head.next; pos; pos = REALM_PMTA_DEREF(pos, LINK).next) { - assert(REALM_PMTA_DEREF(pos, LINK).current_list == this); + REALM_ASSERT(REALM_PMTA_DEREF(pos, LINK).current_list == this); REALM_PMTA_DEREF(pos, LINK).current_list = &swap_with; } #endif @@ -127,7 +127,7 @@ namespace Realm { take_from.lock.lock(); #ifdef DEBUG_REALM_LISTS for(T *pos = take_from.head.next; pos; pos = REALM_PMTA_DEREF(pos, LINK).next) { - assert(REALM_PMTA_DEREF(pos, LINK).current_list == &take_from); + REALM_ASSERT(REALM_PMTA_DEREF(pos, LINK).current_list == &take_from); REALM_PMTA_DEREF(pos, LINK).current_list = this; } #endif @@ -161,9 +161,9 @@ namespace Realm { { lock.lock(); #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); REALM_PMTA_DEREF(new_entry, LINK).current_list = this; - assert(REALM_PMTA_DEREF(new_entry, LINK).next == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next == 0); #endif lastlink->next = new_entry; lastlink = &REALM_PMTA_DEREF(new_entry, LINK); @@ -175,9 +175,9 @@ namespace Realm { { lock.lock(); #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); REALM_PMTA_DEREF(new_entry, LINK).current_list = this; - assert(REALM_PMTA_DEREF(new_entry, LINK).next == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next == 0); #endif REALM_PMTA_DEREF(new_entry, LINK).next = head.next; if(lastlink == &head) { @@ -202,7 +202,7 @@ namespace Realm { if(head.next) { popped = head.next; #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(popped, LINK).current_list == this); + REALM_ASSERT(REALM_PMTA_DEREF(popped, LINK).current_list == this); REALM_PMTA_DEREF(popped, LINK).current_list = 0; #endif head.next = REALM_PMTA_DEREF(popped, LINK).next; @@ -260,9 +260,9 @@ namespace Realm { { #ifdef DEBUG_REALM_LISTS // should not be deleted while in a list - assert(next_within_pri == 0); - assert(next_lower_pri == 0); - assert(current_list == 0); + REALM_ASSERT(next_within_pri == 0); + REALM_ASSERT(next_lower_pri == 0); + REALM_ASSERT(current_list == 0); #endif } @@ -285,7 +285,7 @@ namespace Realm { #ifdef DEBUG_REALM_LISTS lock.lock(); // list should be empty when deleted - assert(head == 0); + REALM_ASSERT(head == 0); #endif } @@ -298,7 +298,7 @@ namespace Realm { const IntrusivePriorityList ©_from) : head(0) { - assert(copy_from.head == 0); + REALM_ASSERT(copy_from.head == 0); } template ::operator=( const IntrusivePriorityList ©_from) { - assert(head == 0); - assert(copy_from.head == 0); + REALM_ASSERT(head == 0); + REALM_ASSERT(copy_from.head == 0); return *this; } @@ -322,7 +322,7 @@ namespace Realm { T *cur = nextp; nextp = REALM_PMTA_DEREF(nextp, LINK).next_lower_pri; while(cur != 0) { - assert(REALM_PMTA_DEREF(cur, LINK).current_list == from); + REALM_ASSERT(REALM_PMTA_DEREF(cur, LINK).current_list == from); REALM_PMTA_DEREF(cur, LINK).current_list = to; cur = REALM_PMTA_DEREF(cur, LINK).next_within_pri; } @@ -405,7 +405,7 @@ namespace Realm { take_from.head = 0; #ifdef DEBUG_REALM_LISTS size_t act_size = size(); - assert(exp_size == act_size); + REALM_ASSERT(exp_size == act_size); #endif take_from.lock.unlock(); lock.unlock(); @@ -420,9 +420,9 @@ namespace Realm { lock.lock(); #ifdef DEBUG_REALM_LISTS // entry being added should be unentangled - assert(REALM_PMTA_DEREF(new_entry, LINK).next_within_pri == 0); - assert(REALM_PMTA_DEREF(new_entry, LINK).lastlink_within_pri == 0); - assert(REALM_PMTA_DEREF(new_entry, LINK).next_lower_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next_within_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).lastlink_within_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next_lower_pri == 0); size_t exp_size = size() + 1; #endif // scan ahead to find right priority level to insert at @@ -447,10 +447,10 @@ namespace Realm { *curdst = new_entry; } #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); REALM_PMTA_DEREF(new_entry, LINK).current_list = this; size_t act_size = size(); - assert(exp_size == act_size); + REALM_ASSERT(exp_size == act_size); #endif lock.unlock(); } @@ -463,9 +463,9 @@ namespace Realm { lock.lock(); #ifdef DEBUG_REALM_LISTS // entry being added should be unentangled - assert(REALM_PMTA_DEREF(new_entry, LINK).next_within_pri == 0); - assert(REALM_PMTA_DEREF(new_entry, LINK).lastlink_within_pri == 0); - assert(REALM_PMTA_DEREF(new_entry, LINK).next_lower_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next_within_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).lastlink_within_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).next_lower_pri == 0); size_t exp_size = size() + 1; #endif // scan ahead to find right priority level to insert at @@ -495,10 +495,10 @@ namespace Realm { *curdst = new_entry; } #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); + REALM_ASSERT(REALM_PMTA_DEREF(new_entry, LINK).current_list == 0); REALM_PMTA_DEREF(new_entry, LINK).current_list = this; size_t act_size = size(); - assert(exp_size == act_size); + REALM_ASSERT(exp_size == act_size); #endif lock.unlock(); } @@ -568,7 +568,7 @@ namespace Realm { head = REALM_PMTA_DEREF(popped, LINK).next_lower_pri; } #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(popped, LINK).current_list == this); + REALM_ASSERT(REALM_PMTA_DEREF(popped, LINK).current_list == this); REALM_PMTA_DEREF(popped, LINK).current_list = 0; // clean up now-unused pointers to make debugging easier REALM_PMTA_DEREF(popped, LINK).next_within_pri = 0; @@ -578,7 +578,7 @@ namespace Realm { } #ifdef DEBUG_REALM_LISTS size_t act_size = size(); - assert(exp_size == act_size); + REALM_ASSERT(exp_size == act_size); #endif lock.unlock(); return popped; @@ -610,7 +610,7 @@ namespace Realm { head = REALM_PMTA_DEREF(popped, LINK).next_lower_pri; } #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(popped, LINK).current_list == this); + REALM_ASSERT(REALM_PMTA_DEREF(popped, LINK).current_list == this); REALM_PMTA_DEREF(popped, LINK).current_list = 0; // clean up now-unused pointers to make debugging easier REALM_PMTA_DEREF(popped, LINK).next_within_pri = 0; @@ -620,7 +620,7 @@ namespace Realm { } #ifdef DEBUG_REALM_LISTS size_t act_size = size(); - assert(exp_size == act_size); + REALM_ASSERT(exp_size == act_size); #endif lock.unlock(); return popped; @@ -661,14 +661,14 @@ namespace Realm { while(REALM_PMTA_DEREF(cur2, LINK).next_within_pri != 0) { cur2 = REALM_PMTA_DEREF(cur2, LINK).next_within_pri; #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(cur2, PRI) == REALM_PMTA_DEREF(cur, PRI)); - assert(REALM_PMTA_DEREF(cur2, LINK).lastlink_within_pri == 0); - assert(REALM_PMTA_DEREF(cur2, LINK).next_lower_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(cur2, PRI) == REALM_PMTA_DEREF(cur, PRI)); + REALM_ASSERT(REALM_PMTA_DEREF(cur2, LINK).lastlink_within_pri == 0); + REALM_ASSERT(REALM_PMTA_DEREF(cur2, LINK).next_lower_pri == 0); #endif count++; } #ifdef DEBUG_REALM_LISTS - assert(REALM_PMTA_DEREF(cur, LINK).lastlink_within_pri == + REALM_ASSERT(REALM_PMTA_DEREF(cur, LINK).lastlink_within_pri == &(REALM_PMTA_DEREF(cur2, LINK).next_within_pri)); #endif cur = REALM_PMTA_DEREF(cur, LINK).next_lower_pri; diff --git a/src/realm/mem_impl.cc b/src/realm/mem_impl.cc index 6ad4d64c5b2..ba3e34832f2 100644 --- a/src/realm/mem_impl.cc +++ b/src/realm/mem_impl.cc @@ -72,7 +72,7 @@ namespace Realm { void Memory::report_memory_fault(int reason, const void *reason_data, size_t reason_size) const { - assert(0); + abort(); } //////////////////////////////////////////////////////////////////////// @@ -132,7 +132,7 @@ namespace Realm { // all allocation requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); // check precondition on allocation bool alloc_poisoned = false; @@ -182,7 +182,7 @@ namespace Realm { // all allocation requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); bool poisoned = false; if(precondition.has_triggered_faultaware(poisoned)) { @@ -202,17 +202,17 @@ namespace Realm { // all reuse requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); // This better be an external instance - assert(old_inst->metadata.ext_resource); + REALM_ASSERT(old_inst->metadata.ext_resource); bool poisoned = false; if(precondition.has_triggered_faultaware(poisoned)) { // fall through to immediate storage release return reuse_storage_immediate(old_inst, new_insts, poisoned, TimeLimit::responsive()); } else { - assert(old_inst->deferred_redistrict.empty()); + REALM_ASSERT(old_inst->deferred_redistrict.empty()); old_inst->deferred_redistrict.swap(new_insts); // ask the instance to tell us when the precondition is satisified old_inst->deferred_destroy.defer(old_inst, this, precondition); @@ -226,7 +226,7 @@ namespace Realm { bool poisoned, TimeLimit work_until) { // Should only be here for external instances - assert(old_inst->metadata.ext_resource); + REALM_ASSERT(old_inst->metadata.ext_resource); // Swap the new instances into a local container because once we start notifying // the instances of their results, the DeferredDeletion object that invoked this // method could be reused right away @@ -246,7 +246,7 @@ namespace Realm { // automatic success - make the "offset" be the difference between the // base address we were given and our own allocation's base const uintptr_t mem_base = reinterpret_cast(get_direct_ptr(0, 0)); - assert(mem_base != 0); + REALM_ASSERT(mem_base != 0); // Figure out how many of the new instances we can allocate size_t bytes_used = 0; uintptr_t offset = res->base; @@ -273,7 +273,7 @@ namespace Realm { return ALLOC_INSTANT_FAILURE; } // Make sure all these instances are treated as external too - assert(!local_insts[idx]->metadata.ext_resource); + REALM_ASSERT(!local_insts[idx]->metadata.ext_resource); local_insts[idx]->metadata.ext_resource = res->clone(); // notify the successful allocation, adjust for mem_base // underflow is ok here - it'll work itself out when we add the mem_base @@ -322,13 +322,13 @@ namespace Realm { #if 0 off_t MemoryImpl::alloc_bytes_local(size_t size) { - assert(0); + abort(); return 0; } void MemoryImpl::free_bytes_local(off_t offset, size_t size) { - assert(0); + abort(); } // make bad offsets really obvious (+1 PB) @@ -400,7 +400,7 @@ namespace Realm { // frees of zero bytes should have the special offset if(size == 0) { - assert((size_t)offset == this->size + ZERO_SIZE_INSTANCE_OFFSET); + REALM_ASSERT((size_t)offset == this->size + ZERO_SIZE_INSTANCE_OFFSET); return; } @@ -423,7 +423,7 @@ namespace Realm { // found one - is it the first one? if(after == free_blocks.begin()) { // yes, so no "before" - assert((offset + (off_t)size) <= after->first); // no overlap! + REALM_ASSERT((offset + (off_t)size) <= after->first); // no overlap! if((offset + (off_t)size) == after->first) { // merge the ranges by eating the "after" size += after->second; @@ -435,7 +435,7 @@ namespace Realm { std::map::iterator before = after; before--; // if we're adjacent to the after, merge with it - assert((offset + (off_t)size) <= after->first); // no overlap! + REALM_ASSERT((offset + (off_t)size) <= after->first); // no overlap! if((offset + (off_t)size) == after->first) { // merge the ranges by eating the "after" size += after->second; @@ -444,7 +444,7 @@ namespace Realm { // if we're adjacent with the before, grow it instead of adding // a new range - assert((before->first + before->second) <= offset); + REALM_ASSERT((before->first + before->second) <= offset); if((before->first + before->second) == offset) { before->second += size; } else { @@ -459,7 +459,7 @@ namespace Realm { // if we're adjacent with the before, grow it instead of adding // a new range - assert((before->first + before->second) <= offset); + REALM_ASSERT((before->first + before->second) <= offset); if((before->first + before->second) == offset) { before->second += size; } else { @@ -477,7 +477,7 @@ namespace Realm { RegionInstanceImpl *MemoryImpl::get_instance(ID id) { - assert(id.is_instance()); + REALM_ASSERT(id.is_instance()); NodeID cnode = id.instance_creator_node(); unsigned idx = id.instance_inst_idx(); @@ -485,8 +485,8 @@ namespace Realm { // if it was locally created, we can directly access the local_instances list // and it's a fatal error if it doesn't exist RWLock::AutoReaderLock al(local_instances.mutex); - assert(idx < local_instances.instances.size()); - assert(local_instances.instances[idx] != 0); + REALM_ASSERT(idx < local_instances.instances.size()); + REALM_ASSERT(local_instances.instances[idx] != 0); return local_instances.instances[idx]; } else { // figure out which instance list to look in - non-local creators require a @@ -568,7 +568,7 @@ namespace Realm { if(!reported) { // fatal error log_inst.fatal() << "FATAL: instance count exceeded for memory " << me; - assert(0); + abort(); } return 0; } @@ -696,7 +696,7 @@ namespace Realm { // all allocation requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); // check precondition on allocation bool alloc_poisoned = false; @@ -769,7 +769,7 @@ namespace Realm { for(std::deque::iterator it = pending_releases.begin(); it != pending_releases.end(); ++it) { // shouldn't have any ready ones here - assert(!it->is_ready); + REALM_ASSERT(!it->is_ready); // due to network delays, it's possible for multiple // deallocations of the same instance to be in our list, // so ignore failures to deallocate from the future state @@ -813,7 +813,7 @@ namespace Realm { // all allocation requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); bool poisoned = false; bool triggered = precondition.has_triggered_faultaware(poisoned); @@ -841,7 +841,7 @@ namespace Realm { // "future release of it" - wait until the creation precondition is // satisfied if(inst->metadata.inst_offset == RegionInstanceImpl::INSTOFFSET_DELAYEDALLOC) { - assert(!triggered); + REALM_ASSERT(!triggered); inst->metadata.inst_offset = RegionInstanceImpl::INSTOFFSET_DELAYEDDESTROY; break; } @@ -917,7 +917,7 @@ namespace Realm { // all allocation requests are handled by the memory's owning node for // now - local caching might be possible though NodeID target = ID(me).memory_owner_node(); - assert(target == Network::my_node_id); + REALM_ASSERT(target == Network::my_node_id); if(old_inst->metadata.ext_resource) { return MemoryImpl::reuse_storage_deferrable(old_inst, new_insts, precondition); @@ -958,7 +958,7 @@ namespace Realm { // "future release of it" - wait until the creation precondition is // satisfied if(old_inst->metadata.inst_offset == RegionInstanceImpl::INSTOFFSET_DELAYEDALLOC) { - assert(!triggered); + REALM_ASSERT(!triggered); old_inst->metadata.inst_offset = RegionInstanceImpl::INSTOFFSET_DELAYEDREDISTRICT; break; } @@ -979,9 +979,9 @@ namespace Realm { #endif // Should never be a delayed destroy or a redistrict as that indicates // that we had a double deletion/redistrict - assert(old_inst->metadata.inst_offset != + REALM_ASSERT(old_inst->metadata.inst_offset != RegionInstanceImpl::INSTOFFSET_DELAYEDDESTROY); - assert(old_inst->metadata.inst_offset != + REALM_ASSERT(old_inst->metadata.inst_offset != RegionInstanceImpl::INSTOFFSET_DELAYEDREDISTRICT); if(pending_allocs.empty()) { @@ -1053,7 +1053,7 @@ namespace Realm { } return ALLOC_INSTANT_SUCCESS; } else { - assert(old_inst->deferred_redistrict.empty()); + REALM_ASSERT(old_inst->deferred_redistrict.empty()); old_inst->deferred_redistrict.swap(new_insts); old_inst->deferred_destroy.defer(old_inst, this, precondition); return ALLOC_DEFERRED; @@ -1074,7 +1074,7 @@ namespace Realm { // with the lock held, check the state of the instance to see if a // deferred destruction has also been received - if so, we'll have to // add that to the allocator history too - assert( + REALM_ASSERT( (inst->metadata.inst_offset == RegionInstanceImpl::INSTOFFSET_DELAYEDALLOC) || (inst->metadata.inst_offset == RegionInstanceImpl::INSTOFFSET_DELAYEDDESTROY) || (inst->metadata.inst_offset == @@ -1098,7 +1098,7 @@ namespace Realm { // automatic success - make the "offset" be the difference between the // base address we were given and our own allocation's base void *mem_base = get_direct_ptr(0, 0); // only our subclasses know this - assert(mem_base != 0); + REALM_ASSERT(mem_base != 0); // underflow is ok here - it'll work itself out when we add the mem_base // back in on accesses inst_offset = res->base - reinterpret_cast(mem_base); @@ -1129,7 +1129,7 @@ namespace Realm { } } if(deferred_redistrict_exists) { - assert(!inst->deferred_redistrict.empty()); + REALM_ASSERT(!inst->deferred_redistrict.empty()); PendingRelease &back = pending_releases.emplace_back( PendingRelease(inst, false /*!ready*/, ++cur_release_seqid)); back.record_redistrict(inst->deferred_redistrict); @@ -1205,7 +1205,7 @@ namespace Realm { break; } // should have gotten at least one - assert(a_now != pending_allocs.begin()); + REALM_ASSERT(a_now != pending_allocs.begin()); // did we get them all? if(a_now == pending_allocs.end()) { @@ -1327,7 +1327,7 @@ namespace Realm { // no future state to fix up remove_pending_release(old_inst, failed_allocs); } else { // not poisoned - assert(!pending_releases.empty()); + REALM_ASSERT(!pending_releases.empty()); std::deque::iterator it = pending_releases.begin(); // special case: if we're the oldest pending item (and we're not // poisoned), we unclog things in the order we planned @@ -1355,7 +1355,7 @@ namespace Realm { #ifdef DEBUG_REALM // but it should never be older than the current release - assert(it2->last_release_seqid >= it->seqid); + REALM_ASSERT(it2->last_release_seqid >= it->seqid); #endif // all older release are done, so this alloc had better work @@ -1363,24 +1363,24 @@ namespace Realm { size_t offset = 0; bool ok = current_allocator.allocate(it2->inst->me, it2->bytes, it2->alignment, offset); - assert(ok); + REALM_ASSERT(ok); #ifdef DEBUG_REALM // it should also be where we thought it was in the future // allocator state (unless it's already been future-deleted) size_t f_first, f_size; if(future_allocator.lookup(it2->inst->me, f_first, f_size)) { - assert((f_first == offset) && (f_size == it2->bytes)); + REALM_ASSERT((f_first == offset) && (f_size == it2->bytes)); } else { // find in future deletion list std::deque::const_iterator it3 = pending_releases.begin(); while(true) { // should not run off end of list - assert(it3 != pending_releases.end()); + REALM_ASSERT(it3 != pending_releases.end()); if(it3->inst != it2->inst) { ++it3; } else { // found it - make sure it's not already deleted - assert(!it3->is_ready); + REALM_ASSERT(!it3->is_ready); break; } } @@ -1415,7 +1415,7 @@ namespace Realm { // find this destruction in the list and mark it ready do { ++it; - assert(it != pending_releases.end()); // can't fall off end + REALM_ASSERT(it != pending_releases.end()); // can't fall off end } while(it->inst != old_inst); it->is_ready = true; @@ -1474,14 +1474,14 @@ namespace Realm { local_insts.swap(new_insts); if(poisoned) { for(unsigned idx = 0; idx < local_insts.size(); idx++) { - assert(offsets[idx] == RegionInstanceImpl::INSTOFFSET_FAILED); + REALM_ASSERT(offsets[idx] == RegionInstanceImpl::INSTOFFSET_FAILED); local_insts[idx]->notify_allocation(ALLOC_CANCELLED, offsets[idx], work_until); } return ALLOC_CANCELLED; } else { old_inst->notify_deallocation(); for(unsigned idx = 0; idx < local_insts.size(); idx++) { - assert((offsets[idx] != RegionInstanceImpl::INSTOFFSET_FAILED) == + REALM_ASSERT((offsets[idx] != RegionInstanceImpl::INSTOFFSET_FAILED) == (idx < allocated)); local_insts[idx]->notify_allocation((idx < allocated) ? ALLOC_EVENTUAL_SUCCESS : ALLOC_EVENTUAL_FAILURE, @@ -1495,7 +1495,7 @@ namespace Realm { RegionInstanceImpl *inst, std::vector &failed_allocs) { // this destruction should be somewhere in the pending ops list - assert(!pending_releases.empty()); + REALM_ASSERT(!pending_releases.empty()); std::deque::iterator it = pending_releases.begin(); // special case: if there are no pending allocation requests, we // just forget this destruction request ever happened - there is @@ -1503,7 +1503,7 @@ namespace Realm { if(pending_allocs.empty()) { while(it->inst != inst) { ++it; - assert(it != pending_releases.end()); // can't fall off end + REALM_ASSERT(it != pending_releases.end()); // can't fall off end } it = pending_releases.erase(it); @@ -1540,7 +1540,7 @@ namespace Realm { ++it2; } else { // this should only happen if we've seen the poisoned release - assert(found); + REALM_ASSERT(found); // this alloc is no longer possible - remove from the list // and notify of the failure @@ -1581,7 +1581,7 @@ namespace Realm { #endif if(!poisoned) { // this destruction should be somewhere in the pending ops list - assert(!pending_releases.empty()); + REALM_ASSERT(!pending_releases.empty()); std::deque::iterator it = pending_releases.begin(); // special case: if we're the oldest pending item (and we're not // poisoned), we unclog things in the order we planned @@ -1609,7 +1609,7 @@ namespace Realm { #ifdef DEBUG_REALM // but it should never be older than the current release - assert(it2->last_release_seqid >= it->seqid); + REALM_ASSERT(it2->last_release_seqid >= it->seqid); #endif // all older release are done, so this alloc had better work @@ -1617,24 +1617,24 @@ namespace Realm { size_t offset = 0; bool ok = current_allocator.allocate(it2->inst->me, it2->bytes, it2->alignment, offset); - assert(ok); + REALM_ASSERT(ok); #ifdef DEBUG_REALM // it should also be where we thought it was in the future // allocator state (unless it's already been future-deleted) size_t f_first, f_size; if(future_allocator.lookup(it2->inst->me, f_first, f_size)) { - assert((f_first == offset) && (f_size == it2->bytes)); + REALM_ASSERT((f_first == offset) && (f_size == it2->bytes)); } else { // find in future deletion list std::deque::const_iterator it3 = pending_releases.begin(); while(true) { // should not run off end of list - assert(it3 != pending_releases.end()); + REALM_ASSERT(it3 != pending_releases.end()); if(it3->inst != it2->inst) { ++it3; } else { // found it - make sure it's not already deleted - assert(!it3->is_ready); + REALM_ASSERT(!it3->is_ready); break; } } @@ -1669,7 +1669,7 @@ namespace Realm { // find this destruction in the list and mark it ready do { ++it; - assert(it != pending_releases.end()); // can't fall off end + REALM_ASSERT(it != pending_releases.end()); // can't fall off end } while(it->inst != inst); it->is_ready = true; @@ -1757,7 +1757,7 @@ namespace Realm { void LocalManagedMemory::PendingRelease::record_redistrict( const std::vector &insts) { - assert(redistrict_tags.empty()); + REALM_ASSERT(redistrict_tags.empty()); // Need to pull these local because the insts might already have been // created and destroyed before we get around to doing the pending release const size_t num_insts = insts.size(); @@ -1787,8 +1787,8 @@ namespace Realm { std::vector &offsets, bool missing_ok) { - assert(!redistrict_tags.empty()); - assert(offsets.size() == redistrict_tags.size()); + REALM_ASSERT(!redistrict_tags.empty()); + REALM_ASSERT(offsets.size() == redistrict_tags.size()); return allocator.split_range(inst->me, redistrict_tags, redistrict_sizes, redistrict_alignments, offsets, missing_ok); } @@ -1850,7 +1850,7 @@ namespace Realm { } prealloced = false; // we should not have been given a NetworkSegment by our caller - assert(!segment); + REALM_ASSERT(!segment); // advertise our allocation in case the network can register it local_segment.assign(NetworkSegmentInfo::HostMem, base, _size); segment = &local_segment; @@ -1902,9 +1902,9 @@ namespace Realm { span fields, bool read_only) { // compute the bounds of the instance relative to our base - assert(inst->metadata.is_valid() && + REALM_ASSERT(inst->metadata.is_valid() && "instance metadata must be valid before accesses are performed"); - assert(inst->metadata.layout); + REALM_ASSERT(inst->metadata.layout); InstanceLayoutGeneric *ilg = inst->metadata.layout; uintptr_t rel_base, extent; if(subspace == 0) { @@ -1912,7 +1912,7 @@ namespace Realm { rel_base = 0; extent = ilg->bytes_used; } else { - assert(!fields.empty()); + REALM_ASSERT(!fields.empty()); // TODO: right now if the subspace is not dense in the underlying instance we // just return an ExternalMemoryResource that describes the upper bound of how // much size this external resource should be allowed to use. If we really wanted @@ -1986,7 +1986,7 @@ namespace Realm { bool need_alloc_result, Event precondition) { NodeID target = ID(me).memory_owner_node(); - assert(target != Network::my_node_id); + REALM_ASSERT(target != Network::my_node_id); // we need to send the layout information to the memory's owner node - see // how big that'll be @@ -1994,7 +1994,7 @@ namespace Realm { bool ok = bcs << *inst->metadata.layout; if(ok && (inst->metadata.ext_resource != 0)) ok = bcs << *inst->metadata.ext_resource; - assert(ok); + REALM_ASSERT(ok); size_t layout_bytes = bcs.bytes_used(); ActiveMessage amsg(target, layout_bytes); @@ -2014,7 +2014,7 @@ namespace Realm { Event precondition) { NodeID target = ID(me).memory_owner_node(); - assert(target != Network::my_node_id); + REALM_ASSERT(target != Network::my_node_id); ActiveMessage amsg(target); amsg->memory = me; @@ -2029,7 +2029,7 @@ namespace Realm { Event precondition) { // TODO: implement this - assert(false); + abort(); return ALLOC_INSTANT_FAILURE; } @@ -2060,23 +2060,23 @@ namespace Realm { off_t RemoteMemory::alloc_bytes_local(size_t size) { - assert(0); + abort(); return 0; } - void RemoteMemory::free_bytes_local(off_t offset, size_t size) { assert(0); } + void RemoteMemory::free_bytes_local(off_t offset, size_t size) { abort(); } void RemoteMemory::put_bytes(off_t offset, const void *src, size_t size) { void *ptr = get_direct_ptr(offset, size); - assert(ptr != nullptr); + REALM_ASSERT(ptr != nullptr); memcpy(ptr, src, size); } void RemoteMemory::get_bytes(off_t offset, void *dst, size_t size) { void *ptr = get_direct_ptr(offset, size); - assert(ptr != nullptr); + REALM_ASSERT(ptr != nullptr); memcpy(dst, ptr, size); } @@ -2097,17 +2097,18 @@ namespace Realm { NodeID sender, const MemStorageAllocRequest &args, const void *data, size_t datalen) { MemoryImpl *impl = get_runtime()->get_memory_impl(args.memory); - assert(impl != nullptr && "invalid memory handle"); + // invalid memory handle + REALM_ASSERT(impl != nullptr); RegionInstanceImpl *inst = impl->get_instance(args.inst); - + REALM_ASSERT(inst != nullptr); // deserialize the layout Serialization::FixedBufferDeserializer fbd(data, datalen); InstanceLayoutGeneric *ilg = InstanceLayoutGeneric::deserialize_new(fbd); - assert(ilg != 0); + REALM_ASSERT(ilg != nullptr); ExternalInstanceResource *res = 0; if(fbd.bytes_left() > 0) { res = ExternalInstanceResource::deserialize_new(fbd); - assert((res != 0) && (fbd.bytes_left() == 0)); + REALM_ASSERT((res != 0) && (fbd.bytes_left() == 0)); } inst->metadata.layout = ilg; // TODO: mark metadata valid? inst->metadata.ext_resource = res; @@ -2140,7 +2141,7 @@ namespace Realm { const void *data, size_t datalen) { MemoryImpl *impl = get_runtime()->get_memory_impl(args.memory); - assert(impl != nullptr && "invalid memory handle"); + REALM_ASSERT(impl != nullptr); RegionInstanceImpl *inst = impl->get_instance(args.inst); impl->release_storage_deferrable(inst, args.precondition); diff --git a/src/realm/mem_impl.h b/src/realm/mem_impl.h index e0cdf11b922..03520c67b33 100644 --- a/src/realm/mem_impl.h +++ b/src/realm/mem_impl.h @@ -98,7 +98,7 @@ namespace Realm { virtual void reuse_allocated_range(RegionInstanceImpl *old_inst, std::vector &new_insts) { - assert(0); + abort(); } // default implementation falls through (directly or indirectly) to diff --git a/src/realm/mem_impl.inl b/src/realm/mem_impl.inl index 68a9e638b4e..d7505d547c4 100644 --- a/src/realm/mem_impl.inl +++ b/src/realm/mem_impl.inl @@ -124,7 +124,7 @@ namespace Realm { return; } - assert(0); + abort(); } template @@ -171,13 +171,13 @@ namespace Realm { { typename std::map::iterator it = allocated.find(old_tag); if(it == allocated.end()) { - assert(missing_ok); + REALM_ASSERT(missing_ok); return 0; } const size_t n = new_tags.size(); - assert(n == sizes.size() && n == alignments.size()); - assert(allocs_first.size() == n); + REALM_ASSERT(n == sizes.size() && n == alignments.size()); + REALM_ASSERT(allocs_first.size() == n); const unsigned range_idx = it->second; if(range_idx == SENTINEL) { @@ -199,7 +199,7 @@ namespace Realm { Range *r = &ranges[range_idx]; for(size_t i = 0; i < n; i++) { - assert(allocated.find(new_tags[i]) == allocated.end()); + REALM_ASSERT(allocated.find(new_tags[i]) == allocated.end()); if(sizes[i]) { RT offset = calculate_offset(r->first, alignments[i]); // do we have enough space? @@ -214,7 +214,7 @@ namespace Realm { unsigned pf_idx = r->prev; while((pf_idx != SENTINEL) && (ranges[pf_idx].prev_free == pf_idx)) { pf_idx = ranges[pf_idx].prev; - assert(pf_idx != range_idx); // wrapping around would be bad + REALM_ASSERT(pf_idx != range_idx); // wrapping around would be bad } if((pf_idx == r->prev) && (pf_idx != SENTINEL)) { // Previous range is free so we can expand it to include offset @@ -266,8 +266,8 @@ namespace Realm { bool has_cycle = free_list_has_cycle(); bool invalid = has_invalid_ranges(); if(has_cycle || invalid) { - assert(has_cycle == false); - assert(invalid == false); + REALM_ASSERT(has_cycle == false); + REALM_ASSERT(invalid == false); } #endif return n; @@ -370,7 +370,7 @@ namespace Realm { stats.total_free_size = total_free_size; stats.largest_free_blocksize = largest_free_blocksize; - assert(total_size == total_used_size + total_free_size); + REALM_ASSERT(total_size == total_used_size + total_free_size); return stats; } @@ -415,11 +415,6 @@ namespace Realm { return true; } -#ifdef DEBUG_REALM - // assert(free_list_has_cycle() == false); - // assert(has_invalid_ranges() == false); -#endif - // walk free ranges and just take the first that fits unsigned idx = ranges[SENTINEL].next_free; while(idx != SENTINEL) { @@ -499,11 +494,6 @@ namespace Realm { allocated[tag] = idx; -#ifdef DEBUG_REALM - // assert(free_list_has_cycle() == false); - // assert(has_invalid_ranges() == false); -#endif - return true; } @@ -528,12 +518,12 @@ namespace Realm { unsigned pf_idx = r.prev; while((pf_idx != SENTINEL) && (ranges[pf_idx].prev_free == pf_idx)) { pf_idx = ranges[pf_idx].prev; - assert(pf_idx != del_idx); // wrapping around would be bad + REALM_ASSERT(pf_idx != del_idx); // wrapping around would be bad } unsigned nf_idx = r.next; while((nf_idx != SENTINEL) && (ranges[nf_idx].next_free == nf_idx)) { nf_idx = ranges[nf_idx].next; - assert(nf_idx != del_idx); + REALM_ASSERT(nf_idx != del_idx); } // do we need to merge? @@ -611,7 +601,7 @@ namespace Realm { { typename std::map::iterator it = allocated.find(tag); if(it == allocated.end()) { - assert(missing_ok); + REALM_ASSERT(missing_ok); return; } unsigned del_idx = it->second; @@ -713,7 +703,7 @@ namespace Realm { stats.total_free_size = total_free_size; stats.largest_free_blocksize = stats.largest_free_blocksize; - assert(total_size == total_used_size + total_free_size); + REALM_ASSERT(total_size == total_used_size + total_free_size); return stats; } @@ -747,7 +737,7 @@ namespace Realm { return; } - assert(0); + abort(); } template @@ -853,7 +843,7 @@ namespace Realm { { typename std::map::iterator it = this->allocated.find(tag); if(it == this->allocated.end()) { - assert(missing_ok); + REALM_ASSERT(missing_ok); return; } unsigned del_idx = it->second; @@ -933,12 +923,12 @@ namespace Realm { { typename std::map::iterator it = this->allocated.find(old_tag); if(it == this->allocated.end()) { - assert(missing_ok); + REALM_ASSERT(missing_ok); return 0; } size_t n = new_tags.size(); - assert(n == sizes.size() && n == alignments.size()); + REALM_ASSERT(n == sizes.size() && n == alignments.size()); unsigned index = it->second; if (index == SENTINEL) { @@ -1086,8 +1076,8 @@ namespace Realm { // We're the first item in the list RT size = range.last - range.first; unsigned log2_size = floor_log2(size); - assert(log2_size < size_based_free_lists.size()); - assert(size_based_free_lists[log2_size] == index); + REALM_ASSERT(log2_size < size_based_free_lists.size()); + REALM_ASSERT(size_based_free_lists[log2_size] == index); if (range.next_free != SENTINEL) this->ranges[range.next_free].prev_free = SENTINEL; size_based_free_lists[log2_size] = range.next_free; @@ -1145,7 +1135,7 @@ namespace Realm { /*static*/ unsigned SizedRangeAllocator::floor_log2(uint64_t size) { // size should be non-zero - assert(size); + REALM_ASSERT(size); // Round down to the nearest power of two to figure out which range // to put it in using DeBruijin algorithm to compute integer log2 // Taken from Hacker's Delight diff --git a/src/realm/metadata.cc b/src/realm/metadata.cc index d037fbd6b28..95b27e71495 100644 --- a/src/realm/metadata.cc +++ b/src/realm/metadata.cc @@ -64,7 +64,7 @@ namespace Realm { // response if the data is already valid AutoLock<> a(mutex); - assert(!remote_copies.contains(requestor)); + REALM_ASSERT(!remote_copies.contains(requestor)); remote_copies.add(requestor); return is_valid(); @@ -88,7 +88,7 @@ namespace Realm { } default: - assert(0); + abort(); } } @@ -129,16 +129,18 @@ namespace Realm { case STATE_REQUESTED: { // request has already been issued, but return the event again - assert(valid_event.exists()); + REALM_ASSERT(valid_event.exists()); e = valid_event; break; } case STATE_INVALIDATE: - assert(0 && "requesting metadata we've been told is invalid!"); + log_metadata.fatal() << "requesting metadata we've been told is invalid!"; + abort(); case STATE_CLEANUP: - assert(0 && "requesting metadata in CLEANUP state!"); + log_metadata.fatal() << "requesting metadata in CLEANUP state!"; + abort(); } } @@ -157,7 +159,7 @@ namespace Realm { { AutoLock<> a(mutex); - assert(state == STATE_VALID); + REALM_ASSERT(state == STATE_VALID); // eagerly invalidate local contents do_invalidate(); @@ -208,7 +210,7 @@ namespace Realm { } default: - assert(0); + abort(); } } @@ -218,7 +220,7 @@ namespace Realm { { AutoLock<> a(mutex); - assert(remote_copies.contains(sender)); + REALM_ASSERT(remote_copies.contains(sender)); remote_copies.remove(sender); last_copy = remote_copies.empty(); if(last_copy) @@ -252,7 +254,7 @@ namespace Realm { impl->metadata.serialize_msg(dbs); } } else { - assert(0); + abort(); } if(send_response) { @@ -310,10 +312,10 @@ namespace Realm { delete[] new_buffer; } } - assert((args.offset + datalen) <= args.total_bytes); + REALM_ASSERT((args.offset + datalen) <= args.total_bytes); memcpy(buffer + args.offset, data, datalen); size_t prev_bytes_done = impl->metadata.frag_bytes_received.fetch_add(datalen); - assert((prev_bytes_done + datalen) <= args.total_bytes); + REALM_ASSERT((prev_bytes_done + datalen) <= args.total_bytes); if((prev_bytes_done + datalen) == args.total_bytes) { // safe to deserialize now, but detach reassembly buffer first (to avoid // races with reuse of the instance) @@ -327,7 +329,7 @@ namespace Realm { } } } else { - assert(0); + abort(); } } @@ -350,7 +352,7 @@ namespace Realm { RegionInstanceImpl *impl = get_runtime()->get_instance_impl(args.id); impl->metadata.handle_invalidate(); } else { - assert(0); + abort(); } // ack the request @@ -380,7 +382,7 @@ namespace Realm { if(last_ack) impl->recycle_instance(); } else { - assert(0); + abort(); } if(last_ack) { diff --git a/src/realm/module.cc b/src/realm/module.cc index 81c0747b0bd..f57159289f7 100644 --- a/src/realm/module.cc +++ b/src/realm/module.cc @@ -254,7 +254,7 @@ namespace Realm { p1 = p2 + (*p2 ? 1 : 0); // no leftover errors from anybody else please... - assert(dlerror() == 0); + REALM_ASSERT(dlerror() == 0); // open so file, resolving all symbols but not polluting global namespace void *handle = dlopen(filename, RTLD_NOW | RTLD_LOCAL); @@ -317,7 +317,7 @@ namespace Realm { // eat this argument and move the next one to sonames_list it = cmdline.erase(it); - assert(it != cmdline.end()); + REALM_ASSERT(it != cmdline.end()); sonames_list.push_back(*it); it = cmdline.erase(it); } @@ -355,7 +355,7 @@ namespace Realm { // out all the name we want to load #ifdef REALM_USE_DLFCN if(module_sofile_handles.size() > 0) { - assert(sofile_loaded); + REALM_ASSERT(sofile_loaded); } for(std::vector::iterator it = module_sofile_handles.begin(); it != module_sofile_handles.end(); it++) { @@ -401,11 +401,8 @@ namespace Realm { void *handle = sofile_handles.back(); sofile_handles.pop_back(); -#ifndef NDEBUG - int ret = -#endif - dlclose(handle); - assert(ret == 0); + int ret = dlclose(handle); + REALM_ASSERT(ret == 0); } #endif } diff --git a/src/realm/module_config.cc b/src/realm/module_config.cc index 8b39492af6c..bf78b4f8f18 100644 --- a/src/realm/module_config.cc +++ b/src/realm/module_config.cc @@ -34,7 +34,7 @@ namespace Realm { void ModuleConfig::finish_configure(void) { - assert(finish_configured == false); + REALM_ASSERT(finish_configured == false); finish_configured = true; } diff --git a/src/realm/mutex.cc b/src/realm/mutex.cc index 23393eba8fe..099833380f7 100644 --- a/src/realm/mutex.cc +++ b/src/realm/mutex.cc @@ -138,7 +138,7 @@ namespace Realm { { event = CreateEvent(NULL /*default security*/, FALSE /*!manual reset*/, FALSE /*initial state*/, NULL /*unnamed*/); - assert(event); + REALM_ASSERT(event); } ~DoorbellImpl() { CloseHandle(event); } @@ -183,7 +183,7 @@ namespace Realm { Doorbell::~Doorbell() { #ifdef DEBUG_REALM - assert(state.load() == STATE_IDLE); + REALM_ASSERT(state.load() == STATE_IDLE); #endif } @@ -285,7 +285,7 @@ namespace Realm { // exactly one wake, no matter which order they happen in if(dbi->state.compare_exchange(val, STATE_PENDING_ASLEEP)) { DWORD result = WaitForSingleObject(dbi->event, INFINITE); - assert(result == WAIT_OBJECT_0); + REALM_ASSERT(result == WAIT_OBJECT_0); } #else // attempt to sleep, but the AWAKE->ASLEEP transition has to happen with @@ -303,7 +303,7 @@ namespace Realm { // uncontested transition back to IDLE #ifdef DEBUG_REALM uint32_t prev = state.exchange(STATE_IDLE); - assert(prev == val); + REALM_ASSERT(prev == val); (void)prev; #else state.store(STATE_IDLE); @@ -318,16 +318,16 @@ namespace Realm { #if defined(REALM_ON_LINUX) && !defined(REALM_NO_USE_FUTEX) // tell kernel to wake up sleeper (or not, if we get there first) int ret = syscall(SYS_futex, &dbi->state, FUTEX_WAKE, 1, nullptr, nullptr, 0); - assert(ret >= 0); + REALM_ASSERT(ret >= 0); #elif defined(REALM_ON_WINDOWS) // set the sleeper's event DWORD result = SetEvent(dbi->event); - assert(result); + REALM_ASSERT(result); #else // we know there was a sleeper, but condvar rules say we need to take mutex // first dbi->mutex.lock(); - assert(dbi->asleep); + REALM_ASSERT(dbi->asleep); dbi->asleep = false; dbi->condvar.signal(); dbi->mutex.unlock(); @@ -377,7 +377,7 @@ namespace Realm { DoorbellList::~DoorbellList() { #ifdef DEBUG_REALM - assert(head_or_count.load() == 0); + REALM_ASSERT(head_or_count.load() == 0); #endif } @@ -467,7 +467,7 @@ namespace Realm { // appears in a next pointer and disconnect it Doorbell *cur = reinterpret_cast(expected); while(cur->next_doorbell != head) { - assert(cur->next_doorbell); + REALM_ASSERT(cur->next_doorbell); cur = cur->next_doorbell; } cur->next_doorbell = head->next_doorbell; @@ -475,7 +475,7 @@ namespace Realm { } else { // we're modifying something inside the list we own, so no need to mess // with the atomic head pointer - assert(chosen_prev->next_doorbell == chosen); + REALM_ASSERT(chosen_prev->next_doorbell == chosen); chosen_prev->next_doorbell = chosen->next_doorbell; } @@ -545,7 +545,7 @@ namespace Realm { // appears in a next pointer and disconnect it Doorbell *cur = reinterpret_cast(expected); while(cur->next_doorbell != head) { - assert(cur->next_doorbell); + REALM_ASSERT(cur->next_doorbell); cur = cur->next_doorbell; } cur->next_doorbell = head->next_doorbell; @@ -645,7 +645,7 @@ namespace Realm { // nope, new work has been delegated to us - return the difference between // what we knew of before and the new total #ifdef DEBUG_REALM - assert(expected > tstate); + REALM_ASSERT(expected > tstate); #endif uint64_t new_work = (expected - tstate) >> 1; tstate = expected; @@ -680,7 +680,7 @@ namespace Realm { #ifdef DEBUG_REALM // lock better be held! val = state.load(); - assert((val & 1) != 0); + REALM_ASSERT((val & 1) != 0); #endif return; } else { @@ -729,7 +729,7 @@ namespace Realm { // since we're releasing the lock to an unknown thread, this needs to // have release semantics uint32_t prev = state.fetch_sub_acqrel(3); - assert(((prev & 1) != 0) && (prev >= 3)); + REALM_ASSERT(((prev & 1) != 0) && (prev >= 3)); (void)prev; db->notify(0 /*!lock_transfer*/); @@ -737,7 +737,7 @@ namespace Realm { // if we got a spinning waiter or none at all (i.e. extra token case), // we'll transfer the lock to them, so just decrement the waiter count uint32_t prev = state.fetch_sub(2); - assert(((prev & 1) != 0) && (prev >= 3)); + REALM_ASSERT(((prev & 1) != 0) && (prev >= 3)); (void)prev; // reattempt extract if we didn't get one before @@ -775,7 +775,7 @@ namespace Realm { return; } } else { - assert(val == 0); + REALM_ASSERT(val == 0); if(state.compare_exchange(val, 1)) { // managed to grab the lock without waiting return; @@ -789,7 +789,7 @@ namespace Realm { // decrement the waiter count and then pass the lock on to whoever we // get from the doorbell list uint32_t prev = state.fetch_sub(2); - assert(((prev & 1) != 0) && (prev >= 3)); + REALM_ASSERT(((prev & 1) != 0) && (prev >= 3)); (void)prev; Doorbell *db = @@ -806,7 +806,7 @@ namespace Realm { KernelMutex::KernelMutex(void) { NativeMutex *mutex = reinterpret_cast(&placeholder); - assert(sizeof(NativeMutex) <= sizeof(placeholder)); + static_assert(sizeof(NativeMutex) <= sizeof(placeholder)); #ifdef REALM_ON_WINDOWS InitializeCriticalSection(mutex); #else @@ -875,14 +875,14 @@ namespace Realm { db_list.extract_newest(true /*prefer_spinning*/, false /*!allow_extra*/); // a waiter had to add themselves before letting go of the lock, so // this should never fail - assert(db); + REALM_ASSERT(db); // now that we have the signal-ee, don't actually ring the doorbell - // just re-insert this doorbell on the mutex's waiter list uint32_t mutex_prev = mutex.state.fetch_add(2); - assert((mutex_prev & 1) != 0); // i.e. we hold the lock + REALM_ASSERT((mutex_prev & 1) != 0); // i.e. we hold the lock // similarly, this should never see a wake-before-wait case bool ok = mutex.db_list.add_doorbell(db); - assert(ok); + REALM_ASSERT(ok); (void)ok; } else { // no waiters, so signal() is a nop @@ -901,14 +901,14 @@ namespace Realm { db_list.extract_oldest(false /*!prefer_spinning*/, false /*!allow_extra*/); // a waiter had to add themselves before letting go of the lock, so // this should never fail - assert(db); + REALM_ASSERT(db); // now that we have the signal-ee, don't actually ring the doorbell - // just re-insert this doorbell on the mutex's waiter list uint32_t mutex_prev = mutex.state.fetch_add(2); - assert((mutex_prev & 1) != 0); // i.e. we hold the lock + REALM_ASSERT((mutex_prev & 1) != 0); // i.e. we hold the lock // similarly, this should never see a wake-before-wait case bool ok = mutex.db_list.add_doorbell(db); - assert(ok); + REALM_ASSERT(ok); (void)ok; } } @@ -922,7 +922,7 @@ namespace Realm { num_waiters++; bool ok = db_list.add_doorbell(db); // condvar doorbell list should never go negative - assert(ok); + REALM_ASSERT(ok); (void)ok; // now release the mutex and wait on our doorbell - we will not be @@ -955,14 +955,14 @@ namespace Realm { db_list.extract_oldest(false /*!prefer_spinning*/, false /*!allow_extra*/); // a waiter had to add themselves before letting go of the lock, so // this should never fail - assert(db); + REALM_ASSERT(db); // now that we have the signal-ee, don't actually ring the doorbell - // just re-insert this doorbell on the mutex's waiter list uint32_t mutex_prev = mutex.state.fetch_add(2); - assert((mutex_prev & 1) != 0); // i.e. we hold the lock + REALM_ASSERT((mutex_prev & 1) != 0); // i.e. we hold the lock // similarly, this should never see a wake-before-wait case bool ok = mutex.db_list.add_doorbell(db); - assert(ok); + REALM_ASSERT(ok); (void)ok; } else { // no waiters, so signal() is a nop @@ -979,14 +979,14 @@ namespace Realm { db_list.extract_oldest(false /*!prefer_spinning*/, false /*!allow_extra*/); // a waiter had to add themselves before letting go of the lock, so // this should never fail - assert(db); + REALM_ASSERT(db); // now that we have the signal-ee, don't actually ring the doorbell - // just re-insert this doorbell on the mutex's waiter list uint32_t mutex_prev = mutex.state.fetch_add(2); - assert((mutex_prev & 1) != 0); // i.e. we hold the lock + REALM_ASSERT((mutex_prev & 1) != 0); // i.e. we hold the lock // similarly, this should never see a wake-before-wait case bool ok = mutex.db_list.add_doorbell(db); - assert(ok); + REALM_ASSERT(ok); (void)ok; } } @@ -1000,7 +1000,7 @@ namespace Realm { num_waiters++; bool ok = db_list.add_doorbell(db); // condvar doorbell list should never go negative - assert(ok); + REALM_ASSERT(ok); (void)ok; // now release the mutex and wait on our doorbell - we will not be @@ -1020,7 +1020,7 @@ namespace Realm { { NativeConditionVariable *condvar = reinterpret_cast(&placeholder); - assert(sizeof(NativeConditionVariable) <= sizeof(placeholder)); + static_assert(sizeof(NativeConditionVariable) <= sizeof(placeholder)); #ifdef REALM_ON_WINDOWS InitializeConditionVariable(condvar); #else @@ -1108,7 +1108,7 @@ namespace Realm { , reader(*this) { NativeRWLock *rwlock = reinterpret_cast(&placeholder); - assert(sizeof(NativeRWLock) <= sizeof(placeholder)); + static_assert(sizeof(NativeRWLock) <= sizeof(placeholder)); #ifdef REALM_ON_WINDOWS InitializeSRWLock(&rwlock->rwlock); #else diff --git a/src/realm/mutex.inl b/src/realm/mutex.inl index 62876432a83..cb3798bd129 100644 --- a/src/realm/mutex.inl +++ b/src/realm/mutex.inl @@ -36,7 +36,7 @@ namespace Realm { // uncontested transition from IDLE to PENDING_AWAKE #ifdef DEBUG_REALM uint32_t prev = state.exchange(STATE_PENDING_AWAKE); - assert(prev == STATE_IDLE); + REALM_ASSERT(prev == STATE_IDLE); (void)prev; #else state.store(STATE_PENDING_AWAKE); @@ -48,7 +48,7 @@ namespace Realm { // uncontested transition from PENDING_AWAKE to IDLE #ifdef DEBUG_REALM uint32_t prev = state.exchange(STATE_IDLE); - assert(prev == STATE_PENDING_AWAKE); + REALM_ASSERT(prev == STATE_PENDING_AWAKE); (void)prev; #else state.store(STATE_IDLE); @@ -60,7 +60,7 @@ namespace Realm { uint32_t val = state.load_acquire(); #ifdef DEBUG_REALM // should not be asking about an idle doorbell - assert(val != STATE_IDLE); + REALM_ASSERT(val != STATE_IDLE); #endif return ((val & STATE_SATISFIED_BIT) != 0); } @@ -73,7 +73,7 @@ namespace Realm { // uncontested transition back to IDLE #ifdef DEBUG_REALM uint32_t prev = state.exchange(STATE_IDLE); - assert(prev == val); + REALM_ASSERT(prev == val); (void)prev; #else state.store(STATE_IDLE); @@ -88,7 +88,7 @@ namespace Realm { uint32_t val = state.load(); #ifdef DEBUG_REALM // should not be asking about an idle or satisfied doorbell - assert((val != STATE_IDLE) && ((val & STATE_SATISFIED_BIT) == 0)); + REALM_ASSERT((val != STATE_IDLE) && ((val & STATE_SATISFIED_BIT) == 0)); #endif return (val != STATE_PENDING_AWAKE); } @@ -110,7 +110,7 @@ namespace Realm { // wake thread uint32_t oldval = state.exchange(STATE_PENDING_PREWAKE); #ifdef DEBUG_REALM - assert((oldval == STATE_PENDING_AWAKE) || (oldval == STATE_PENDING_ASLEEP)); + REALM_ASSERT((oldval == STATE_PENDING_AWAKE) || (oldval == STATE_PENDING_ASLEEP)); #endif if(REALM_UNLIKELY(oldval == STATE_PENDING_ASLEEP)) prewake_slow(); @@ -121,7 +121,7 @@ namespace Realm { // uncontested transition from PREWAKE back to AWAKE #ifdef DEBUG_REALM uint32_t prev = state.exchange(STATE_PENDING_AWAKE); - assert(prev == STATE_PENDING_PREWAKE); + REALM_ASSERT(prev == STATE_PENDING_PREWAKE); (void)prev; #else state.store(STATE_PENDING_AWAKE); @@ -334,7 +334,7 @@ namespace Realm { inline void AutoLock::release(void) { #ifdef DEBUG_REALM - assert(held); + REALM_ASSERT(held); #endif mutex.unlock(); held = false; @@ -344,7 +344,7 @@ namespace Realm { inline void AutoLock::reacquire(void) { #ifdef DEBUG_REALM - assert(!held); + REALM_ASSERT(!held); #endif mutex.lock(); held = true; diff --git a/src/realm/network.cc b/src/realm/network.cc index 345a63feee8..eeb341ab286 100644 --- a/src/realm/network.cc +++ b/src/realm/network.cc @@ -253,8 +253,9 @@ namespace Realm { CommandLineParser cp; cp.add_option_int_units("-ll:gsize", global_size, 'm'); bool ok = cp.parse_command_line(cmdline); - assert(ok); - assert((global_size == 0) && "no global mem support in dummy network yet"); + REALM_ASSERT(ok); + // no global mem support in dummy network yet + REALM_ASSERT(global_size == 0); } // "attaches" to the network, if that is meaningful - attempts to @@ -269,7 +270,7 @@ namespace Realm { if(((*it)->bytes > 0) && ((*it)->base == 0)) { void *memptr = aligned_malloc((*it)->bytes, std::max((*it)->alignment, sizeof(void *))); - assert(memptr != 0); + REALM_ASSERT(memptr != 0); (*it)->base = memptr; (*it)->add_rdma_info(this, &memptr, sizeof(void *)); } @@ -447,7 +448,7 @@ namespace Realm { ba.set(data, len); #ifdef REALM_USE_MULTIPLE_NETWORKS #else - assert(single_network == 0); + REALM_ASSERT(single_network == 0); single_network = network; single_network_data = &ba; #endif @@ -560,7 +561,7 @@ namespace Realm { p1 = p2 + (*p2 ? 1 : 0); // no leftover errors from anybody else please... - assert(dlerror() == 0); + REALM_ASSERT(dlerror() == 0); // open so file, resolving all symbols but not polluting global namespace void *handle = dlopen(filename, RTLD_NOW | RTLD_LOCAL); @@ -728,9 +729,9 @@ namespace Realm { if(need_loopback) { NetworkModule *m = LoopbackNetworkModule::create_network_module(runtime, argc, argv); - assert(m != 0); + REALM_ASSERT(m != 0); modules.push_back(m); - assert(Network::single_network == 0); + REALM_ASSERT(Network::single_network == 0); Network::single_network = m; } } From b9cb52d3fb06510f10509760c916898072bd4f43 Mon Sep 17 00:00:00 2001 From: Wei Wu Date: Thu, 6 Nov 2025 14:29:11 -0800 Subject: [PATCH 3/4] checkpoint --- src/realm/inst_impl.cc | 122 ++++++++++++++++++-------------------- src/realm/inst_impl.h | 2 +- src/realm/inst_layout.cc | 6 +- src/realm/inst_layout.inl | 70 +++++++++++----------- 4 files changed, 96 insertions(+), 104 deletions(-) diff --git a/src/realm/inst_impl.cc b/src/realm/inst_impl.cc index d3469ff3c97..fe4ec44f657 100644 --- a/src/realm/inst_impl.cc +++ b/src/realm/inst_impl.cc @@ -128,7 +128,7 @@ namespace Realm { { program_size = bytes; program_base = repl_heap->alloc_obj(bytes, 16); - assert(program_base != 0); + REALM_ASSERT(program_base != 0); return program_base; } @@ -245,12 +245,12 @@ namespace Realm { opens++; cur_vol += pieces[(-1 - ss[i].second)]->bounds.volume(); } else { - assert(opens > 0); + REALM_ASSERT(opens > 0); opens--; } } - assert(cur_vol == total_vol); - assert(opens == 0); + REALM_ASSERT(cur_vol == total_vol); + REALM_ASSERT(opens == 0); } if(best_dim >= 0) { @@ -337,8 +337,8 @@ namespace Realm { // generate low half of tree then record delta for high tree next_inst = low_child->generate_instructions(pieces, next_inst, usage_mask); size_t delta_bytes = next_inst - cur_inst; - assert((delta_bytes & 15) == 0); - assert(delta_bytes < (1 << 20)); + REALM_ASSERT((delta_bytes & 15) == 0); + REALM_ASSERT(delta_bytes < (1 << 20)); sp->set_delta(delta_bytes >> 4); next_inst = high_child->generate_instructions(pieces, next_inst, usage_mask); @@ -351,7 +351,7 @@ namespace Realm { template void InstanceLayout::compile_lookup_program(PieceLookup::CompiledProgram &p) const { - assert(!p.is_compiled.load()); + REALM_ASSERT(!p.is_compiled.load()); // first, count up how many bytes we're going to need size_t total_bytes = 0; @@ -508,7 +508,7 @@ namespace Realm { log_inst.info() << "instance destroyed: inst=" << *this << " wait_on=" << wait_on; RegionInstanceImpl *inst_impl = get_runtime()->get_instance_impl(id); - assert(inst_impl != nullptr && "invalid instance handle"); + REALM_ASSERT(inst_impl != nullptr); return inst_impl->release(wait_on); } @@ -533,7 +533,7 @@ namespace Realm { { ID inst_id = ID(id); MemoryImpl *mem_impl = get_runtime()->get_memory_impl(inst_id); - assert(mem_impl != nullptr && "invalid memory handle"); + REALM_ASSERT(mem_impl != nullptr); RegionInstanceImpl *inst_impl = mem_impl->get_instance(inst_id); return mem_impl->generate_resource_info(inst_impl, 0, span(), read_only); @@ -545,7 +545,7 @@ namespace Realm { { ID inst_id = ID(id); MemoryImpl *mem_impl = get_runtime()->get_memory_impl(inst_id); - assert(mem_impl != nullptr && "invalid memory handle"); + REALM_ASSERT(mem_impl != nullptr); RegionInstanceImpl *inst_impl = mem_impl->get_instance(inst_id); return mem_impl->generate_resource_info(inst_impl, &space, fields, read_only); } @@ -569,9 +569,8 @@ namespace Realm { { RegionInstanceImpl *r_impl = get_runtime()->get_instance_impl(*this); // metadata must already be available - assert(r_impl->metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(r_impl->metadata.layout); + REALM_ASSERT(r_impl->metadata.is_valid()); + REALM_ASSERT(r_impl->metadata.layout); return r_impl->metadata.layout; } @@ -644,7 +643,7 @@ namespace Realm { void *orig_base = 0; size_t orig_stride = 0; bool ok = r_impl->get_strided_parameters(orig_base, orig_stride, field_offset); - assert(ok); + REALM_ASSERT(ok); base = reinterpret_cast(orig_base); stride = orig_stride; } @@ -652,7 +651,7 @@ namespace Realm { void RegionInstance::report_instance_fault(int reason, const void *reason_data, size_t reason_size) const { - assert(0); + abort(); } //////////////////////////////////////////////////////////////////////// @@ -694,7 +693,7 @@ namespace Realm { RegionInstance &inst, MemoryImpl *mem_impl, InstanceLayoutGeneric *ilg, const ExternalInstanceResource *res, const ProfilingRequestSet &prs, Event wait_on) { - assert(mem_impl != nullptr && "Invalid mem impl"); + REALM_ASSERT(mem_impl != nullptr); RegionInstanceImpl *impl = mem_impl->new_instance(prs); // we can fail to get a valid pointer if we are out of instance slots // we can also fail if there is not enough space for the instance @@ -743,7 +742,7 @@ namespace Realm { case MemoryImpl::ALLOC_INSTANT_SUCCESS: { // successful allocation - assert(impl->metadata.inst_offset <= RegionInstanceImpl::INSTOFFSET_MAXVALID); + REALM_ASSERT(impl->metadata.inst_offset <= RegionInstanceImpl::INSTOFFSET_MAXVALID); ready_event = Event::NO_EVENT; break; } @@ -812,7 +811,7 @@ namespace Realm { case MemoryImpl::ALLOC_EVENTUAL_SUCCESS: case MemoryImpl::ALLOC_EVENTUAL_FAILURE: // should not occur - assert(0); + abort(); } if(res) @@ -842,7 +841,7 @@ namespace Realm { std::vector insts(num_layouts); // TODO(apryakhin): Handle redistricting from non-owner node - assert(NodeID(ID(me).instance_owner_node()) == Network::my_node_id); + REALM_ASSERT(NodeID(ID(me).instance_owner_node()) == Network::my_node_id); for(size_t i = 0; i < num_layouts; i++) { insts[i] = mem_impl->new_instance(prs[i]); @@ -956,7 +955,7 @@ namespace Realm { case MemoryImpl::ALLOC_EVENTUAL_SUCCESS: case MemoryImpl::ALLOC_EVENTUAL_FAILURE: // should not occur - assert(0); + abort(); } return ready_event; } @@ -1019,7 +1018,7 @@ namespace Realm { } default: - assert(0); + abort(); } ActiveMessage amsg(creator_node); @@ -1055,7 +1054,7 @@ namespace Realm { // exception: allocations that were cancelled would have had some // error response reported further up the chain, so let this // one slide - assert(result == MemoryImpl::ALLOC_CANCELLED); + REALM_ASSERT(result == MemoryImpl::ALLOC_CANCELLED); } log_inst.info() << "allocation failed: inst=" << me; @@ -1096,8 +1095,8 @@ namespace Realm { if(metadata.need_alloc_result) { #ifdef DEBUG_REALM - assert(measurements.wants_measurement()); - assert(!metadata.need_notify_dealloc); + REALM_ASSERT(measurements.wants_measurement()); + REALM_ASSERT(!metadata.need_notify_dealloc); #endif // this is either the only result we will get or has raced ahead of @@ -1134,7 +1133,7 @@ namespace Realm { if(metadata.need_alloc_result) { #ifdef DEBUG_REALM - assert(measurements + REALM_ASSERT(measurements .wants_measurement()); #endif ProfilingMeasurements::InstanceAllocResult result; @@ -1175,8 +1174,8 @@ namespace Realm { // message, so do it with lock held if(metadata.need_alloc_result) { #ifdef DEBUG_REALM - assert(measurements.wants_measurement()); - assert(!metadata.need_notify_dealloc); + REALM_ASSERT(measurements.wants_measurement()); + REALM_ASSERT(!metadata.need_notify_dealloc); #endif // this is either the only result we will get or has raced ahead of @@ -1240,9 +1239,9 @@ namespace Realm { log_inst.debug() << "deallocation completed: inst=" << me; // our instance better not be in the unallocated state... - assert(metadata.inst_offset != INSTOFFSET_UNALLOCATED); - assert(metadata.inst_offset != INSTOFFSET_DELAYEDALLOC); - assert(metadata.inst_offset != INSTOFFSET_DELAYEDDESTROY); + REALM_ASSERT(metadata.inst_offset != INSTOFFSET_UNALLOCATED); + REALM_ASSERT(metadata.inst_offset != INSTOFFSET_DELAYEDALLOC); + REALM_ASSERT(metadata.inst_offset != INSTOFFSET_DELAYEDDESTROY); // was this a successfully allocatated instance? if(metadata.inst_offset != INSTOFFSET_FAILED) { @@ -1295,7 +1294,7 @@ namespace Realm { Event RegionInstanceImpl::prefetch_metadata(NodeID target_node) { - assert(target_node != Network::my_node_id); + REALM_ASSERT(target_node != Network::my_node_id); Event e = Event::NO_EVENT; { @@ -1331,11 +1330,10 @@ namespace Realm { } // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); + REALM_ASSERT(metadata.is_valid()); std::map::const_iterator it; it = metadata.lookup_program.fields.find(field_id); - assert(it != metadata.lookup_program.fields.end()); + REALM_ASSERT(it != metadata.lookup_program.fields.end()); // bail out if the program requires unsupported instructions if((it->second.inst_usage_mask & ~allowed_mask) != 0) @@ -1344,7 +1342,7 @@ namespace Realm { // the "field offset" picks up both the actual per-field offset but also // the base of the instance itself void *ptr = mem_impl->get_inst_ptr(this, 0, metadata.layout->bytes_used); - assert(ptr != 0); + REALM_ASSERT(ptr != 0); field_offset = (reinterpret_cast(ptr) + it->second.field_offset); return it->second.start_inst; @@ -1363,11 +1361,10 @@ namespace Realm { } // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); + REALM_ASSERT(metadata.is_valid()); std::map::const_iterator it; it = metadata.lookup_program.fields.find(field_id); - assert(it != metadata.lookup_program.fields.end()); + REALM_ASSERT(it != metadata.lookup_program.fields.end()); // bail out if the program requires unsupported instructions if((it->second.inst_usage_mask & ~allowed_mask) != 0) @@ -1376,7 +1373,7 @@ namespace Realm { // the "field offset" picks up both the actual per-field offset but also // the base of the instance itself void *ptr = mem_impl->get_inst_ptr(this, 0, metadata.layout->bytes_used); - assert(ptr != 0); + REALM_ASSERT(ptr != 0); field_offset = (reinterpret_cast(ptr) + it->second.field_offset); // try to pre-execute part of the program based on the subrect given @@ -1402,18 +1399,16 @@ namespace Realm { void RegionInstanceImpl::read_untyped(size_t offset, void *data, size_t datalen) const { // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(metadata.layout); + REALM_ASSERT(metadata.is_valid()); + REALM_ASSERT(metadata.layout); mem_impl->get_bytes(metadata.inst_offset + offset, data, datalen); } void RegionInstanceImpl::write_untyped(size_t offset, const void *data, size_t datalen) { // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(metadata.layout); + REALM_ASSERT(metadata.is_valid()); + REALM_ASSERT(metadata.layout); mem_impl->put_bytes(metadata.inst_offset + offset, data, datalen); } @@ -1422,16 +1417,15 @@ namespace Realm { bool exclusive /*= false*/) { // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(metadata.layout); + REALM_ASSERT(metadata.is_valid()); + REALM_ASSERT(metadata.layout); const ReductionOpUntyped *redop = runtime_impl->reduce_op_table.get(redop_id, 0); if(redop == 0) { log_inst.fatal() << "no reduction op registered for ID " << redop_id; abort(); } // data should match RHS size - assert(datalen == redop->sizeof_rhs); + REALM_ASSERT(datalen == redop->sizeof_rhs); // can we run the reduction op directly on the memory location? void *ptr = mem_impl->get_inst_ptr(this, offset, redop->sizeof_lhs); if(ptr) { @@ -1442,7 +1436,7 @@ namespace Realm { } else { // we have to do separate get/put, which means we cannot supply // atomicity in the !exclusive case - assert(exclusive); + REALM_ASSERT(exclusive); void *lhs_copy = alloca(redop->sizeof_lhs); mem_impl->get_bytes(metadata.inst_offset + offset, lhs_copy, redop->sizeof_lhs); (redop->cpu_apply_excl_fn)(lhs_copy, 0, data, 0, 1, redop->userdata); @@ -1455,16 +1449,15 @@ namespace Realm { bool exclusive /*= false*/) { // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(metadata.layout); + REALM_ASSERT(metadata.is_valid()); + REALM_ASSERT(metadata.layout); const ReductionOpUntyped *redop = runtime_impl->reduce_op_table.get(redop_id, 0); if(redop == 0) { log_inst.fatal() << "no reduction op registered for ID " << redop_id; abort(); } // data should match RHS size - assert(datalen == redop->sizeof_rhs); + REALM_ASSERT(datalen == redop->sizeof_rhs); // can we run the reduction op directly on the memory location? void *ptr = mem_impl->get_inst_ptr(this, offset, redop->sizeof_rhs); if(ptr) { @@ -1475,7 +1468,7 @@ namespace Realm { } else { // we have to do separate get/put, which means we cannot supply // atomicity in the !exclusive case - assert(exclusive); + REALM_ASSERT(exclusive); void *rhs1_copy = alloca(redop->sizeof_rhs); mem_impl->get_bytes(metadata.inst_offset + offset, rhs1_copy, redop->sizeof_rhs); (redop->cpu_fold_excl_fn)(rhs1_copy, 0, data, 0, 1, redop->userdata); @@ -1485,9 +1478,8 @@ namespace Realm { void *RegionInstanceImpl::pointer_untyped(size_t offset, size_t datalen) { // metadata must already be available - assert(metadata.is_valid() && - "instance metadata must be valid before accesses are performed"); - assert(metadata.layout); + REALM_ASSERT(metadata.is_valid()); + REALM_ASSERT(metadata.layout); return mem_impl->get_inst_ptr(this, offset, datalen); } @@ -1520,12 +1512,12 @@ namespace Realm { // this exists for compatibility and assumes N=1, T=long long const InstanceLayout<1, long long> *inst_layout = dynamic_cast *>(metadata.layout); - assert(inst_layout != 0); + REALM_ASSERT(inst_layout != 0); // look up the right field InstanceLayoutGeneric::FieldMap::const_iterator it = inst_layout->fields.find(field_offset); - assert(it != inst_layout->fields.end()); + REALM_ASSERT(it != inst_layout->fields.end()); // hand out a null pointer for empty instances (stride can be whatever // the caller wants) @@ -1535,10 +1527,10 @@ namespace Realm { } // also only works for a single piece - assert(inst_layout->piece_lists[it->second.list_idx].pieces.size() == 1); + REALM_ASSERT(inst_layout->piece_lists[it->second.list_idx].pieces.size() == 1); const InstanceLayoutPiece<1, long long> *piece = inst_layout->piece_lists[it->second.list_idx].pieces[0]; - assert((piece->layout_type == PieceLayoutTypes::AffineLayoutType)); + REALM_ASSERT((piece->layout_type == PieceLayoutTypes::AffineLayoutType)); const AffineLayoutPiece<1, long long> *affine = static_cast *>(piece); @@ -1587,7 +1579,7 @@ namespace Realm { Serialization::DynamicBufferSerializer dbs(128); bool ok = ((dbs << inst_offset) && (dbs << *layout)); - assert(ok); + REALM_ASSERT(ok); out_size = dbs.bytes_used(); return dbs.detach_buffer(0 /*trim*/); @@ -1601,7 +1593,7 @@ namespace Realm { if(ok) { layout = InstanceLayoutGeneric::deserialize_new(fbd); } - assert(ok && (layout != 0) && (fbd.bytes_left() == 0)); + REALM_ASSERT(ok && (layout != 0) && (fbd.bytes_left() == 0)); } void RegionInstanceImpl::Metadata::do_invalidate(void) @@ -1678,7 +1670,7 @@ namespace Realm { { // TODO: some way to ask for external memory resources on other ranks? CoreModule *mod = get_runtime()->get_module("core"); - assert(mod); + REALM_ASSERT(mod); return mod->ext_sysmem->me; } diff --git a/src/realm/inst_impl.h b/src/realm/inst_impl.h index b1f41c9f3c2..66e1310bbff 100644 --- a/src/realm/inst_impl.h +++ b/src/realm/inst_impl.h @@ -180,7 +180,7 @@ namespace Realm { void serialize_msg(T &s) const { bool ok = ((s << inst_offset) && (s << *layout)); - assert(ok); + REALM_ASSERT(ok); } void deserialize(const void *in_data, size_t in_size); diff --git a/src/realm/inst_layout.cc b/src/realm/inst_layout.cc index c4e1c68eaea..2cfe95da508 100644 --- a/src/realm/inst_layout.cc +++ b/src/realm/inst_layout.cc @@ -68,7 +68,7 @@ namespace Realm { default: { // hybrid - blech - assert(0); + abort(); } } } @@ -119,7 +119,7 @@ namespace Realm { default: { // hybrid - blech - assert(0); + abort(); } } } @@ -166,7 +166,7 @@ namespace Realm { default: { // hybrid - blech - assert(0); + abort(); } } } diff --git a/src/realm/inst_layout.inl b/src/realm/inst_layout.inl index ddce572a150..c4ac6e69a6d 100644 --- a/src/realm/inst_layout.inl +++ b/src/realm/inst_layout.inl @@ -220,7 +220,7 @@ namespace Realm { size_t stride = gsize; for(int i = 0; i < N; i++) { const int dim = dim_order[i]; - assert((0 <= dim) && (dim < N)); + REALM_ASSERT((0 <= dim) && (dim < N)); piece->strides[dim] = stride; piece->offset -= bloated.lo[dim] * stride; stride *= (bloated.hi[dim] - bloated.lo[dim] + 1); @@ -241,7 +241,7 @@ namespace Realm { for(std::map::const_iterator it2 = field_offsets.begin(); it2 != field_offsets.end(); ++it2) { // should not have seen this field before - assert(layout->fields.count(it2->first) == 0); + REALM_ASSERT(layout->fields.count(it2->first) == 0); InstanceLayoutGeneric::FieldLayout &fl = layout->fields[it2->first]; fl.list_idx = li; fl.rel_offset = /*group_offset +*/ it2->second + reuse_offset; @@ -582,10 +582,10 @@ namespace Realm { { // first look up the field to see which piece list it uses (and get offset) FieldMap::const_iterator it = fields.find(fid); - assert(it != fields.end()); + REALM_ASSERT(it != fields.end()); const InstanceLayoutPiece *ilp = piece_lists[it->second.list_idx].find_piece(p); - assert(ilp != 0); + REALM_ASSERT(ilp != 0); size_t offset = ilp->calculate_offset(p); // add in field's offset offset += it->second.rel_offset; @@ -768,7 +768,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); this->piece_list = &layout->piece_lists[it->second.list_idx]; this->rel_offset = it->second.rel_offset + subfield_offset; @@ -787,7 +787,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); this->piece_list = &layout->piece_lists[it->second.list_idx]; this->rel_offset = it->second.rel_offset + subfield_offset; @@ -862,7 +862,7 @@ namespace Realm { const InstanceLayoutPiece *mypiece = prev_piece; if(!mypiece || !mypiece->bounds.contains(p)) { mypiece = piece_list->find_piece(p); - assert(mypiece); + REALM_ASSERT(mypiece); prev_piece = mypiece; } size_t offset = mypiece->calculate_offset(p); @@ -910,7 +910,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); const InstancePieceList &ipl = layout->piece_lists[it->second.list_idx]; // Special case for empty instances @@ -922,13 +922,13 @@ namespace Realm { } // this constructor only works if there's exactly one piece and it's affine - assert(ipl.pieces.size() == 1); + REALM_ASSERT(ipl.pieces.size() == 1); const InstanceLayoutPiece *ilp = ipl.pieces[0]; - assert((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); + REALM_ASSERT((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); const AffineLayoutPiece *alp = static_cast *>(ilp); base = reinterpret_cast(inst.pointer_untyped(0, layout->bytes_used)); - assert(base != 0); + REALM_ASSERT(base != 0); base += alp->offset + it->second.rel_offset + subfield_offset; strides = alp->strides; #if defined(REALM_ACCESSOR_DEBUG) || defined(REALM_USE_KOKKOS) @@ -959,7 +959,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); const InstancePieceList &ipl = layout->piece_lists[it->second.list_idx]; // special case for empty regions @@ -971,12 +971,12 @@ namespace Realm { // find the piece that holds the lo corner of the subrect and insist it // exists, covers the whole subrect, and is affine const InstanceLayoutPiece *ilp = ipl.find_piece(subrect.lo); - assert(ilp && ilp->bounds.contains(subrect)); - assert((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); + REALM_ASSERT(ilp && ilp->bounds.contains(subrect)); + REALM_ASSERT((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); const AffineLayoutPiece *alp = static_cast *>(ilp); base = reinterpret_cast(inst.pointer_untyped(0, layout->bytes_used)); - assert(base != 0); + REALM_ASSERT(base != 0); base += alp->offset + it->second.rel_offset + subfield_offset; strides = alp->strides; } @@ -1015,7 +1015,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); const InstancePieceList &ipl = layout->piece_lists[it->second.list_idx]; // Special case for empty instances @@ -1027,13 +1027,13 @@ namespace Realm { } // this constructor only works if there's exactly one piece and it's affine - assert(ipl.pieces.size() == 1); + REALM_ASSERT(ipl.pieces.size() == 1); const InstanceLayoutPiece *ilp = ipl.pieces[0]; - assert((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); + REALM_ASSERT((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); const AffineLayoutPiece *alp = static_cast *>(ilp); base = reinterpret_cast(inst.pointer_untyped(0, layout->bytes_used)); - assert(base != 0); + REALM_ASSERT(base != 0); base += alp->offset + it->second.rel_offset + subfield_offset; // to get the effect of transforming every accessed x to Ax+b, we // add strides.b to the offset and left-multiply s'*A to get strides @@ -1082,7 +1082,7 @@ namespace Realm { const InstanceLayout *layout = checked_cast *>(inst.get_layout()); InstanceLayoutGeneric::FieldMap::const_iterator it = layout->fields.find(field_id); - assert(it != layout->fields.end()); + REALM_ASSERT(it != layout->fields.end()); const InstancePieceList &ipl = layout->piece_lists[it->second.list_idx]; // special case for empty regions @@ -1099,12 +1099,12 @@ namespace Realm { // find the piece that holds the lo corner of the subrect and insist it // exists, covers the whole subrect, and is affine const InstanceLayoutPiece *ilp = ipl.find_piece(subrect_image.lo); - assert(ilp && ilp->bounds.contains(subrect_image)); - assert((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); + REALM_ASSERT(ilp && ilp->bounds.contains(subrect_image)); + REALM_ASSERT((ilp->layout_type == PieceLayoutTypes::AffineLayoutType)); const AffineLayoutPiece *alp = static_cast *>(ilp); base = reinterpret_cast(inst.pointer_untyped(0, layout->bytes_used)); - assert(base != 0); + REALM_ASSERT(base != 0); base += alp->offset + it->second.rel_offset + subfield_offset; // to get the effect of transforming every accessed x to Ax+b, we // add strides.b to the offset and left-multiply s'*A to get strides @@ -1419,7 +1419,7 @@ namespace Realm { kls.dimension[i] = ((bounds.hi[i] >= bounds.lo[i]) ? (bounds.hi[i] - bounds.lo[i] + 1) : 0); kls.stride[i] = strides[i] / sizeof(FT); - assert((size_t(kls.stride[i]) * sizeof(FT)) == size_t(strides[i])); + REALM_ASSERT((size_t(kls.stride[i]) * sizeof(FT)) == size_t(strides[i])); } typedef Kokkos::View::data_type, Kokkos::LayoutStride, @@ -1474,7 +1474,7 @@ namespace Realm { kls.dimension[i] = ((bounds.hi[i] >= bounds.lo[i]) ? (bounds.hi[i] - bounds.lo[i] + 1) : 0); kls.stride[i] = strides[i] / sizeof(FT); - assert((size_t(kls.stride[i]) * sizeof(FT)) == size_t(strides[i])); + REALM_ASSERT((size_t(kls.stride[i]) * sizeof(FT)) == size_t(strides[i])); } typedef Kokkos::View::data_type, Kokkos::LayoutStride, @@ -1601,7 +1601,7 @@ namespace Realm { { unsigned allowed_mask = (PieceLookup::ALLOW_AFFINE_PIECE | PieceLookup::ALLOW_SPLIT1); start_inst = inst.get_lookup_program(field_id, allowed_mask, field_offset); - assert(start_inst != 0); + REALM_ASSERT(start_inst != 0); // special case: if the first instruction is an AffinePiece and there's // no next instruction, we cache the answer and forget the program @@ -1632,7 +1632,7 @@ namespace Realm { unsigned allowed_mask = (PieceLookup::ALLOW_AFFINE_PIECE | PieceLookup::ALLOW_SPLIT1); start_inst = inst.get_lookup_program(field_id, subrect, allowed_mask, field_offset); - assert(start_inst != 0); + REALM_ASSERT(start_inst != 0); // special case: if the first instruction is an AffinePiece and there's // either no next instruction or the piece we've got covers the entire @@ -1670,7 +1670,7 @@ namespace Realm { const PieceLookup::Instruction *i = start_inst; while(true) { #ifdef DEBUG_REALM - assert(i != 0); + REALM_ASSERT(i != 0); #endif if(i->opcode() == PieceLookup::Opcodes::OP_AFFINE_PIECE) { const PieceLookup::AffinePiece *ap = @@ -1684,7 +1684,7 @@ namespace Realm { } else i = ap->next(); } else { - assert(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); + REALM_ASSERT(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); i = static_cast *>(i)->next(p); } } @@ -1708,7 +1708,7 @@ namespace Realm { const PieceLookup::Instruction *i = start_inst; while(true) { #ifdef DEBUG_REALM - assert(i != 0); + REALM_ASSERT(i != 0); #endif if(i->opcode() == PieceLookup::Opcodes::OP_AFFINE_PIECE) { const PieceLookup::AffinePiece *ap = @@ -1724,7 +1724,7 @@ namespace Realm { } else i = ap->next(); } else { - assert(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); + REALM_ASSERT(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); const PieceLookup::SplitPlane *sp = static_cast *>(i); if(sp->splits_rect(r)) @@ -1763,7 +1763,7 @@ namespace Realm { while(true) { #ifdef DEBUG_REALM #ifndef __HIP_DEVICE_COMPILE__ - assert(i != 0); + REALM_ASSERT(i != 0); #endif #endif if(i->opcode() == PieceLookup::Opcodes::OP_AFFINE_PIECE) { @@ -1780,7 +1780,7 @@ namespace Realm { i = ap->next(); } else { #ifndef __HIP_DEVICE_COMPILE__ - assert(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); + REALM_ASSERT(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); #endif i = static_cast *>(i)->next(p); } @@ -1802,7 +1802,7 @@ namespace Realm { const PieceLookup::Instruction *i = start_inst; while(true) { #ifdef DEBUG_REALM - assert(i != 0); + REALM_ASSERT(i != 0); #endif if(i->opcode() == PieceLookup::Opcodes::OP_AFFINE_PIECE) { const PieceLookup::AffinePiece *ap = @@ -1817,7 +1817,7 @@ namespace Realm { } else i = ap->next(); } else { - assert(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); + REALM_ASSERT(i->opcode() == PieceLookup::Opcodes::OP_SPLIT1); const PieceLookup::SplitPlane *sp = static_cast *>(i); if(sp->splits_rect(r)) From 86030339255b9c7eadc6ba0e29e193a9bb886ded Mon Sep 17 00:00:00 2001 From: Wei Wu Date: Fri, 7 Nov 2025 00:37:35 -0800 Subject: [PATCH 4/4] checkpoint --- src/realm/logging.cc | 13 +++++-------- src/realm/logging.inl | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/realm/logging.cc b/src/realm/logging.cc index 0c10242733f..51c10a14460 100644 --- a/src/realm/logging.cc +++ b/src/realm/logging.cc @@ -129,11 +129,8 @@ namespace Realm { virtual void write(const char *buffer, size_t len) { AutoLock<> al(mutex); -#ifndef NDEBUG - size_t amt = -#endif - fwrite(buffer, 1, len, f); - assert(amt == len); + size_t amt = fwrite(buffer, 1, len, f); + REALM_ASSERT(amt == len); } FILE *f; @@ -402,14 +399,14 @@ namespace Realm { void LoggerConfig::set_default_output(LoggerOutputStream *s) { // must be called before command line is parsed - assert(!cmdline_read); + REALM_ASSERT(!cmdline_read); default_output = s; } void LoggerConfig::set_logger_output(const std::string &name, LoggerOutputStream *s) { // must be called before command line is read - assert(!cmdline_read); + REALM_ASSERT(!cmdline_read); logger_output[name] = s; } @@ -566,7 +563,7 @@ namespace Realm { if(!configured) { size_t bytes = sizeof(DelayedMessage) + msglen; void *ptr = ::operator new(bytes); - assert(ptr != 0); + REALM_ASSERT(ptr != 0); DelayedMessage *d = new(ptr) DelayedMessage; d->next_msg = 0; d->level = level; diff --git a/src/realm/logging.inl b/src/realm/logging.inl index df58977489c..8a14c8fc96f 100644 --- a/src/realm/logging.inl +++ b/src/realm/logging.inl @@ -400,7 +400,7 @@ namespace Realm { inline std::ostream &LoggerMessage::get_stream(void) { #ifdef DEBUG_REALM - assert(active); + REALM_ASSERT(active); #endif return *stream; }