runtime/realm/mem_impl.cc
// adds a new instance to this memory, to be filled in by caller
adds a new instance to this memory, to be filled in by caller
adds a new instance to this memory to be filled in by caller
RegionInstanceImpl *MemoryImpl::new_instance(void)
    {
      unsigned inst_idx;
      RegionInstanceImpl *inst_impl;
      {
	AutoLock<> al(local_instances.mutex);
	if(local_instances.free_list.empty()) {
	  const size_t chunk_size = 8;
	  size_t old_size = local_instances.instances.size();
	  size_t new_size = old_size + chunk_size;
	  if(new_size > (1 << ID::INSTANCE_INDEX_WIDTH)) {
	    new_size = (1 << ID::INSTANCE_INDEX_WIDTH);
	    if(old_size == new_size) {
	      return 0;
	    }
	  }
	  local_instances.instances.resize(new_size, 0);
	  local_instances.free_list.resize(chunk_size - 1);
	  for(size_t i = 0; i < chunk_size - 1; i++)
	    local_instances.free_list[i] = new_size - 1 - i;
	  inst_idx = old_size;
	  inst_impl = 0;
	} else {
	  inst_idx = local_instances.free_list.back();
	  local_instances.free_list.pop_back();
	  inst_impl = local_instances.instances[inst_idx];
	}
      }
      if(!inst_impl) {
	ID mem_id(me);
	RegionInstance i = ID::make_instance(mem_id.memory_owner_node(),
					     Network::my_node_id ,
					     mem_id.memory_mem_idx(),
					     inst_idx).convert<RegionInstance>();
	log_inst.info() << "creating new local instance: " << i;
	inst_impl = new RegionInstanceImpl(i, me);
	{
	  AutoLock<> al(local_instances.mutex);
	  local_instances.instances[inst_idx] = inst_impl;
	}
      } else
	log_inst.info() << "reusing local instance: " << inst_impl->me;
      return inst_impl;
    }
RegionInstanceImpl * MemoryImpl :: new_instance ( void ) { unsigned inst_idx ; RegionInstanceImpl * inst_impl ; { AutoLock < > al ( local_instances . mutex ) ; if ( local_instances . free_list . empty ( ) ) { const size_t chunk_size = 8 ; size_t old_size = local_instances . instances . size ( ) ; size_t new_size = old_size + chunk_size ; if ( new_size > ( 1 << ID :: INSTANCE_INDEX_WIDTH ) ) { new_size = ( 1 << ID :: INSTANCE_INDEX_WIDTH ) ; if ( old_size == new_size ) { return 0 ; } } local_instances . instances . resize ( new_size , 0 ) ; local_instances . free_list . resize ( chunk_size - 1 ) ; for ( size_t i = 0 ; i < chunk_size - 1 ; i ++ ) local_instances . free_list [ i ] = new_size - 1 - i ; inst_idx = old_size ; inst_impl = 0 ; } else { inst_idx = local_instances . free_list . back ( ) ; local_instances . free_list . pop_back ( ) ; inst_impl = local_instances . instances [ inst_idx ] ; } } if ( ! inst_impl ) { ID mem_id ( me ) ; RegionInstance i = ID :: make_instance ( mem_id . memory_owner_node ( ) , Network :: my_node_id , mem_id . memory_mem_idx ( ) , inst_idx ) . convert < RegionInstance > ( ) ; log_inst . info ( ) << " " << i ; inst_impl = new RegionInstanceImpl ( i , me ) ; { AutoLock < > al ( local_instances . mutex ) ; local_instances . instances [ inst_idx ] = inst_impl ; } } else log_inst . info ( ) << " " << inst_impl -> me ; return inst_impl ; }
adds a new instance to this memory, to be filled in by caller
adds a new instance to this memory to be filled in by caller
// selecting a slot requires holding the mutex // need to grow the list - do it in chunks // completely out of slots - nothing we can do // we've got a slot and possibly an object to reuse - if not, allocate //  it now (only retaking the lock to add it back to the list) /*creator*/