| 956 | | pvm_scatter(result, data, count, datatype, msgtag, gname, rootinst) | | 957 | | void *result, *data; | | 958 | | int count, datatype, msgtag, rootinst; | | 959 | | char *gname; | | 960 | | { | | 961 | | int roottid, myginst, datasize, gsize, *tids = 0, i, cc; | | 962 | | int sbuf, rbuf; | | 963 | | | | 964 | | int (*packfunc)(), (*unpackfunc)(); | | 965 | | int x; | | 966 | | int savectx; | | 967 | | | | 968 | | TEV_DECLS
| | 969 | | | | 970 | | BGN_TRACE( TEV_SCATTER, gname, TEV_DID_MC, &msgtag );
| /kat0/fletcher/SATE/2010/pvm3/pvmgs/pvmgs_mac.h | | 82 | #define BGN_TRACE( event, strarg, did, intarg ) \ | | 83 | if ( TEV_EXCLUSIVE ) { \ | | 84 | if (TEV_DO_TRACE( event, TEV_EVENT_ENTRY ) ) \ | | 85 | { \ | | 86 | TEV_PACK_STRING( TEV_DID_GN, TEV_DATA_SCALAR, \ | | 87 | strarg ? strarg: "", 1, 1 ); \ | | 88 | if ( intarg != (int *) NULL ) \ | | 89 | TEV_PACK_INT( did, TEV_DATA_SCALAR, intarg, 1, 1 ); \ | | 90 | TEV_FIN; \ | | 91 | } \ | | 92 | } |
| | 971 | | | | 972 | | | | 973 | | savectx = pvm_setcontext( SYSCTX_DG );
| | 974 | | | | 975 | | if ( (result == NULL) || (count <= 0) )
| | 976 | | { | | 977 | | cc = PvmBadParam;
| | 978 | | goto done; | | 979 | | } | | 980 | | | | 981 | | | | 982 | | if ( (cc = gs_pack_unpack(datatype, &packfunc, &unpackfunc)) < 0) | | 983 | | goto done; | | 984 | | | | 985 | | | | 986 | | if ( (roottid = pvm_gettid(gname,rootinst)) < 0 ) | | 987 | | { | | 988 | | cc = roottid; | | 989 | | goto done; | | 990 | | } | | 991 | | | | 992 | | | | 993 | | if ( (cc = myginst = pvm_getinst(gname, pvmmytid)) < 0 ) goto done; | | 994 | | | | 995 | | | | 996 | | if (myginst == rootinst) | | 997 | | { | | 998 | | if ( data == NULL)
| | 999 | | { | | 1000 | | cc = PvmBadParam;
| | 1001 | | goto done; | | 1002 | | } | | 1003 | | | | 1004 | | | | 1005 | | if ( (cc = datasize = gs_get_datasize(datatype)) < 0 ) goto done; | | 1006 | | | | 1007 | | | | 1008 | | if ( (cc = gs_get_tidlist(gname, msgtag, &gsize, &tids, 1)) < 0) | | 1009 | | goto done; | | 1010 | | | | 1011 | | sbuf = pvm_mkbuf(PvmDataDefault);
| | 1012 | | | | 1013 | | | | 1014 | | | | 1015 | | | | 1016 | | for (i=0; i<gsize; i++) | | 1017 | | { | | 1018 | | if (i == myginst) | | 1019 | | BCOPY((char *) data + i*datasize*count, (char *) result,
| | 1020 | | datasize*count); | | 1021 | | else | | 1022 | | { | | 1023 | | sbuf = pvm_initsend(PvmDataDefault);
| | 1024 | | if ((cc=(*packfunc)((char *)data+i*datasize*count,count,1))<0) | | 1025 | | { | | 1026 | | pvm_freebuf(pvm_setsbuf(sbuf)); | | 1027 | | goto done; | | 1028 | | } | | 1029 | | if ( (cc = pvm_send( tids[i], msgtag)) < 0) | | 1030 | | { | | 1031 | | pvm_freebuf(pvm_setsbuf(sbuf)); | | 1032 | | goto done; | | 1033 | | } | | 1034 | | } | | 1035 | | } | | 1036 | | pvm_freebuf(pvm_setsbuf(sbuf)); | | 1037 | | } | | 1038 | | else | | 1039 | | { | | 1040 | | | | 1041 | | rbuf = pvm_setrbuf(0); | | 1042 | | if ( (cc = pvm_recv( roottid, msgtag )) < 0) | | 1043 | | { | | 1044 | | pvm_freebuf(pvm_setrbuf(rbuf)); | | 1045 | | goto done; | | 1046 | | } | | 1047 | | if ( (cc = (*unpackfunc)( result, count, 1)) < 0) | | 1048 | | { | | 1049 | | pvm_freebuf(pvm_setrbuf(rbuf)); | | 1050 | | goto done; | | 1051 | | } | | 1052 | | pvm_freebuf(pvm_setrbuf(rbuf)); | | 1053 | | | | 1054 | | } | | 1055 | | | | 1056 | | cc = PvmOk;
| | 1057 | | | | 1058 | | done: | | 1059 | | | | 1060 | | | | 1061 | | pvm_setcontext( savectx ); | | 1062 | | | | 1063 | | if (tids) free(tids); | | 1064 | | | | 1065 | | if (cc < 0) lpvmerr("pvm_scatter",cc); | | 1066 | | | | 1067 | | END_TRACE( TEV_SCATTER, TEV_DID_CC, &cc);
| | 1068 | | | | 1069 | | return(cc); | | 1070 | | | | 1071 | | } |
|