Пример #1
0
smi_error_t _smi_copy_globally_distributed_to_local(int global_region_id,
        int local_region_id)
{
    DSECTION("_smi_copy_globally_distributed_to_local");
    smi_error_t error;
    size_t       i, j, k;							   /* loop counters                      */
    smi_rlayout_t* distributed_layout;               /* description of the detailed memory */
    smi_rlayout_t* local_layout;                     /* layout of the two regions          */
    void*      own_global_segment_start = NULL;  /* start address and size of a segment*/
    size_t     own_global_segment_size = 0;      /* and it's size of the entire copy   */
    void*      other_global_segment_start = NULL;/* proceedure; once for the own source*/
    size_t     other_global_segment_size = 0;    /* segment, once for the remote       */
    /* source segment                     */
    double*       ptr;                              /* tmp var                            */
    int           other_machine_rank;
    size_t        no_iterations;                 /* specifies how many                 */
    /* SMI_COPY_BUFFER_SIZE-byte blocks   */
    /* the largest segment of the distrib.*/
    /* region contains                    */
    int tmp_machine, tmp_proc;
    size_t act_inner_iterations;
    size_t remaining_bytes;
    size_t tmp_it;

    double* tmp_ptr;
    size_t no_inner_iterations = SMI_COPY_BUFFER_SIZE/sizeof(double);
    double* s;
    double* d;

    DSECTENTRYPOINT;

    /* _smi_allocate buffer space, if not already done */
    if (buffer__smi_allocated == false)
    {
        buffer__smi_allocated = true;

        error = SMI_Init_PC(&progress_counter);
        ASSERT_R((error==SMI_SUCCESS),"Could not init progress-counter",error);

        ALLOCATE( buffer,  double**, _smi_nbr_machines * sizeof(double*) );
        for(i=0; i<(size_t)_smi_nbr_machines; i++)
        {
            tmp_proc = _smi_first_proc_on_node((int) i);
            error = SMI_Cmalloc(SMI_COPY_BUFFER_SIZE, tmp_proc|INTERNAL,
                                (char**)(&(buffer[i])));
            ASSERT_R((error==SMI_SUCCESS),"Could not allocate memory",error);
        }
    }
Пример #2
0
bool EventFsm::AddNewEvent(BaseEvent *pevent)
{
	ASSERT_R(pevent, false);
	
	std::pair<NewEventsT::iterator, bool> res = new_evs_.insert(NewEventsT::value_type(pevent->GetFd(), pevent));
	if (!res.second)
		return false;
	return true;
}
Пример #3
0
smi_error_t SMI_Get_node_name (char *nodename, size_t *namelen)
{
  DSECTION("SMI_Get_node_name");
  int iError;
  char szHostName[MAXHOSTNAMELEN];

  ASSERT_R((nodename != NULL), "illegal parameter for nodename", SMI_ERR_PARAM);
  ASSERT_R((namelen != NULL), "illegal parameter for namelen", SMI_ERR_PARAM);
  ASSERT_R(((*namelen) > 0), "illegal parameter for *namelen", SMI_ERR_PARAM);

  iError = _smi_tcp_init();
  ASSERT_R((iError == 0),"could not init tcp", SMI_ERR_OTHER);

  iError = gethostname(szHostName, MAXHOSTNAMELEN);
  ASSERT_R((iError == 0),"gethostname failed", SMI_ERR_OTHER);

  if ( strlen(szHostName) >= (*namelen) ) {
    DPROBLEM("insufficient space is provided for hostname");
    DSECTLEAVE
      return(SMI_ERR_OTHER);
  }
Пример #4
0
smi_error_t SMI_Redirect_IO(int err, void* errparam, 
			int out, void* outparam, 
			int in, void* inparam)
{
  DSECTION(" SMI_Redirect_IO");
  char filename[256];
  
  DSECTENTRYPOINT;

  ASSERT_R((_smi_initialized==true),"SMI not initialized",SMI_ERR_NOINIT);
  
  /* It is just allowed to call this function once. */
  /* If it is called multiple times, we just return */
  if (smi_already_redirected != 0) {
    DNOTICE("Output is already redirected");
    DSECTLEAVE
      return(SMI_SUCCESS);
  }  
Пример #5
0
smi_error_t  SMI_Iget (void *dst, int src_region_id, int offset, size_t size, smi_memcpy_handle* pHandle)
{
    DSECTION("SMI_Iput");
    memtype_t mtLocalRegion = _smi_detect_memtype(dst);
    memtype_t mtRemoteRegion = _smi_detect_memtype_rdma(src_region_id);
    smi_memcpy_handle h;    
    char *reg_addr;
    size_t is_misaligned = 0;
    smi_error_t error;
    
#ifndef DOLPHIN_SISCI
    DPROBLEM("DMA only supported by Dolphin's SISCI");
    DSECTLEAVE;
    return SMI_ERR_NOTIMPL;
#else
    
    if ((mtLocalRegion != mt_lsown) && (mtLocalRegion != mt_ls)) {
	DPROBLEM("src must be an local segment");
	DSECTLEAVE;
	return(SMI_ERR_PARAM);
    }
    
    ASSERT_R((mtRemoteRegion == mt_rs),"dest must be an remote segment",SMI_ERR_PARAM);
    
    /* Check alignments. If the operation is peformed on a mapped region (which thus has
       an address, we can use SMI_Imemcpy() in case of a misalignemt. */
    if ((is_misaligned = size % _smi_dma_size_alignment) != 0) {
	DPROBLEMI("misaligned size:", size);
    } else {
	if ((is_misaligned = (size_t)dst % _smi_dma_offset_alignment) != 0) {
	    DPROBLEMP("misaligned destination address:", dst);
	} else {
	    if ((is_misaligned = (size_t)offset % _smi_dma_offset_alignment) != 0) {
		DPROBLEMI("misaligned source offset:", offset);
	    }
	}
    }
    if (is_misaligned) {
	reg_addr = _smi_get_region_address(src_region_id);
	if (reg_addr == NULL) {
	    /* no way to transfer data */
	    DPROBLEM ("destination region is not mapped -> no way to work around misalignment"); 
	    DSECTLEAVE; return (SMI_ERR_BADALIGN);
	} else {
	    DPROBLEM ("destination region is not mapped -> using SMI_Imemcpy to cope with misalignment"); 
	    DSECTLEAVE; return SMI_Imemcpy (dst, reg_addr + offset, size, 0, pHandle);
	}
    }
    
    _smi_mc_handle_lock();
    h = *pHandle;
    
    if (_smi_mc_dma_enabled() == FALSE) {
	DNOTICE("DMA-read not implemented by Dolphin`s SISCI");
	if (!((h->dma_used==TRUE)&&(h->dma_entries>0)))
	    _smi_mc_destroy_handle(h);
	_smi_mc_handle_unlock();
	DSECTLEAVE; return SMI_ERR_NOTIMPL;
    }
    
    if ( (h!=NULL) && (h->otid == SMI_MEMCPY_HANDLE_OTID) ) {
	if (*(h->pHandle) != *pHandle) {
	    DPROBLEM("Not a valid handle");      
	    _smi_mc_handle_unlock();
	    DSECTLEAVE; return SMI_ERR_PARAM;
	}
	DNOTICE("The Handle already exists!");
	if ( (h->dma_used == TRUE) && (h->dma_entries > 0)) {
	    DNOTICE("The handle contains an nonposted queue");
	}
	else {
	    DPROBLEM("The handle is in use");      
	    _smi_mc_handle_unlock();
	    DSECTLEAVE; return SMI_ERR_PARAM;
	}
    }
    else {
	h = _smi_mc_create_handle(pHandle);
	if (h == NULL) { 
	  DPROBLEM ("Could not get memory for memcpy-handle");
	  _smi_mc_handle_unlock();
	  DSECTLEAVE; return SMI_ERR_NOMEM;
	}
	h->mc_flags = 0;
    }

    error = _smi_dma_transfer(src_region_id, offset, dst, size, SCI_FLAG_DMA_READ, h);
    
    _smi_mc_handle_unlock();  
    DSECTLEAVE; return error;
#endif
}