-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComm.java
More file actions
1364 lines (1162 loc) · 46.7 KB
/
Copy pathComm.java
File metadata and controls
1364 lines (1162 loc) · 46.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* File : Comm.java
* Author : Sang Lim, Sung-Hoon Ko, Xinying Li, Bryan Carpenter
* Created : Thu Apr 9 12:22:15 1998
* Revision : $Revision: 1.20 $
* Updated : $Date: 2001/08/07 16:36:25 $
* Copyright: Northeast Parallel Architectures Center
* at Syracuse University 1998
*/
package mpi;
import java.io.*;
import java.lang.*;
public class Comm {
protected final static int SELF = 1;
protected final static int WORLD = 2;
protected static long nullHandle ;
Comm() {}
void setType(int Type) {
GetComm(Type);
}
private native void GetComm(int Type);
protected Comm(long handle) {
this.handle = handle;
}
/**
* Duplicate this communicator.
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> copy of this communicator </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_DUP</tt>.
* <p>
* The new communicator is ``congruent'' to the old one, but has a
* different context.
*/
public Object clone() {
return new Comm(dup());
}
protected native long dup();
/**
* Size of group of this communicator.
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> number of processors in the group
* of this communicator </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_SIZE</tt>.
*/
public native int Size() throws MPIException ;
/**
* Rank of this process in group of this communicator.
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> rank of the calling process in the
* group of this communicator </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_RANK</tt>.
*/
public native int Rank() throws MPIException ;
/**
* Compare two communicators.
* <p>
* <table>
* <tr><td><tt> comm1 </tt></td><td> first communicator </tr>
* <tr><td><tt> comm2 </tt></td><td> second communicator </tr>
* <tr><td><em> returns: </em></td><td> result </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_COMPARE</tt>.
* <p>
* <tt>MPI.IDENT</tt> results if the <tt>comm1</tt> and <tt>comm2</tt>
* are references to the same object (ie, if <tt>comm1 == comm2</tt>).
* <tt>MPI.CONGRUENT</tt> results if the underlying groups are identical
* but the communicators differ by context.
* <tt>MPI.SIMILAR</tt> results if the underlying groups are similar
* but the communicators differ by context.
* <tt>MPI.UNEQUAL</tt> results otherwise.
*/
public static native int Compare(Comm comm1, Comm comm2) throws MPIException ;
/**
* Destroy this communicator.
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_FREE</tt>.
*/
public native void Free() throws MPIException ;
/**
* Test if communicator object is void (has been freed).
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> true if the comm object is void,
* false otherwise </tr>
* </table>
*/
public native boolean Is_null();
/**
* Return group associated with a communicator.
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> group corresponding to this
* communicator group </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_GROUP</tt>.
*/
public Group Group() throws MPIException {
return new Group(group());
}
private native long group();
// Inter-communication
/**
* Test if this communicator is an inter-communicator.
* <p>
* <table>
* <tr><td><em> returns: </em></td><td> <tt>true</tt> if this is an
* inter-communicator,
* <tt>false</tt> otherwise </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_COMM_TEST_INTER</tt>.
*/
public native boolean Test_inter() throws MPIException ;
/**
* Create an inter-communicator.
* <p>
* <table>
* <tr><td><tt> local_comm </tt></td><td> local intra-communicator </tr>
* <tr><td><tt> local_leader </tt></td><td> rank of local group leader
* in <tt>localComm</tt> </tr>
* <tr><td><tt> remote_leader </tt></td><td> rank of remote group leader
* in this communictor </tr>
* <tr><td><tt> tag </tt></td><td> ``safe'' tag </tr>
* <tr><td><em> returns: </em></td><td> new inter-communicator </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_INTERCOMM_CREATE</tt>.
* <p>
* (This operation is defined as a method on the ``peer communicator'',
* making it analogous to a <tt>send</tt> or <tt>recv</tt> communication
* with the remote group leader.)
*/
public Intercomm Create_intercomm(Comm local_comm,
int local_leader,
int remote_leader,
int tag) throws MPIException {
return new Intercomm(GetIntercomm(local_comm, local_leader,
remote_leader, tag)) ;
}
public native long GetIntercomm(Comm local_comm,
int local_leader,
int remote_leader,
int tag) ;
// Object serialization support
public byte[] Object_Serialize(Object buf,
int offset,
int count,
Datatype type) throws MPIException {
if(type.Size() != 0) {
byte[] byte_buf ;
Object buf_els [] = (Object[])buf;
try {
ByteArrayOutputStream o = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(o);
int base;
for (int i = 0; i < count; i++){
base = type.Extent() * i;
for (int j = 0 ; j < type.displacements.length ; j++)
out.writeObject(buf_els[base + offset +
type.displacements[j]]);
}
out.flush();
out.close();
byte_buf = o.toByteArray();
} catch(Exception ex){
ex.printStackTrace();
byte_buf = null ;
}
return byte_buf ;
}
else return new byte[0];
}
public void Object_Deserialize(Object buf,
byte[] byte_buf,
int offset,
int count,
Datatype type) throws MPIException {
if(type.Size() != 0) {
Object buf_els [] = (Object[])buf;
try {
ByteArrayInputStream in = new ByteArrayInputStream(byte_buf);
ObjectInputStream s = new ObjectInputStream(in);
int base;
for (int i = 0; i < count; i++){
base = type.Extent() * i;
for (int j = 0 ; j < type.displacements.length ; j++)
buf_els[base + offset + type.displacements[j]]=s.readObject();
}
s.close();
}catch(Exception ex){ex.printStackTrace();}
}
}
// Blocking Send and Recv
/**
* Blocking send operation.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SEND</tt>.
* <p>
* The actual argument associated with <tt>buf</tt> must be
* one-dimensional array. The value <tt>offset</tt> is a subscript in
* this array, defining the position of the first item of the message.
* <p>
* If the <tt>datatype</tt> argument represents an MPI basic type, its
* value must agree with the element type of <tt>buf</tt>---either
* a primitive type or a reference (object) type. If the
* <tt>datatype</tt> argument represents an MPI derived type, its
* <em>base type</em> must agree with the element type of <tt>buf</tt>
*/
public void Send(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
send(length_buf, 0, 2, MPI.INT, dest, tag); // header
send(byte_buf, 0, byte_buf.length, MPI.BYTE,dest, tag) ;
}
else {
send(buf, offset, count, type, dest, tag);
}
}
private native void send(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag);
/**
* Blocking receive operation.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> receive buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in receive buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items in receive
* buffer </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in receive
* buffer </tr>
* <tr><td><tt> source </tt></td><td> rank of source </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> status object </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_RECV</tt>.
* <p>
* The actual argument associated with <tt>buf</tt> must be
* one-dimensional array. The value <tt>offset</tt> is a subscript in
* this array, defining the position into which the first item of the
* incoming message will be copied.
* <p>
* If the <tt>datatype</tt> argument represents an MPI basic type, its
* value must agree with the element type of <tt>buf</tt>---either
* a primitive type or a reference (object) type. If the
* <tt>datatype</tt> argument represents an MPI derived type, its
* <em>base type</em> must agree with the element type of <tt>buf</tt>
*/
public Status Recv(Object buf,
int offset,
int count,
Datatype type,
int source,
int tag) throws MPIException {
if (type.isObject()){
Status status = new Status();
int[] length_buf= new int[2];
Recv(length_buf,0,2, MPI.INT, source, tag, status);
byte[] byte_buf = new byte[length_buf[0]];
Recv(byte_buf,0,length_buf[0], MPI.BYTE, status.source, tag, status);
Object_Deserialize(buf,byte_buf,offset,length_buf[1],type);
status.object_count = length_buf[1];
return status;
}
else
return Recv(buf, offset, count, type, source, tag, new Status());
}
private native Status Recv(Object buf,
int offset,
int count,
Datatype type,
int source,
int tag,
Status stat);
// Send-Recv
/**
* Execute a blocking send and receive operation.
* <p>
* <table>
* <tr><td><tt> sendbuf </tt></td><td> send buffer array </tr>
* <tr><td><tt> sendoffset </tt></td><td> initial offset in send
* buffer </tr>
* <tr><td><tt> sendcount </tt></td><td> number of items to send </tr>
* <tr><td><tt> sendtype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> sendtag </tt></td><td> send tag </tr>
* <tr><td><tt> recvbuf </tt></td><td> receive buffer array </tr>
* <tr><td><tt> recvoffset </tt></td><td> initial offset in receive
* buffer </tr>
* <tr><td><tt> recvcount </tt></td><td> number of items in receive
* buffer </tr>
* <tr><td><tt> recvtype </tt></td><td> datatype of each item in receive
* buffer </tr>
* <tr><td><tt> source </tt></td><td> rank of source </tr>
* <tr><td><tt> recvtag </tt></td><td> receive tag </tr>
* <tr><td><em> returns: </em></td><td> status object </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SENDRECV</tt>.
* <p>
* Further comments as for <tt>Send</tt> and <tt>Recv</tt>.
*/
public Status Sendrecv(Object sendbuf,
int sendoffset,
int sendcount,
Datatype sendtype,
int dest,
int sendtag,
Object recvbuf,
int recvoffset,
int recvcount,
Datatype recvtype,
int source,
int recvtag) throws MPIException {
if(sendtype.isObject() || recvtype.isObject()) {
Request reqs [] = {Isend(sendbuf, sendoffset, sendcount, sendtype,
dest, sendtag),
Irecv(recvbuf, recvoffset, recvcount, recvtype,
source, recvtag)} ;
Status stas [] = Request.Waitall(reqs) ;
return stas [1] ;
}
else return Sendrecv(sendbuf, sendoffset,
sendcount, sendtype,
dest, sendtag,
recvbuf, recvoffset,
recvcount, recvtype,
source, recvtag,
new Status());
}
private native Status Sendrecv(Object sbuf,
int soffset,
int scount,
Datatype stype,
int dest,
int stag,
Object rbuf,
int roffset,
int rcount,
Datatype rtype,
int source,
int rtag,
Status stat);
/**
* Execute a blocking send and receive operation, receiving message
* into send buffer.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> type </tt></td><td> datatype of each item in
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> sendtag </tt></td><td> send tag </tr>
* <tr><td><tt> source </tt></td><td> rank of source </tr>
* <tr><td><tt> recvtag </tt></td><td> receive tag </tr>
* <tr><td><em> returns: </em></td><td> status object </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SENDRECV_REPLACE</tt>.
* <p>
* Further comments as for <tt>Send</tt> and <tt>Recv</tt>.
*/
public Status Sendrecv_replace(Object buf,
int offset,
int count,
Datatype type,
int dest,
int sendtag,
int source,
int recvtag) throws MPIException {
if(type.isObject()) {
// Might as well do this natively, to avoid allocation of one more
// buffer.
Status status = new Status() ;
byte[] sendbytes = Object_Serialize(buf,offset,count,type);
int[] length_buf = {sendbytes.length, count} ;
Sendrecv_replace(length_buf, 0, 2, MPI.INT,
dest, sendtag, source, recvtag,
status) ;
byte [] recvbytes = new byte [length_buf[0]] ;
Sendrecv(sendbytes, 0, sendbytes.length, MPI.BYTE, dest, sendtag,
recvbytes, 0, recvbytes.length, MPI.BYTE, status.source, recvtag,
status) ;
Object_Deserialize(buf,recvbytes,offset,length_buf[1],type);
status.object_count = length_buf[1] ;
return status;
}
else
return Sendrecv_replace(buf, offset, count, type,
dest, sendtag, source, recvtag, new Status());
}
private native Status Sendrecv_replace(Object buf,
int offset,
int count,
Datatype type,
int dest,
int stag,
int source,
int rtag,
Status stat);
// Communication Modes
/**
* Send in buffered mode.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_BSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public void Bsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
bsend(length_buf, 0, 2, MPI.INT, dest, tag);
bsend(byte_buf, 0, length_buf[0], MPI.BYTE, dest, tag);
}
else bsend(buf, offset, count, type, dest, tag);
}
private native void bsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) ;
/**
* Send in synchronous mode.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public void Ssend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
send(length_buf, 0, 2, MPI.INT, dest, tag);
ssend(byte_buf , 0, byte_buf.length, MPI.BYTE, dest, tag);
}
else ssend(buf, offset, count, type, dest, tag);
}
private native void ssend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag);
/**
* Send in ready mode.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_RSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public void Rsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
rsend(length_buf, 0, 2, MPI.INT, dest, tag);
rsend(byte_buf , 0, byte_buf.length, MPI.BYTE, dest, tag);
}
else rsend(buf, offset, count, type, dest, tag);
}
private native void rsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) ;
// Nonblocking communication
/**
* Start a standard mode, nonblocking send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> communication request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_ISEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Request Isend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()) {
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
Request hdrReq = Isend(length_buf, 0, 2, MPI.INT, dest, tag,
new Request());
Request req = new Request(hdrReq) ;
Isend(byte_buf, 0, byte_buf.length, MPI.BYTE, dest, tag, req);
return req;
}
else
return Isend(buf, offset, count, type, dest, tag, new Request());
}
/**
* Protected member used internally by <tt>Prequest.Start</tt>
*/
protected native Request Isend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag,
Request req);
/**
* Start a buffered mode, nonblocking send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> communication request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_IBSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Request Ibsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
Request hdrReq = Ibsend(length_buf, 0, 2, MPI.INT, dest, tag,
new Request());
Request req = new Request(hdrReq) ;
Ibsend(byte_buf, 0, byte_buf.length, MPI.BYTE, dest, tag, req);
return req;
}
else
return Ibsend(buf, offset, count, type, dest, tag, new Request());
}
/**
* Protected member used internally by <tt>Prequest.Start</tt>
*/
protected native Request Ibsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag,
Request req);
/**
* Start a synchronous mode, nonblocking send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> communication request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_ISSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Request Issend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
Request hdrReq = Issend(length_buf, 0, 2, MPI.INT, dest, tag,
new Request());
Request req = new Request(hdrReq) ;
Isend(byte_buf, 0, byte_buf.length, MPI.BYTE, dest, tag, req);
return req;
}
else
return Issend(buf, offset, count, type, dest, tag, new Request());
}
/**
* Protected member used internally by <tt>Prequest.Start</tt>
*/
protected native Request Issend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag,
Request req);
/**
* Start a ready mode, nonblocking send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> communication request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_IRSEND</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Request Irsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
if (type.isObject()){
byte[] byte_buf = Object_Serialize(buf,offset,count,type);
int[] length_buf = {byte_buf.length, count} ;
Request hdrReq = Irsend(length_buf, 0, 2, MPI.INT, dest, tag,
new Request());
Request req = new Request(hdrReq) ;
Isend(byte_buf, 0, byte_buf.length, MPI.BYTE, dest, tag, req);
return req;
}
else
return Irsend(buf, offset, count, type, dest, tag, new Request());
}
/**
* Protected member used internally by <tt>Prequest.Start</tt>
*/
protected native Request Irsend(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag,
Request req);
/**
* Start a nonblocking receive.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> receive buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in receive
* buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items in receive
* buffer </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in receive
* buffer </tr>
* <tr><td><tt> source </tt></td><td> rank of source </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> communication request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_IRECV</tt>.
* <p>
* Further comments as for <tt>Recv</tt>.
*/
public Request Irecv(Object buf,
int offset,
int count,
Datatype type,
int source,
int tag) throws MPIException {
if (type.isObject()){
int[] length_buf= new int[2];
Request req = new Request(buf, offset, count, type,
tag, this, length_buf) ;
Irecv(length_buf, 0, 2, MPI.INT, source, tag, req);
return req;
}
else
return Irecv(buf, offset, count, type, source, tag, new Request());
}
/**
* Protected member used internally by <tt>Prequest.Start</tt>
*/
protected native Request Irecv(Object buf,
int offset,
int count,
Datatype type,
int source,
int tag,
Request req);
// Persistent communication requests
/**
* Creates a persistent communication request for a standard mode send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> persistent communication
* request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SEND_INIT</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Prequest Send_init(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
return new Prequest(Prequest.MODE_STANDARD, buf, offset, count, type,
dest, tag, this) ;
}
/**
* Creates a persistent communication request for a buffered mode send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> persistent communication
* request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_BSEND_INIT</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Prequest Bsend_init(Object buf,
int offset,
int count,
Datatype type,
int dest,
int tag) throws MPIException {
return new Prequest(Prequest.MODE_BUFFERED, buf, offset, count, type,
dest, tag, this) ;
}
/**
* Creates a persistent communication request for a synchronous mode send.
* <p>
* <table>
* <tr><td><tt> buf </tt></td><td> send buffer array </tr>
* <tr><td><tt> offset </tt></td><td> initial offset in send buffer </tr>
* <tr><td><tt> count </tt></td><td> number of items to send </tr>
* <tr><td><tt> datatype </tt></td><td> datatype of each item in send
* buffer </tr>
* <tr><td><tt> dest </tt></td><td> rank of destination </tr>
* <tr><td><tt> tag </tt></td><td> message tag </tr>
* <tr><td><em> returns: </em></td><td> persistent communication
* request </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_SSEND_INIT</tt>.
* <p>
* Further comments as for <tt>Send</tt>.
*/
public Prequest Ssend_init(Object buf,