Esempio n. 1
0
/**
 * @brief If there are any openings in the posted_sends queue, start sends
 * for events in the outgoing queue.
 *
 * @param[in] me pointer to the PE
 * @return 0 if no changes are made to the posted_sends queue, 1 otherwise.
 */
static int
send_begin(tw_pe *me)
{
  int changed = 0;

  while (posted_sends.cur < send_buffer)
    {
      tw_event *e = tw_eventq_peek(&outq);
      tw_peid dest_pe;

      unsigned id = posted_sends.cur;

      if (!e)
	break;

      if(e == me->abort_event)
	tw_error(TW_LOC, "Sending abort event!");

      dest_pe = (*e->src_lp->type->map) ((tw_lpid) e->dest_lp);

      e->send_pe = (tw_peid) g_tw_mynode;
      e->send_lp = e->src_lp->gid;

      if (MPI_Isend(e,
		    (int)EVENT_SIZE(e),
		    MPI_BYTE,
		    (int)dest_pe,
		    EVENT_TAG,
		    MPI_COMM_ROSS,
		    &posted_sends.req_list[id]) != MPI_SUCCESS) {
	return changed;
      }

      tw_eventq_pop(&outq);
      e->state.owner = e->state.cancel_q
	? TW_net_acancel
	: TW_net_asend;

      posted_sends.event_list[id] = e;
      posted_sends.cur++;
      me->s_nwhite_sent++;

      changed = 1;
    }
  return changed;
}
Esempio n. 2
0
static int
send_begin(tw_pe *me)
{
  int changed = 0;

  while (posted_sends.cur < send_buffer)
    {
      tw_event *e = tw_eventq_peek(&outq);
      tw_node	*dest_node = NULL;

      unsigned id = posted_sends.cur;

#if ROSS_MEMORY
      tw_event *tmp_prev = NULL;

      tw_lp *tmp_lp = NULL;

      tw_memory *memory = NULL;
      tw_memory *m = NULL;

      char *buffer = NULL;

      size_t mem_size = 0;

      unsigned position = 0;
#endif

      if (!e)
	break;

      if(e == me->abort_event)
	tw_error(TW_LOC, "Sending abort event!");

      dest_node = tw_net_onnode((*e->src_lp->type->map)
				((tw_lpid) e->dest_lp));

      //if(!e->state.cancel_q)
	//e->event_id = (tw_eventid) ++me->seq_num;

      e->send_pe = (tw_peid) g_tw_mynode;
      e->send_lp = e->src_lp->gid;

#if ROSS_MEMORY
      // pack pointers
      tmp_prev = e->prev;
      tmp_lp = e->src_lp;

      // delete when working
      e->src_lp = NULL;

      memory = NULL;
      if(e->memory)
	{
	  memory = e->memory;
	  e->memory = (tw_memory *) tw_memory_getsize(me, memory->fd);
	  e->prev = (tw_event *) memory->fd;
	  mem_size = (size_t) e->memory;
	}

      buffer = posted_sends.buffers[id];
      memcpy(&buffer[position], e, g_tw_event_msg_sz);
      position += g_tw_event_msg_sz;

      // restore pointers
      e->prev = tmp_prev;
      e->src_lp = tmp_lp;

      m = NULL;
      while(memory)
	{
	  m = memory->next;

	  if(m)
	    {
	      memory->next = (tw_memory *)
		tw_memory_getsize(me, m->fd);
	      memory->fd = m->fd;
	    }

	  if(position + mem_size > TW_MEMORY_BUFFER_SIZE)
	    tw_error(TW_LOC, "Out of buffer space!");

	  memcpy(&buffer[position], memory, mem_size);
	  position += mem_size;

	  memory->nrefs--;
	  tw_memory_unshift(e->src_lp, memory, memory->fd);

	  if(NULL != (memory = m))
	    mem_size = tw_memory_getsize(me, memory->fd);
	}

      e->memory = NULL;

      if (MPI_Isend(buffer,
		    EVENT_SIZE(e),
		    MPI_BYTE,
		    *dest_node,
		    EVENT_TAG,
		    MPI_COMM_ROSS,
		    &posted_sends.req_list[id]) != MPI_SUCCESS) {
	return changed;
      }
#else
      if (MPI_Isend(e,
		    (int)EVENT_SIZE(e),
		    MPI_BYTE,
		    (int)*dest_node,
		    EVENT_TAG,
		    MPI_COMM_ROSS,
		    &posted_sends.req_list[id]) != MPI_SUCCESS) {
	return changed;
      }
#endif

      tw_eventq_pop(&outq);
      e->state.owner = e->state.cancel_q
	? TW_net_acancel
	: TW_net_asend;

      posted_sends.event_list[id] = e;
      posted_sends.cur++;
      me->s_nwhite_sent++;

      changed = 1;
    }
  return changed;
}