runtime/realm/mem_impl.cc
// attempt to allocate storage for the specified instance
attempt to allocate storage for the specified instance
attempt to allocate storage for the specified instance
MemoryImpl::AllocationResult MemoryImpl::allocate_instance_storage(RegionInstance i,
							   size_t bytes,
							   size_t alignment,
							   Event precondition,
							   size_t offset )
    {
      NodeID target = ID(me).memory_owner_node();
      if(target != Network::my_node_id) {
	ActiveMessage<MemStorageAllocRequest> amsg(target);
	amsg->memory = me;
	amsg->inst = i;
	amsg->bytes = bytes;
	amsg->alignment = alignment;
	amsg->precondition = precondition;
	assert(offset==0);
	amsg.commit();
	return ALLOC_DEFERRED ;
      }
      RegionInstanceImpl *inst = get_instance(i);
      bool alloc_poisoned = false;
      if(precondition.has_triggered_faultaware(alloc_poisoned)) {
	if(alloc_poisoned) {
	  NodeID creator_node = ID(i).instance_creator_node();
	  if(creator_node == Network::my_node_id) {
	    inst->notify_allocation(ALLOC_CANCELLED,
				    RegionInstanceImpl::INSTOFFSET_FAILED);
	  } else {
	    inst->metadata.inst_offset = RegionInstanceImpl::INSTOFFSET_FAILED;
	    ActiveMessage<MemStorageAllocResponse> amsg(creator_node);
	    amsg->inst = i;
	    amsg->offset = RegionInstanceImpl::INSTOFFSET_FAILED;
	    amsg->result = ALLOC_CANCELLED;
	    amsg.commit();
	  }
	  return ALLOC_INSTANT_FAILURE;
	} else {
	}
      } else {
	inst->metadata.inst_offset = RegionInstanceImpl::INSTOFFSET_DELAYEDALLOC;
	inst->deferred_create.defer(inst, this, bytes, alignment, precondition);
	return ALLOC_DEFERRED ;
      }
      AllocationResult result;
      size_t inst_offset = offset;
      {
	AutoLock<> al(allocator_mutex);
	result = attempt_deferrable_allocation(inst, bytes, alignment,
					       inst_offset);
      }
      if(result != ALLOC_DEFERRED) {
	NodeID creator_node = ID(i).instance_creator_node();
	if(creator_node == Network::my_node_id) {
	  inst->notify_allocation(result, inst_offset);
	} else {
	  inst->metadata.inst_offset = ((result == ALLOC_INSTANT_SUCCESS) ?
					  inst_offset :
					  RegionInstanceImpl::INSTOFFSET_FAILED);
	  ActiveMessage<MemStorageAllocResponse> amsg(creator_node);
	  amsg->inst = i;
	  amsg->offset = inst_offset;
	  amsg->result = result;
	  amsg.commit();
	}
      }
      return result;
    }
MemoryImpl :: AllocationResult MemoryImpl :: allocate_instance_storage ( RegionInstance i , size_t bytes , size_t alignment , Event precondition , size_t offset ) { NodeID target = ID ( me ) . memory_owner_node ( ) ; if ( target != Network :: my_node_id ) { ActiveMessage < MemStorageAllocRequest > amsg ( target ) ; amsg -> memory = me ; amsg -> inst = i ; amsg -> bytes = bytes ; amsg -> alignment = alignment ; amsg -> precondition = precondition ; assert ( offset == 0 ) ; amsg . commit ( ) ; return ALLOC_DEFERRED ; } RegionInstanceImpl * inst = get_instance ( i ) ; bool alloc_poisoned = false ; if ( precondition . has_triggered_faultaware ( alloc_poisoned ) ) { if ( alloc_poisoned ) { NodeID creator_node = ID ( i ) . instance_creator_node ( ) ; if ( creator_node == Network :: my_node_id ) { inst -> notify_allocation ( ALLOC_CANCELLED , RegionInstanceImpl :: INSTOFFSET_FAILED ) ; } else { inst -> metadata . inst_offset = RegionInstanceImpl :: INSTOFFSET_FAILED ; ActiveMessage < MemStorageAllocResponse > amsg ( creator_node ) ; amsg -> inst = i ; amsg -> offset = RegionInstanceImpl :: INSTOFFSET_FAILED ; amsg -> result = ALLOC_CANCELLED ; amsg . commit ( ) ; } return ALLOC_INSTANT_FAILURE ; } else { } } else { inst -> metadata . inst_offset = RegionInstanceImpl :: INSTOFFSET_DELAYEDALLOC ; inst -> deferred_create . defer ( inst , this , bytes , alignment , precondition ) ; return ALLOC_DEFERRED ; } AllocationResult result ; size_t inst_offset = offset ; { AutoLock < > al ( allocator_mutex ) ; result = attempt_deferrable_allocation ( inst , bytes , alignment , inst_offset ) ; } if ( result != ALLOC_DEFERRED ) { NodeID creator_node = ID ( i ) . instance_creator_node ( ) ; if ( creator_node == Network :: my_node_id ) { inst -> notify_allocation ( result , inst_offset ) ; } else { inst -> metadata . inst_offset = ( ( result == ALLOC_INSTANT_SUCCESS ) ? inst_offset : RegionInstanceImpl :: INSTOFFSET_FAILED ) ; ActiveMessage < MemStorageAllocResponse > amsg ( creator_node ) ; amsg -> inst = i ; amsg -> offset = inst_offset ; amsg -> result = result ; amsg . commit ( ) ; } } return result ; }
attempt to allocate storage for the specified instance
attempt to allocate storage for the specified instance
/*=0*/ // all allocation requests are handled by the memory's owning node for //  now - local caching might be possible though /*asynchronous notification*/ // check precondition on allocation // a poisoned creation works a lot like a failed creation // local notification of result // we have to at least have the correct offset on our local //  instance impl (even if we don't have the rest of the metadata) // remote notification // attempt allocation below // defer allocation attempt /*asynchronous notification*/ // offer up (hopefully non-zero) offset for external allocations // local notification of result // we have to at least have the correct offset on our local //  instance impl (even if we don't have the rest of the metadata) // remote notification