Example #1
0
void mpi_replyhandler(gasnet_token_t token, harg_t tid) {
  int ltid = tid - gasnet_mynode()*threads_num;
  PRINT_AM(("node=%2d> Got AMShort MPI Reply for tid=%d\n",
                        (int)gasnet_mynode(), (int)tid));
  assert(tt_thread_map[tid] == gasnet_mynode());
  tt_thread_data[ltid].flag = 0;
}
Example #2
0
void mpi_handler(gasnet_token_t token, harg_t tid, harg_t sz) {
  gasnet_node_t   node;
  int mpipeer;
  int tag;
  char *buf;
  gasnet_AMGetMsgSource(token, &node);

  PRINT_AM(("node=%2d> AMShort MPI Request for tid=%i, nbytes=%i\n",
            (int)gasnet_mynode(), (int)tid, (int)sz));
  assert(tt_thread_map[tid] == node);
  assert(sz > 0);
  mpipeer = gasnetnode_to_mpirank[node];
  tag = tid;
  buf = (char*)test_malloc(sz);

  MPI_LOCK();

    assert(mpi_buf[tid] == NULL);
    assert(mpi_recvhandle[tid] == MPI_REQUEST_NULL);
    assert(mpi_sendhandle[tid] == MPI_REQUEST_NULL);
    mpi_buf[tid] = buf;
    mpi_bufsz[tid] = sz;

    ACTION_PRINTF("node=%2d> setting MPI_Irecv, %i bytes\n", (int)gasnet_mynode(), (int)sz);
    MPI_SAFE(MPI_Irecv(mpi_buf[tid], sz, MPI_BYTE, mpipeer, tag, MPI_COMM_WORLD, &(mpi_recvhandle[tid])));
    assert(mpi_recvhandle[tid] != MPI_REQUEST_NULL);
          
  MPI_UNLOCK();

}
Example #3
0
void 
pong_shorthandler(gasnet_token_t token, harg_t idx) 
{
	int	tid = tt_thread_data[idx].tid;
	PRINT_AM(("node=%2d> AMShort Reply for tid=%d, (%d,%d)", 
			(int)gasnet_mynode(), tid, (int)gasnet_mynode(), (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(tid >= 0 && tid < threads_num*gasnet_nodes());
	tt_thread_data[idx].flag++;
}
Example #4
0
void 
ping_shorthandler(gasnet_token_t token, harg_t idx) 
{
	gasnet_node_t	node;
	gasnet_AMGetMsgSource(token, &node);

	PRINT_AM(("node=%2d> AMShort Request for (%d,%d)", 
			(int)gasnet_mynode(), (int)node, (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(node < gasnet_nodes());
	GASNET_Safe(gasnet_AMReplyShort1(token, hidx_pong_shorthandler, idx));
}
Example #5
0
void 
pong_longhandler(gasnet_token_t token, void *buf, size_t nbytes, harg_t idx) {
	int	tid = tt_thread_data[idx].tid;

	PRINT_AM(("node=%2d> AMLong Reply for tid=%d, (%d,%d)", 
			(int)gasnet_mynode(), tid, (int)gasnet_mynode(), (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(tid >= 0 && tid < threads_num*gasnet_nodes());
        assert(nbytes <= gasnet_AMMaxLongReply());
        assert(buf == tt_addr_map[gasnet_mynode() * threads_num + idx]);
        assert((uintptr_t)buf + nbytes <= (uintptr_t)TEST_SEG(gasnet_mynode()) + TEST_SEGSZ);
	tt_thread_data[idx].flag++;
}
Example #6
0
void 
pong_medhandler(gasnet_token_t token, void *buf, size_t nbytes, 
		gasnet_handlerarg_t idx) 
{
	int	tid = tt_thread_data[idx].tid;

	PRINT_AM(("node=%2d> AMMedium Reply for tid=%d, (%d,%d)", 
			(int)gasnet_mynode(), tid, (int)gasnet_mynode(), (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(tid >= 0 && tid < threads_num*gasnet_nodes());
        assert(nbytes <= gasnet_AMMaxMedium());
        assert((uintptr_t)buf+nbytes < (uintptr_t)TEST_SEG(gasnet_mynode()) ||
               (uintptr_t)buf >= (uintptr_t)TEST_SEG(gasnet_mynode()) + TEST_SEGSZ);
	tt_thread_data[idx].flag++;
}
Example #7
0
void mpi_probehandler(gasnet_token_t token, harg_t tid) {
  gasnet_node_t   node;
  int mpipeer;
  int tag;
  int reply = 0;
  gasnet_AMGetMsgSource(token, &node);
  assert(tt_thread_map[tid] == node);
  mpipeer = gasnetnode_to_mpirank[node];
  tag = tid;

  MPI_LOCK();
    if (mpi_recvhandle[tid] != MPI_REQUEST_NULL) {
      MPI_Status status;
      int flag = 0;
      MPI_SAFE(MPI_Test(&mpi_recvhandle[tid],&flag,&status));
      if (flag) {
        int sz = mpi_bufsz[tid];
        assert(mpi_recvhandle[tid] == MPI_REQUEST_NULL);
        assert(mpi_sendhandle[tid] == MPI_REQUEST_NULL);
        assert(mpi_buf[tid] != NULL && sz >= 0);
        ACTION_PRINTF("node=%2d> sending MPI reply message, %i bytes\n", (int)gasnet_mynode(), sz);
        MPI_SAFE(MPI_Isend(mpi_buf[tid], sz, MPI_BYTE, mpipeer, 10000+tag, MPI_COMM_WORLD, &(mpi_sendhandle[tid])));
        assert(mpi_sendhandle[tid] != MPI_REQUEST_NULL);
      } 
    } else if (mpi_sendhandle[tid] != MPI_REQUEST_NULL) {
      MPI_Status status;
      int flag = 0;
      MPI_SAFE(MPI_Test(&mpi_sendhandle[tid],&flag,&status));
      if (flag) {
        assert(mpi_recvhandle[tid] == MPI_REQUEST_NULL);
        assert(mpi_sendhandle[tid] == MPI_REQUEST_NULL);
        reply = 1;
      }
    } else {
      /* nothing to do */ 
    }
  MPI_UNLOCK();

  if (reply) {
    assert(mpi_buf[tid] != NULL);
    test_free(mpi_buf[tid]);
    mpi_buf[tid] = NULL;
    PRINT_AM(("node=%2d> Sending AMShort MPI Reply for tid=%i\n",
            (int)gasnet_mynode(), (int)tid));
    GASNET_Safe(gasnet_AMReplyShort1(token, hidx_mpi_replyhandler, tid));
  }
}
Example #8
0
void 
ping_medhandler(gasnet_token_t token, void *buf, size_t nbytes, harg_t idx) 
{
	gasnet_node_t	node;
	gasnet_AMGetMsgSource(token, &node);

	PRINT_AM(("node=%2d> AMMedium Request for (%d,%d)", 
			(int)gasnet_mynode(), (int)node, (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(node < gasnet_nodes());
        assert(nbytes <= gasnet_AMMaxMedium());
        assert((uintptr_t)buf+nbytes < (uintptr_t)TEST_SEG(gasnet_mynode()) ||
               (uintptr_t)buf >= (uintptr_t)TEST_SEG(gasnet_mynode()) + TEST_SEGSZ);
	GASNET_Safe(
		gasnet_AMReplyMedium1(token, hidx_pong_medhandler, 
			buf, nbytes, idx));
}
Example #9
0
void 
ping_longhandler(gasnet_token_t token, void *buf, size_t nbytes, harg_t idx, harg_t target_id) 
{
	int		tid;
	void		*paddr;
	gasnet_node_t	node;

	gasnet_AMGetMsgSource(token, &node);
	tid = node * threads_num + idx;
	paddr = tt_addr_map[tid];

	PRINT_AM(("node=%2d> AMLong Request for (%d,%d)", 
			(int)gasnet_mynode(), (int)node, (int)idx));
        assert(idx >= 0 && idx < threads_num);
        assert(node < gasnet_nodes());
        assert(nbytes <= gasnet_AMMaxLongRequest());
        assert(buf == tt_addr_map[target_id]);
        assert((uintptr_t)buf + nbytes <= (uintptr_t)TEST_SEG(gasnet_mynode()) + TEST_SEGSZ);
	GASNET_Safe(
		gasnet_AMReplyLong1(token, hidx_pong_longhandler, 
			buf, nbytes, paddr, idx));
}