This source file includes following definitions.
- createWin
- allocateWin
- allocateSharedWin
- createDynamicWin
- getBaseType
- attach
- attach
- detach
- detach
- getGroup
- getGroup
- put
- put
- get
- get
- accumulate
- accumulate
- fence
- fence
- start
- start
- complete
- complete
- post
- post
- waitFor
- waitFor
- test
- test
- lock
- lock
- unlock
- unlock
- setErrhandler
- setErrhandler
- getErrhandler
- getErrhandler
- callErrhandler
- callErrhandler
- createKeyval
- createKeyval_jni
- freeKeyval
- freeKeyval_jni
- setAttr
- setAttr
- getAttr
- getAttr
- deleteAttr
- deleteAttr
- free
- free
- getInfo
- getInfo
- setInfo
- setInfo
- rPut
- rPut
- rGet
- rGet
- rAccumulate
- rAccumulate
- getAccumulate
- getAccumulate
- rGetAccumulate
- rGetAccumulate
- lockAll
- lockAll
- unlockAll
- unlockAll
- sync
- sync
- flush
- flush
- flushAll
- flushAll
- compareAndSwap
- compareAndSwap
- fetchAndOp
- fetchAndOp
- flushLocal
- flushLocal
- flushLocalAll
- flushLocalAll
- getName
- getName
- setName
- setName
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package mpi;
25
26 import java.nio.*;
27
28
29
30
31 public final class Win implements Freeable
32 {
33 private long handle;
34 public static final int WIN_NULL = 0;
35 public static final int FLAVOR_PRIVATE = 0;
36 public static final int FLAVOR_SHARED = 1;
37
38
39
40
41
42
43
44
45
46
47 public Win(Buffer base, int size, int dispUnit, Info info, Comm comm)
48 throws MPIException
49 {
50 if(!base.isDirect())
51 throw new IllegalArgumentException("The buffer must be direct.");
52
53 int baseSize;
54
55 if(base instanceof ByteBuffer)
56 baseSize = 1;
57 else if(base instanceof CharBuffer || base instanceof ShortBuffer)
58 baseSize = 2;
59 else if(base instanceof IntBuffer || base instanceof FloatBuffer)
60 baseSize = 4;
61 else if(base instanceof LongBuffer || base instanceof DoubleBuffer)
62 baseSize = 8;
63 else
64 throw new AssertionError();
65
66 int sizeBytes = size * baseSize,
67 dispBytes = dispUnit * baseSize;
68
69 handle = createWin(base, sizeBytes, dispBytes, info.handle, comm.handle);
70 }
71
72 private native long createWin(
73 Buffer base, int size, int dispUnit, long info, long comm)
74 throws MPIException;
75
76
77
78
79
80
81
82
83
84
85
86 public Win(int size, int dispUnit, Info info, Comm comm, Buffer base, int flavor)
87 throws MPIException
88 {
89 if(!base.isDirect())
90 throw new IllegalArgumentException("The buffer must be direct.");
91
92 int baseSize;
93
94 if(base instanceof ByteBuffer)
95 baseSize = 1;
96 else if(base instanceof CharBuffer || base instanceof ShortBuffer)
97 baseSize = 2;
98 else if(base instanceof IntBuffer || base instanceof FloatBuffer)
99 baseSize = 4;
100 else if(base instanceof LongBuffer || base instanceof DoubleBuffer)
101 baseSize = 8;
102 else
103 throw new AssertionError();
104
105 int sizeBytes = size * baseSize,
106 dispBytes = dispUnit * baseSize;
107
108 if(flavor == 0) {
109 handle = allocateWin(sizeBytes, dispBytes, info.handle, comm.handle, base);
110 } else if(flavor == 1) {
111 handle = allocateSharedWin(sizeBytes, dispBytes, info.handle, comm.handle, base);
112 }
113 }
114
115 private native long allocateWin(
116 int size, int dispUnit, long info, long comm, Buffer base)
117 throws MPIException;
118
119 private native long allocateSharedWin(
120 int size, int dispUnit, long info, long comm, Buffer base)
121 throws MPIException;
122
123
124
125
126
127
128
129 public Win(Info info, Comm comm)
130 throws MPIException
131 {
132 handle = createDynamicWin(info.handle, comm.handle);
133 }
134
135 private native long createDynamicWin(
136 long info, long comm)
137 throws MPIException;
138
139 private int getBaseType(Datatype orgType, Datatype targetType)
140 {
141 int baseType = orgType.baseType;
142
143 if(baseType != targetType.baseType)
144 {
145 throw new IllegalArgumentException(
146 "Both datatype arguments must be constructed "+
147 "from the same predefined datatype.");
148 }
149
150 return baseType;
151 }
152
153
154
155
156
157
158
159 public void attach(Buffer base, int size) throws MPIException
160 {
161 MPI.check();
162 if(!base.isDirect())
163 throw new IllegalArgumentException("The buffer must be direct.");
164
165 int baseSize;
166
167 if(base instanceof ByteBuffer)
168 baseSize = 1;
169 else if(base instanceof CharBuffer || base instanceof ShortBuffer)
170 baseSize = 2;
171 else if(base instanceof IntBuffer || base instanceof FloatBuffer)
172 baseSize = 4;
173 else if(base instanceof LongBuffer || base instanceof DoubleBuffer)
174 baseSize = 8;
175 else
176 throw new AssertionError();
177
178 int sizeBytes = size * baseSize;
179
180 attach(handle, base, sizeBytes);
181 }
182
183 private native void attach(long win, Buffer base, int size) throws MPIException;
184
185
186
187
188
189
190 public void detach(Buffer base) throws MPIException
191 {
192 MPI.check();
193 if(!base.isDirect())
194 throw new IllegalArgumentException("The buffer must be direct.");
195
196 detach(handle, base);
197 }
198
199 private native void detach(long win, Buffer base) throws MPIException;
200
201
202
203
204
205
206 public Group getGroup() throws MPIException
207 {
208 MPI.check();
209 return new Group(getGroup(handle));
210 }
211
212 private native long getGroup(long win) throws MPIException;
213
214
215
216
217
218
219
220
221
222
223
224
225 public void put(Buffer origin, int orgCount, Datatype orgType,
226 int targetRank, int targetDisp, int targetCount,
227 Datatype targetType)
228 throws MPIException
229 {
230 MPI.check();
231
232 if(!origin.isDirect())
233 throw new IllegalArgumentException("The origin must be direct buffer.");
234
235 put(handle, origin, orgCount, orgType.handle,
236 targetRank, targetDisp, targetCount, targetType.handle,
237 getBaseType(orgType, targetType));
238 }
239
240 private native void put(
241 long win, Buffer origin, int orgCount, long orgType,
242 int targetRank, int targetDisp, int targetCount, long targetType,
243 int baseType) throws MPIException;
244
245
246
247
248
249
250
251
252
253
254
255
256 public void get(Buffer origin, int orgCount, Datatype orgType,
257 int targetRank, int targetDisp, int targetCount,
258 Datatype targetType)
259 throws MPIException
260 {
261 MPI.check();
262
263 if(!origin.isDirect())
264 throw new IllegalArgumentException("The origin must be direct buffer.");
265
266 get(handle, origin, orgCount, orgType.handle,
267 targetRank, targetDisp, targetCount, targetType.handle,
268 getBaseType(orgType, targetType));
269 }
270
271 private native void get(
272 long win, Buffer origin, int orgCount, long orgType,
273 int targetRank, int targetDisp, int targetCount, long targetType,
274 int baseType) throws MPIException;
275
276
277
278
279
280
281
282
283
284
285
286
287
288 public void accumulate(Buffer origin, int orgCount, Datatype orgType,
289 int targetRank, int targetDisp, int targetCount,
290 Datatype targetType, Op op)
291 throws MPIException
292 {
293 MPI.check();
294
295 if(!origin.isDirect())
296 throw new IllegalArgumentException("The origin must be direct buffer.");
297
298 accumulate(handle, origin, orgCount, orgType.handle,
299 targetRank, targetDisp, targetCount, targetType.handle,
300 op, op.handle, getBaseType(orgType, targetType));
301 }
302
303 private native void accumulate(
304 long win, Buffer origin, int orgCount, long orgType,
305 int targetRank, int targetDisp, int targetCount, long targetType,
306 Op jOp, long hOp, int baseType) throws MPIException;
307
308
309
310
311
312
313 public void fence(int assertion) throws MPIException
314 {
315 MPI.check();
316 fence(handle, assertion);
317 }
318
319 private native void fence(long win, int assertion) throws MPIException;
320
321
322
323
324
325
326
327 public void start(Group group, int assertion) throws MPIException
328 {
329 MPI.check();
330 start(handle, group.handle, assertion);
331 }
332
333 private native void start(long win, long group, int assertion)
334 throws MPIException;
335
336
337
338
339
340 public void complete() throws MPIException
341 {
342 MPI.check();
343 complete(handle);
344 }
345
346 private native void complete(long win) throws MPIException;
347
348
349
350
351
352
353
354 public void post(Group group, int assertion) throws MPIException
355 {
356 MPI.check();
357 post(handle, group.handle, assertion);
358 }
359
360 private native void post(long win, long group, int assertion)
361 throws MPIException;
362
363
364
365
366
367 public void waitFor() throws MPIException
368 {
369 MPI.check();
370 waitFor(handle);
371 }
372
373 private native void waitFor(long win) throws MPIException;
374
375
376
377
378
379
380 public boolean test() throws MPIException
381 {
382 MPI.check();
383 return test(handle);
384 }
385
386 private native boolean test(long win) throws MPIException;
387
388
389
390
391
392
393
394
395 public void lock(int lockType, int rank, int assertion) throws MPIException
396 {
397 MPI.check();
398 lock(handle, lockType, rank, assertion);
399 }
400
401 private native void lock(long win, int lockType, int rank, int assertion)
402 throws MPIException;
403
404
405
406
407
408
409 public void unlock(int rank) throws MPIException
410 {
411 MPI.check();
412 unlock(handle, rank);
413 }
414
415 private native void unlock(long win, int rank) throws MPIException;
416
417
418
419
420
421
422 public void setErrhandler(Errhandler errhandler) throws MPIException
423 {
424 MPI.check();
425 setErrhandler(handle, errhandler.handle);
426 }
427
428 private native void setErrhandler(long win, long errhandler)
429 throws MPIException;
430
431
432
433
434
435
436 public Errhandler getErrhandler() throws MPIException
437 {
438 MPI.check();
439 return new Errhandler(getErrhandler(handle));
440 }
441
442 private native long getErrhandler(long win);
443
444
445
446
447
448
449 public void callErrhandler(int errorCode) throws MPIException
450 {
451 callErrhandler(handle, errorCode);
452 }
453
454 private native void callErrhandler(long handle, int errorCode)
455 throws MPIException;
456
457
458
459
460
461
462
463 public static int createKeyval() throws MPIException
464 {
465 MPI.check();
466 return createKeyval_jni();
467 }
468
469 private static native int createKeyval_jni() throws MPIException;
470
471
472
473
474
475
476
477 public static void freeKeyval(int keyval) throws MPIException
478 {
479 MPI.check();
480 freeKeyval_jni(keyval);
481 }
482
483 private static native void freeKeyval_jni(int keyval) throws MPIException;
484
485
486
487
488
489
490
491
492 public void setAttr(int keyval, Object value) throws MPIException
493 {
494 MPI.check();
495 setAttr(handle, keyval, MPI.attrSet(value));
496 }
497
498 private native void setAttr(long win, int keyval, byte[] value)
499 throws MPIException;
500
501
502
503
504
505
506
507
508 public Object getAttr(int keyval) throws MPIException
509 {
510 MPI.check();
511 Object obj = getAttr(handle, keyval);
512 return obj instanceof byte[] ? MPI.attrGet((byte[])obj) : obj;
513 }
514
515 private native Object getAttr(long win, int keyval) throws MPIException;
516
517
518
519
520
521
522
523 public void deleteAttr(int keyval) throws MPIException
524 {
525 MPI.check();
526 deleteAttr(handle, keyval);
527 }
528
529 private native void deleteAttr(long win, int keyval) throws MPIException;
530
531
532
533
534
535 @Override public void free() throws MPIException
536 {
537 MPI.check();
538 handle = free(handle);
539 }
540
541 private native long free(long win) throws MPIException;
542
543
544
545
546
547
548 public Info getInfo() throws MPIException
549 {
550 MPI.check();
551 return new Info(getInfo(handle));
552 }
553
554 private native long getInfo(long win)
555 throws MPIException;
556
557
558
559
560
561
562 public void setInfo(Info info) throws MPIException
563 {
564 MPI.check();
565 setInfo(handle, info.handle);
566 }
567
568 private native void setInfo(long win, long info)
569 throws MPIException;
570
571
572
573
574
575
576
577
578
579
580
581
582
583 public final Request rPut(Buffer origin_addr, int origin_count,
584 Datatype origin_datatype, int target_rank, int target_disp,
585 int target_count, Datatype target_datatype)
586 throws MPIException
587 {
588 if(!origin_addr.isDirect())
589 throw new IllegalArgumentException("The origin must be direct buffer.");
590 Request req = new Request(rPut(handle, origin_addr, origin_count,
591 origin_datatype.handle, target_rank, target_disp,
592 target_count, target_datatype.handle, getBaseType(origin_datatype, target_datatype)));
593 req.addSendBufRef(origin_addr);
594 return req;
595 }
596
597 private native long rPut(long win, Buffer origin_addr, int origin_count,
598 long origin_datatype, int target_rank, int target_disp,
599 int target_count, long target_datatype, int baseType)
600 throws MPIException;
601
602
603
604
605
606
607
608
609
610
611
612
613
614 public final Request rGet(Buffer origin, int orgCount, Datatype orgType,
615 int targetRank, int targetDisp, int targetCount,
616 Datatype targetType)
617 throws MPIException
618 {
619 MPI.check();
620
621 if(!origin.isDirect())
622 throw new IllegalArgumentException("The origin must be direct buffer.");
623 Request req = new Request(rGet(handle, origin, orgCount, orgType.handle,
624 targetRank, targetDisp, targetCount, targetType.handle,
625 getBaseType(orgType, targetType)));
626 req.addRecvBufRef(origin);
627 return req;
628 }
629
630 private native long rGet(
631 long win, Buffer origin, int orgCount, long orgType,
632 int targetRank, int targetDisp, int targetCount, long targetType,
633 int baseType) throws MPIException;
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648 public Request rAccumulate(Buffer origin, int orgCount, Datatype orgType,
649 int targetRank, int targetDisp, int targetCount,
650 Datatype targetType, Op op)
651 throws MPIException
652 {
653 MPI.check();
654
655 if(!origin.isDirect())
656 throw new IllegalArgumentException("The origin must be direct buffer.");
657 Request req = new Request(rAccumulate(handle, origin, orgCount, orgType.handle,
658 targetRank, targetDisp, targetCount, targetType.handle,
659 op, op.handle, getBaseType(orgType, targetType)));
660 req.addSendBufRef(origin);
661 return req;
662 }
663
664 private native long rAccumulate(
665 long win, Buffer origin, int orgCount, long orgType,
666 int targetRank, int targetDisp, int targetCount, long targetType,
667 Op jOp, long hOp, int baseType) throws MPIException;
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685 public void getAccumulate(Buffer origin, int orgCount, Datatype orgType,
686 Buffer resultAddr, int resultCount, Datatype resultType,
687 int targetRank, int targetDisp, int targetCount,
688 Datatype targetType, Op op)
689 throws MPIException
690 {
691 MPI.check();
692
693 if(!origin.isDirect())
694 throw new IllegalArgumentException("The origin must be direct buffer.");
695
696 getAccumulate(handle, origin, orgCount, orgType.handle,
697 resultAddr, resultCount, resultType.handle,
698 targetRank, targetDisp, targetCount, targetType.handle,
699 op, op.handle, getBaseType(orgType, targetType));
700 }
701
702 private native void getAccumulate(
703 long win, Buffer origin, int orgCount, long orgType,
704 Buffer resultAddr, int resultCount, long resultType,
705 int targetRank, int targetDisp, int targetCount, long targetType,
706 Op jOp, long hOp, int baseType) throws MPIException;
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725 public Request rGetAccumulate(Buffer origin, int orgCount, Datatype orgType,
726 Buffer resultAddr, int resultCount, Datatype resultType,
727 int targetRank, int targetDisp, int targetCount,
728 Datatype targetType, Op op)
729 throws MPIException
730 {
731 MPI.check();
732
733 if(!origin.isDirect())
734 throw new IllegalArgumentException("The origin must be direct buffer.");
735 Request req = new Request(rGetAccumulate(handle, origin, orgCount, orgType.handle,
736 resultAddr, resultCount, resultType.handle,
737 targetRank, targetDisp, targetCount, targetType.handle,
738 op, op.handle, getBaseType(orgType, targetType)));
739 req.addRecvBufRef(origin);
740 return req;
741 }
742
743 private native long rGetAccumulate(
744 long win, Buffer origin, int orgCount, long orgType,
745 Buffer resultAddr, int resultCount, long resultType,
746 int targetRank, int targetDisp, int targetCount, long targetType,
747 Op jOp, long hOp, int baseType) throws MPIException;
748
749
750
751
752
753
754 public void lockAll(int assertion) throws MPIException
755 {
756 MPI.check();
757 lockAll(handle, assertion);
758 }
759
760 private native void lockAll(long win, int assertion)
761 throws MPIException;
762
763
764
765
766
767 public void unlockAll() throws MPIException
768 {
769 MPI.check();
770 unlockAll(handle);
771 }
772
773 private native void unlockAll(long win) throws MPIException;
774
775
776
777
778
779 public void sync() throws MPIException
780 {
781 MPI.check();
782 sync(handle);
783 }
784
785 private native void sync(long win) throws MPIException;
786
787
788
789
790
791
792 public void flush(int targetRank) throws MPIException
793 {
794 MPI.check();
795 flush(handle, targetRank);
796 }
797
798 private native void flush(long win, int targetRank) throws MPIException;
799
800
801
802
803
804 public void flushAll() throws MPIException
805 {
806 MPI.check();
807 flushAll(handle);
808 }
809
810 private native void flushAll(long win) throws MPIException;
811
812
813
814
815
816
817
818
819
820
821
822
823 public void compareAndSwap(Buffer origin, Buffer compareAddr, Buffer resultAddr,
824 Datatype targetType, int targetRank, int targetDisp)
825 throws MPIException
826 {
827 MPI.check();
828
829 if(!origin.isDirect())
830 throw new IllegalArgumentException("The origin must be direct buffer.");
831
832 compareAndSwap(handle, origin, compareAddr, resultAddr,
833 targetType.handle, targetRank, targetDisp);
834 }
835
836 private native void compareAndSwap(
837 long win, Buffer origin, Buffer compareAddr, Buffer resultAddr,
838 long targetType, int targetRank, int targetDisp) throws MPIException;
839
840
841
842
843
844
845
846
847
848
849
850
851 public void fetchAndOp(Buffer origin, Buffer resultAddr, Datatype dataType,
852 int targetRank, int targetDisp, Op op)
853 throws MPIException
854 {
855 MPI.check();
856
857 if(!origin.isDirect())
858 throw new IllegalArgumentException("The origin must be direct buffer.");
859
860 fetchAndOp(handle, origin, resultAddr, dataType.handle, targetRank,
861 targetDisp, op, op.handle, getBaseType(dataType, dataType));
862 }
863
864 private native void fetchAndOp(
865 long win, Buffer origin, Buffer resultAddr, long targetType, int targetRank,
866 int targetDisp, Op jOp, long hOp, int baseType) throws MPIException;
867
868
869
870
871
872
873
874 public void flushLocal(int targetRank) throws MPIException
875 {
876 MPI.check();
877 flushLocal(handle, targetRank);
878 }
879
880 private native void flushLocal(long win, int targetRank) throws MPIException;
881
882
883
884
885
886
887 public void flushLocalAll() throws MPIException
888 {
889 MPI.check();
890 flushLocalAll(handle);
891 }
892
893 private native void flushLocalAll(long win) throws MPIException;
894
895
896
897
898
899
900 public String getName() throws MPIException
901 {
902 MPI.check();
903 return getName(handle);
904 }
905
906 private native String getName(long handle) throws MPIException;
907
908
909
910
911
912
913 public void setName(String name) throws MPIException
914 {
915 MPI.check();
916 setName(handle, name);
917 }
918
919 private native void setName(long handle, String name) throws MPIException;
920
921 }