Exemple #1
0
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT (gaspi_segment_create(0, _4GB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  const gaspi_size_t msgSize = 1;
  if(myrank == 0)
    {
      gaspi_rank_t n;
      for(n = 1; n < P; n++)
	EXPECT_TIMEOUT(gaspi_passive_send(0, 0, n, msgSize, 2000));
    }
  
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
/* Test that sends passive messages without blocking (GASPI_TEST) */
int
main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  gaspi_rank_t P, myrank;
  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  if( P < 2 )
    {
      return EXIT_SUCCESS;
    }

  ASSERT (gaspi_segment_create(0, _2MB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  const gaspi_size_t msgSize = 4;
  if( P > 1 )
    {
      
      if(myrank == 1)
	{
	  gaspi_rank_t n;
	  for(n = 0; n < P; n++)
	    {
	      if(n == myrank)
		continue;
	  
	      gaspi_return_t ret = GASPI_ERROR;
	      do
		{
		  ret = gaspi_passive_send(0, 0, n, msgSize, GASPI_TEST);
		}
	      while(ret != GASPI_SUCCESS);
	    }
	}
      else
	{
	  gaspi_rank_t sender;
	  ASSERT(gaspi_passive_receive(0, 0, &sender, msgSize, GASPI_BLOCK));
	  assert(sender == 1);
	}
    }

  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT (gaspi_segment_create(0, _2MB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  int * int_GlbMem;
  gaspi_pointer_t _vptr;

  ASSERT(gaspi_segment_ptr(0, &_vptr));

  int_GlbMem = ( int *) _vptr;

  gaspi_size_t msgSize;
  gaspi_size_t i;
  for(msgSize = 4; msgSize < 8192; msgSize *=2)
    if(myrank == 0)
      {

	for(i = 0; i < msgSize / sizeof(int); i++)
	  int_GlbMem[i] = (int) msgSize;

	gaspi_rank_t n;
	for(n = 1; n < P; n++)
	  ASSERT(gaspi_passive_send(0, 0, n, msgSize, GASPI_BLOCK));
      }
    else
      {
	gaspi_rank_t sender;
	ASSERT(gaspi_passive_receive(0, 0, &sender, msgSize, GASPI_BLOCK));
	for(i = 0; i < msgSize / sizeof(int); i++)
	  assert( int_GlbMem[i] == (int) msgSize );
      }
  
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
Exemple #4
0
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT (gaspi_segment_create(0, _4GB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  int * int_GlbMem;
  gaspi_pointer_t _vptr;

  ASSERT(gaspi_segment_ptr(0, &_vptr));

  int_GlbMem = ( int *) _vptr;

  const gaspi_size_t msgSize = sizeof(int);

  if(myrank == 0)
    {
      int_GlbMem[0] = 11223344;
      gaspi_rank_t n;
      for(n = 1; n < P; n++)
	ASSERT(gaspi_passive_send(0, 0, n, msgSize, GASPI_BLOCK));
    }
  else
    {
      gaspi_rank_t sender;
      ASSERT(gaspi_passive_receive(0, 0, &sender, msgSize, GASPI_BLOCK));
      gaspi_printf("Received msg from %d\n", sender);
      assert( int_GlbMem[0] == 11223344 );
    }
  
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
Exemple #5
0
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  mctpInitUser(2);
  int tid = mctpRegisterThread();

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT (gaspi_segment_create(0, _4GB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  int * int_GlbMem;
  gaspi_pointer_t _vptr;

  ASSERT(gaspi_segment_ptr(0, &_vptr));

  int_GlbMem = ( int *) _vptr;

  mctpStartSingleThread(recvThread, int_GlbMem);

  int_GlbMem[0] = 11223344;

  //send to myself (need trick to avoid blocking)
  gaspi_return_t ret = GASPI_ERROR;
  do
    {
      ret = gaspi_passive_send(0, 0, myrank, sizeof(int), GASPI_TEST);
      assert (ret != GASPI_ERROR);
      sleep(1);
    }
  while (ret != GASPI_SUCCESS);

  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT(gaspi_segment_create(0, _2MB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));

  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  const gaspi_size_t msgSize = 4;
  const int times = 1000;
  int i;

  for(i = 1; i < times; i++)
    {
      if(myrank == 0)
	{
	  gaspi_rank_t n;
	  for(n = 1; n < P; n++)
	    ASSERT(gaspi_passive_send(0, 0, n, msgSize, GASPI_BLOCK));
	}
      else
	{
	  gaspi_rank_t sender;
	  ASSERT(gaspi_passive_receive(0, 0, &sender, msgSize, GASPI_BLOCK));
	  gaspi_printf("Received msg (%lu bytes) from %d\n", msgSize, sender);
	}
    }

  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));

  ASSERT(gaspi_threads_init_user(2));

  int tid;
  ASSERT (gaspi_threads_register(&tid));

  gaspi_rank_t P, myrank;

  ASSERT (gaspi_proc_num(&P));
  ASSERT (gaspi_proc_rank(&myrank));

  ASSERT (gaspi_segment_create(0, _2MB, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  int * int_GlbMem;
  gaspi_pointer_t _vptr;

  ASSERT(gaspi_segment_ptr(0, &_vptr));

  int_GlbMem = ( int *) _vptr;

  ASSERT(gaspi_threads_run(recvThread, int_GlbMem));

  int_GlbMem[0] = 11223344;

  ASSERT(gaspi_passive_send(0, 0, myrank, sizeof(int), GASPI_BLOCK));

  gaspi_threads_sync();
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return EXIT_SUCCESS;
}
/*-----------------------------------------------------------*/
int masteronlyHaloexchange(int totalReps, int dataSize){
    int repIter, i;

    char* seg_ptr;
    GASPI(segment_ptr(0, (gaspi_pointer_t*)&seg_ptr));

    for (repIter=0; repIter<totalReps; repIter++){

        /* Each thread writes its globalID to rightSendBuf
         * and leftSendBuf using a parallel for directive.
         */
        #pragma omp parallel for  \
          private(i) \
          shared(leftSendBuf,rightSendBuf,dataSize) \
          shared(sizeofBuffer,globalIDarray) \
          schedule(static,dataSize)
        for (i=0; i<sizeofBuffer; i++){
            leftSendBuf[i] = globalIDarray[myThreadID];
            rightSendBuf[i] = globalIDarray[myThreadID];
        }

#if ONE_SIDED
        /* Process starts send of data to leftNeighbour and
         * rightNeighbour using non-blocking send...
         */
        GASPI(write_notify(0, (char*)leftSendBuf-seg_ptr, myGASPIleftNeighbour,
                           0, (char*)leftRecvBuf-seg_ptr, sizeof(int)*sizeofBuffer,
                           0, 1, 0, GASPI_BLOCK));
        //MPI_Isend(leftSendBuf, sizeofBuffer, MPI_INT, leftNeighbour, \
        //          TAG, commCart, &requestArray[0]);

        GASPI(write_notify(0, (char*)rightSendBuf-seg_ptr, myGASPIrightNeighbour,
                           0, (char*)rightRecvBuf-seg_ptr, sizeof(int)*sizeofBuffer,
                           1, 1, 0, GASPI_BLOCK));
        //MPI_Isend(rightSendBuf, sizeofBuffer, MPI_INT, rightNeighbour, \
        //          TAG, commCart, &requestArray[1]);

        /* Process then waits for messages from leftNeighbour and rightNeighbour */
        //MPI_Irecv(leftRecvBuf, sizeofBuffer, MPI_INT, leftNeighbour, \
        //          TAG, commCart, &requestArray[2]);

        //MPI_Irecv(rightRecvBuf, sizeofBuffer, MPI_INT, rightNeighbour, \
        //          TAG, commCart, &requestArray[3]);

        gaspi_notification_id_t first;
        gaspi_notification_t old;
        GASPI(notify_waitsome(0, 0, 1, &first, GASPI_BLOCK));
        GASPI(notify_reset(0, first, &old));
        GASPI(notify_waitsome(0, 1, 1, &first, GASPI_BLOCK));
        GASPI(notify_reset(0, first, &old));

        #pragma omp parallel for  \
          private(i) \
          shared(leftRecvBuf,rightRecvBuf,dataSize,sizeofBuffer) \
          shared(finalLeftBuf,finalRightBuf) \
          schedule(static,dataSize)
        for (i=0; i<sizeofBuffer; i++){
            finalRightBuf[i] = rightRecvBuf[i];
            finalLeftBuf[i] = leftRecvBuf[i];
        }
#else
        int send = 0;
        int recv = 0;
        int wrong_order = 0;
        while (send != 2 || recv != 2) {
            if (send == 0) {
                int ret = gaspi_passive_send(0, (char*)leftSendBuf-seg_ptr, 0, sizeof(int)*sizeofBuffer, 10);
                if (ret == GASPI_SUCCESS) {
                    ++send;
                }
                if (ret == GASPI_ERROR) {
                    assert(0);
                }
            }
            if (send == 1) {
                int ret = gaspi_passive_send(0, (char*)rightSendBuf-seg_ptr, 0, sizeof(int)*sizeofBuffer, 10);
                if (ret == GASPI_SUCCESS) {
                    ++send;
                }
                if (ret == GASPI_ERROR) {
                    assert(0);
                }
            }
            if (recv == 0) {
                gaspi_rank_t source;
                int ret = gaspi_passive_receive(0, (char*)leftRecvBuf-seg_ptr, &source, sizeof(int)*sizeofBuffer, 10);
                if (ret == GASPI_SUCCESS) {
                    if (source != leftNeighbour) wrong_order = 1;
                    ++recv;
                }
                if (ret == GASPI_ERROR) {
                    printf("%s\n", strerror(errno));
                    assert(0);
                }
            }
            if (recv == 1) {
                gaspi_rank_t source;
                int ret = gaspi_passive_receive(0, (char*)rightRecvBuf-seg_ptr, &source, sizeof(int)*sizeofBuffer, 10);
                if (ret == GASPI_SUCCESS) {
                    if (source != rightNeighbour && wrong_order != 1) assert(0);
                    ++recv;
                }
                if (ret == GASPI_ERROR) {
                    printf("%s\n", strerror(errno));
                    assert(0);
                }
            }
        }

        if (wrong_order == 0) {
            #pragma omp parallel for  \
              private(i) \
              shared(leftRecvBuf,rightRecvBuf,dataSize,sizeofBuffer) \
              shared(finalLeftBuf,finalRightBuf) \
              schedule(static,dataSize)
            for (i=0; i<sizeofBuffer; i++){
                finalRightBuf[i] = rightRecvBuf[i];
                finalLeftBuf[i] = leftRecvBuf[i];
            }
        } else {
            #pragma omp parallel for  \
              private(i) \
              shared(leftRecvBuf,rightRecvBuf,dataSize,sizeofBuffer) \
              shared(finalLeftBuf,finalRightBuf) \
              schedule(static,dataSize)
            for (i=0; i<sizeofBuffer; i++){
                finalRightBuf[i] = leftRecvBuf[i];
                finalLeftBuf[i] = rightRecvBuf[i];
            }
        }
#endif


#if ONE_SIDED
        GASPI(notify(0, myGASPIrightNeighbour, 2, 1, 0, GASPI_BLOCK));
        GASPI(notify(0, myGASPIleftNeighbour, 3, 1, 0, GASPI_BLOCK));

        GASPI(notify_waitsome(0, 2, 1, &first, GASPI_BLOCK));
        GASPI(notify_reset(0, first, &old));
        GASPI(notify_waitsome(0, 3, 1, &first, GASPI_BLOCK));
        GASPI(notify_reset(0, first, &old));

        /* Finish the sends with an MPI_Waitall on the requests */
        //MPI_Waitall(4, requestArray, statusArray);
        GASPI(wait(0, GASPI_BLOCK));
#else
        GASPI(barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
#endif
    }

    return 0;
}