home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / prospero / PRM / src / testprog / vector.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-24  |  1.6 KB  |  71 lines

  1. /*
  2.  * Copyright (c) 1992, 1993 by the University of Southern California
  3.  *
  4.  * For copying and distribution information, please see the files
  5.  * <prm-copyr.h>.
  6.  */
  7.  
  8. #include <prm-copyr.h>
  9.  
  10. #include <stdio.h>
  11.  
  12. #define  MAIN_PROG
  13. #include <comm.h>   /*     This file defines certain constants, and declares
  14.             some global variables used by the message passing
  15.             routines.  */
  16.  
  17. #ifndef RNEIGH
  18. #   define RNEIGH(x,tot)    ((x<tot)?x+1:1) /* right neighbor of x in ring */
  19. #endif
  20.  
  21. #ifndef LNEIGH
  22. #   define LNEIGH(y,tot)    ((y==1)?tot:y-1)
  23. #endif
  24.  
  25. #define MAXTIME 12                        /* Maximum computation time in sec.*/
  26. #define INT_SZ sizeof(int)
  27.  
  28. char *progname;
  29.  
  30. main(argc, argv)
  31. int argc;
  32. char **argv;
  33. {
  34.   int ntasks, my_tid, i;
  35.   int comp_time, intime, timeleft, iter_cnt;
  36.   int sendto_task, rcvfrom_task;
  37.   int data[32];
  38.   char largeb[256], tmp[4];
  39.  
  40.   init_task(argv);    /* Initialization is required for all tasks in every
  41.              application */
  42.   pfs_debug=0;
  43.   my_tid = gettid(); 
  44.   if (my_tid == -1) {
  45.     io_printf(" task could not get its tid!", (char *)0);
  46.     exit(1);
  47.   }
  48.   
  49.   largeb[0] = 0;
  50.   if (my_tid == 1) {
  51.     for (i = 0; i< 32; i++) data[i] = i;
  52.  
  53.     io_printf("Sending every fourth element of array to task 2", (char *)0);
  54.     vsend_v (2, 1, 10, data, 4, 4, 8);
  55.   }
  56.   if (my_tid == 2) {
  57.     for (i = 0; i< 32; i++) data[i] = 31-i;
  58.     vrecv_v(1, 1, -1, data, 4, 4, 8);
  59.  
  60.     for (i=0; i < 32; i++) {
  61.       sprintf(tmp, "%d ", data[i]);
  62.       strcat(largeb, tmp);
  63.     }
  64.     io_printf("Recvd array: %s from task 1", largeb);
  65.   }
  66.   io_printf("done.\n", (char *)0 );
  67.   
  68.   exit(0);
  69. }
  70.  
  71.