home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adaptor.zip / adapt.zip / adaptor / dalib / pvm3 / pbroadct.c < prev    next >
C/C++ Source or Header  |  1993-11-29  |  3KB  |  84 lines

  1. /*******************************************************************
  2. *                                                                  *
  3. *  MODULE : broadcast.c                                            *
  4. *                                                                  *
  5. *  Function: Realization of Broadcast Operations                   *
  6. *                                                                  *
  7. *                                                                  *
  8. *   THIS MODULE IS A  PVM  VERSION, based on PVM 3.1               *
  9. *                                                                  *
  10. *      equal for Alliant, Sun4, IBM AIX                            *
  11. *                                                                  *
  12. *******************************************************************/
  13.  
  14. #include "system.h"
  15. #include "pvm3.h"
  16.  
  17. #define WITH_HOST 1
  18. #define NO_HOST   0 
  19.  
  20. /*******************************************************************
  21. *                                                                  *
  22. *  IMPORT :                                                        *
  23. *                                                                  *
  24. *      asend, areceive from MAILBOX                                *
  25. *                                                                  *
  26. *******************************************************************/
  27.  
  28. void general_broadcast (data,size,j,host_opt)
  29.  
  30. char *data;   /* pointer to the data element */
  31. int j, size;  /* process j sends data of size bytes */
  32. int host_opt; /* indicates participation of host    */
  33.  
  34. /* using broadcast possibility of pvm
  35.  
  36.     if host_opt == NO_HOST, host gets no copy     */
  37.  
  38. { int i, n;
  39.  
  40.   i = pcb.i;  /* number of the calling process */
  41.   n = pcb.p;  /* number of processors */
  42.  
  43.   /* printf ("broadcast, here %d(%d), gets from %d, size = %d\n",i,n,j,size); */
  44.  
  45.   if (i == j)  /* I am sending */
  46.     { pvm_initsend(PvmDataRaw);
  47.       pvm_pkbyte (data, size, 1);
  48.       if ((i != 0) && (host_opt == WITH_HOST) && (target_model == 0))
  49.          pvm_mcast (tids, n+1, j);   /* also send to host */
  50.        else
  51.          pvm_mcast (tids+1, n, j);     /* not to host = process 0 */
  52.     }
  53.    else if ((i != 0) || (host_opt == WITH_HOST))
  54.     { pvm_recv (tids[j], j);
  55.       pvm_upkbyte (data, size, 1);
  56.     }
  57. }
  58.  
  59. process_broadcast (data,size,j)
  60. char *data;  /* pointer to the data element */
  61. int j, size;  /* process j sends data of size bytes */
  62. { general_broadcast (data,size,j,WITH_HOST); }
  63.  
  64. /*******************************************************************
  65. *                                                                  *
  66. *  FORTRAN - Interface                                             *
  67. *                                                                  *
  68. *    dalib_broadcast (data, size, j)                               *
  69. *      - broadcast to host and all node from process j             *
  70. *                                                                  *
  71. *******************************************************************/
  72.  
  73. void dalib_broadcast__ (data,size,j)
  74. int *data, *size, *j;
  75. { int pos;
  76.   general_broadcast (data, *size, *j, WITH_HOST);
  77. }
  78.  
  79. void dalib_node_broadcast__ (data,size,j)
  80. int *data, *size, *j;
  81. { int pos;
  82.   general_broadcast (data, *size, *j, NO_HOST);
  83. }
  84.