runtime/realm/mem_impl.cc
// for internal use by allocation routines - must be called with
//  allocator_mutex held!
for internal use by allocation routines - must be called with
allocator_mutex held!
for internal use by allocation routines - must be called with allocator_mutex held!
MemoryImpl::AllocationResult MemoryImpl::attempt_deferrable_allocation(RegionInstanceImpl *inst,
									   size_t bytes,
									   size_t alignment,
									   size_t& inst_offset)
    {
      if(pending_allocs.empty()) {
	bool ok = current_allocator.allocate(inst->me,
					     bytes, alignment, inst_offset);
	if(ok) {
	  return ALLOC_INSTANT_SUCCESS;
	} else {
	  if(pending_releases.empty() ||
	     !Config::deferred_instance_allocation) {
	    return ALLOC_INSTANT_FAILURE;
	  } else {
	    future_allocator = current_allocator;
	    for(std::vector<PendingRelease>::iterator it = pending_releases.begin();
		it != pending_releases.end();
		++it) {
	      assert(!it->is_ready);
	      future_allocator.deallocate(it->inst->me, true );
	    }
	    bool ok = future_allocator.allocate(inst->me,
						bytes, alignment, inst_offset);
	    if(ok) {
	      pending_allocs.push_back(PendingAlloc(inst, bytes, alignment,
						    cur_release_seqid));
	      release_allocator = current_allocator;
	      return ALLOC_DEFERRED;
	    } else {
	      return ALLOC_INSTANT_FAILURE; 
	    }
	  }
	}
      } else {
	bool ok = future_allocator.allocate(inst->me,
					    bytes, alignment, inst_offset);
	if(ok) {
	  pending_allocs.push_back(PendingAlloc(inst, bytes, alignment,
						cur_release_seqid));
	  return ALLOC_DEFERRED;
	} else {
	  return ALLOC_INSTANT_FAILURE; 
	}
      }
    }
MemoryImpl :: AllocationResult MemoryImpl :: attempt_deferrable_allocation ( RegionInstanceImpl * inst , size_t bytes , size_t alignment , size_t & inst_offset ) { if ( pending_allocs . empty ( ) ) { bool ok = current_allocator . allocate ( inst -> me , bytes , alignment , inst_offset ) ; if ( ok ) { return ALLOC_INSTANT_SUCCESS ; } else { if ( pending_releases . empty ( ) || ! Config :: deferred_instance_allocation ) { return ALLOC_INSTANT_FAILURE ; } else { future_allocator = current_allocator ; for ( std :: vector < PendingRelease > :: iterator it = pending_releases . begin ( ) ; it != pending_releases . end ( ) ; ++ it ) { assert ( ! it -> is_ready ) ; future_allocator . deallocate ( it -> inst -> me , true ) ; } bool ok = future_allocator . allocate ( inst -> me , bytes , alignment , inst_offset ) ; if ( ok ) { pending_allocs . push_back ( PendingAlloc ( inst , bytes , alignment , cur_release_seqid ) ) ; release_allocator = current_allocator ; return ALLOC_DEFERRED ; } else { return ALLOC_INSTANT_FAILURE ; } } } } else { bool ok = future_allocator . allocate ( inst -> me , bytes , alignment , inst_offset ) ; if ( ok ) { pending_allocs . push_back ( PendingAlloc ( inst , bytes , alignment , cur_release_seqid ) ) ; return ALLOC_DEFERRED ; } else { return ALLOC_INSTANT_FAILURE ; } } }
for internal use by allocation routines - must be called with
allocator_mutex held!
for internal use by allocation routines - must be called with allocator_mutex held!
// as long as there aren't any pending allocations, we can attempt to //  satisfy the allocation based on the current state // doesn't currently fit - are there any pending deletes that //  might allow it to fit in the future? // also, check that deferred allocations are even permitted // nope - this allocation can't succeed based on what we know //  right now // build the future state based on those deletes and try again // shouldn't have any ready ones here // 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 //  (this is conservative, because it can only cause a //  false-failure of a future allocation) /*missing ok*/ // now that we have pending allocs, we need release_allocator //  to be valid /*immediate notification*/ // NOTE: future_allocator becomes invalid // with other pending allocs, we can only tentatively allocate based //  on future state /*immediate notification*/