Пример #1
0
int main(int argc, char *argv[])
{

  gaspi_rank_t r;

  gaspi_notification_id_t id;

  TSUITE_INIT(argc, argv);


  ASSERT( gaspi_proc_init(GASPI_BLOCK));
  ASSERT( gaspi_proc_rank(&r));

  ASSERT( gaspi_segment_create(0, 1, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_ALLOC_DEFAULT));


  ASSERT(gaspi_notify(0, r, r, 1, 0, GASPI_BLOCK));

  ASSERT(  gaspi_notify_waitsome(0, r, 1, &id, GASPI_BLOCK));

  // wait for zero notifications
  ASSERT( gaspi_notify_waitsome(0, 0, 0, &id, GASPI_BLOCK));

  ASSERT(  gaspi_segment_delete(0 ));

  ASSERT( gaspi_proc_term(GASPI_BLOCK) );

  return 0;

}
Пример #2
0
int main(int argc, char *argv[])
{
  TSUITE_INIT(argc, argv);
  
  ASSERT (gaspi_proc_init(GASPI_BLOCK));
  
  gaspi_notification_id_t  n=0;
  gaspi_number_t notif_num;
  gaspi_rank_t rank, nprocs, i;
  const  gaspi_segment_id_t seg_id = 0;

  ASSERT(gaspi_proc_num(&nprocs));
  ASSERT (gaspi_proc_rank(&rank));
  
  ASSERT (gaspi_segment_create(seg_id, 1024, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_UNINITIALIZED));
  
  ASSERT( gaspi_notification_num(&notif_num));
  gaspi_printf("max num notifications %u\n", notif_num);
  
  if(rank == 0)
    {
      gaspi_number_t queue_size;
      gaspi_number_t queue_max;
      ASSERT (gaspi_queue_size_max(&queue_max));

      for(n = 0; n < notif_num; n++)
	{
	  ASSERT (gaspi_queue_size(0, &queue_size));
	  if(queue_size > queue_max - 1)
	    ASSERT (gaspi_wait(0, GASPI_BLOCK));
	  
	  for(i = 1; i < nprocs; i++)
	    {
	      ASSERT (gaspi_notify( seg_id, i, n, 1, 0, GASPI_BLOCK));
	    }
	}
    }
  else
    {
      do
	{
	  gaspi_notification_id_t id;
	  ASSERT (gaspi_notify_waitsome(seg_id, 0, notif_num, &id, GASPI_BLOCK));

	  gaspi_notification_t notification_val;
	  ASSERT( gaspi_notify_reset(seg_id, id, &notification_val));
	  assert(notification_val == 1);
	  n++;
	}
      while(n < notif_num);
    } 
  ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));
  
  return EXIT_SUCCESS;
}
Пример #3
0
int main(int argc, char *argv[])
{
  int k = 0;
  int ret = 0;
  unsigned long j;

  const gaspi_size_t size = 4096;

  const gaspi_size_t memSize = _4GB;

  gaspi_offset_t offset_write = 0;
  gaspi_offset_t offset_read = _2GB;
  gaspi_offset_t offset_check = 3221225472;
  gaspi_number_t qmax ;
  gaspi_number_t queueSize;

  TSUITE_INIT(argc, argv);

  ASSERT (gaspi_proc_init(GASPI_BLOCK));
  ASSERT (gaspi_queue_size_max(&qmax));
  ASSERT (gaspi_segment_create(0, memSize, GASPI_GROUP_ALL, GASPI_BLOCK, GASPI_MEM_INITIALIZED));

  gaspi_pointer_t _vptr;
  ASSERT (gaspi_segment_ptr(0, &_vptr));

  /* get memory area pointer */
  float *mptr_f = (float *) _vptr;
  char *mptr_c = (char *) _vptr;

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

  while(k <= RUNS)
    {
      //generate random
      srand((unsigned)time(0));
      srand48((unsigned) time(0));

      ASSERT(gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

      //clean
      for(j = 0; j < memSize; j++)
	mptr_c[j]= 0;

      /* fill randoms up to 1GB */
      for(j = 0; j < (GB / sizeof(float)); j++)
	{
	  mptr_f[j]=  drand48() + (myrank * 1.0);
	}

#ifdef DEBUG
      gaspi_printf("random value in pos 0 %f\n", mptr_f[0]);
#endif
      ASSERT (gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

      gaspi_printf("\n....Running iteration %d of %d...\n",k, RUNS);

      const unsigned long packets = (GB / size);
      for(j = 0; j < packets; j++)
	{
	  ASSERT(gaspi_queue_size(0, &queueSize));
	  if (queueSize > qmax - 24)
	    {
	      ASSERT(gaspi_wait(0, GASPI_BLOCK));
	    }

	  ASSERT (gaspi_write(0, offset_write, (myrank + 1) % highestnode,
			      0, offset_read, size,
			      0, GASPI_BLOCK));

	  offset_write += size;
	  offset_read += size;
	}

    offset_write=0;
    offset_read = _2GB;

#ifdef DEBUG
    gaspi_printf("%d bytes written!\n", packets * size);
#endif

    /* notify remote that data is written */
    ASSERT (gaspi_notify( 0, (myrank + 1) % highestnode, 0, 1, 0, GASPI_BLOCK));
    gaspi_notification_id_t recv_id;
    ASSERT(gaspi_notify_waitsome(0, 0, 1, &recv_id, GASPI_BLOCK));
    assert(recv_id == 0);
    gaspi_notification_t notification_val;
    ASSERT( gaspi_notify_reset(0, recv_id, &notification_val));

    /* notify remote that data has arrived */
    ASSERT (gaspi_notify( 0, (myrank + highestnode - 1) % highestnode, 1, 1, 0, GASPI_BLOCK));

    gaspi_notification_id_t ack_id;
    ASSERT(gaspi_notify_waitsome(0, 1, 1, &ack_id, GASPI_BLOCK));
    assert(ack_id == 1);
    ASSERT( gaspi_notify_reset(0, ack_id, &notification_val));

    /* check if data was written successfully */
    ASSERT (gaspi_read(0, offset_check, (myrank + 1) % highestnode,
		       0, offset_read, GB / 2,
		       0, GASPI_BLOCK));

    ASSERT (gaspi_read(0, offset_check + (GB / 2), (myrank + 1) % highestnode,
		       0, offset_read  + (GB / 2), GB / 2,
		       0, GASPI_BLOCK));

    ASSERT (gaspi_wait(0, GASPI_BLOCK));

#ifdef DEBUG
    gaspi_printf("Values %f %f %f \n", mptr_f[0], mptr_f[offset_read / sizeof(float)], mptr_f[offset_check / sizeof(float)]);
#endif

    j = 0;
    while(j < GB / sizeof(float) )
      {
	if(mptr_f[j] != mptr_f[offset_check / sizeof(float) + j]){
	  gaspi_printf("value incorrect %f-%f at %d \n",
		       mptr_f[j],
		       mptr_f[offset_check / sizeof(float) + j],
		       j);
	  ret = -1;
	  goto out;
	}
	j++;
      }

#ifdef DEBUG
    gaspi_printf("Check!\n");
#endif

    k++;
  }

 out:

  gaspi_printf("Waiting to finish...\n");
  ASSERT(gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));
  ASSERT (gaspi_proc_term(GASPI_BLOCK));

  return ret;
}
Пример #4
0
int main(int argc, char *argv[])
{
  int i;
  gaspi_rank_t rank, nprocs;
  gaspi_notification_id_t id;

  const int num_elems = 1024;

  TSUITE_INIT( argc, argv );

  ASSERT( gaspi_proc_init(GASPI_BLOCK) );

  ASSERT( gaspi_proc_num(&nprocs) );
  ASSERT( gaspi_proc_rank(&rank) );

  const gaspi_rank_t left = (rank + nprocs - 1 ) % nprocs;
  const gaspi_rank_t right = (rank + nprocs + 1) % nprocs;

  /* Create and fill buffer */
  int  * const buf = (int *) malloc(num_elems * sizeof(int));
  assert( buf != NULL);

  for (i = 0; i < num_elems; i++)
    {
      buf[i] = rank;
    }

  ASSERT( gaspi_segment_use( 0, buf, num_elems * sizeof(int),
			     GASPI_GROUP_ALL, GASPI_BLOCK,
			     0) );

  ASSERT( gaspi_segment_create( 1, num_elems * sizeof(int),
				GASPI_GROUP_ALL, GASPI_BLOCK,
				GASPI_MEM_INITIALIZED) );

  ASSERT(gaspi_barrier(GASPI_GROUP_ALL, GASPI_BLOCK));

  /* write data to neighbour */
  ASSERT( gaspi_write( 0, 0, right,
		       1, 0, num_elems * sizeof(int),
		       0, GASPI_BLOCK) );

  ASSERT( gaspi_notify( 1, right, 0, 1, 0, GASPI_BLOCK ) );
  ASSERT( gaspi_notify_waitsome( 1, 0, 1, &id, GASPI_BLOCK ) );
  ASSERT( gaspi_wait( 0, GASPI_BLOCK ) );

  /* Check data */
  gaspi_pointer_t seg1_ptr;
  ASSERT( gaspi_segment_ptr( 1, &seg1_ptr ) );
  int * recv_buf = (int *) seg1_ptr;

  for (i = 0; i < num_elems; i++)
    {
      assert(recv_buf[i] == left);
    }

  ASSERT( gaspi_segment_delete(0));
  ASSERT( gaspi_segment_delete(1));

  for (i = 0; i < num_elems; i++)
    {
      assert(buf[i] == rank);
    }

  ASSERT( gaspi_barrier( GASPI_GROUP_ALL, GASPI_BLOCK ) );

  ASSERT( gaspi_proc_term( GASPI_BLOCK ) );

  return EXIT_SUCCESS;
}