1 /*
2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2015 Research Organization for Information Science
13 * and Technology (RIST). All rights reserved.
14 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
15 * reserved.
16 * Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
17 * $COPYRIGHT$
18 *
19 * Additional copyrights may follow
20 *
21 * $HEADER$
22 */
23
24 package mpi;
25
26 import java.nio.*;
27
28 /**
29 * This class represents {@code MPI_Win}.
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 * Java binding of {@code MPI_WIN_CREATE}.
40 * @param base initial address of window
41 * @param size size of window (buffer elements)
42 * @param dispUnit local unit size for displacements (buffer elements)
43 * @param info info object
44 * @param comm communicator
45 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_ALLOCATE} and {@code MPI_WIN_ALLOCATE_SHARED}.
78 * @param size size of window (buffer elements)
79 * @param dispUnit local unit size for displacements (buffer elements)
80 * @param info info object
81 * @param comm communicator
82 * @param base initial address of window
83 * @param flavor FLAVOR_PRIVATE or FLAVOR_SHARED
84 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_CREATE_DYNAMIC}.
125 * @param info info object
126 * @param comm communicator
127 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_ATTACH}.
155 * @param base initial address of window
156 * @param size size of window (buffer elements)
157 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_DETACH}.
187 * @param base initial address of window
188 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_GET_GROUP}.
203 * @return group of processes which share access to the window
204 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_PUT}.
216 * @param origin origin buffer
217 * @param orgCount number of entries in origin buffer
218 * @param orgType datatype of each entry in origin buffer
219 * @param targetRank rank of target
220 * @param targetDisp displacement from start of window to target buffer
221 * @param targetCount number of entries in target buffer
222 * @param targetType datatype of each entry in target buffer
223 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_GET}.
247 * @param origin origin buffer
248 * @param orgCount number of entries in origin buffer
249 * @param orgType datatype of each entry in origin buffer
250 * @param targetRank rank of target
251 * @param targetDisp displacement from start of window to target buffer
252 * @param targetCount number of entries in target buffer
253 * @param targetType datatype of each entry in target buffer
254 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_ACCUMULATE}.
278 * @param origin origin buffer
279 * @param orgCount number of entries in origin buffer
280 * @param orgType datatype of each entry in origin buffer
281 * @param targetRank rank of target
282 * @param targetDisp displacement from start of window to target buffer
283 * @param targetCount number of entries in target buffer
284 * @param targetType datatype of each entry in target buffer
285 * @param op reduce operation
286 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_FENCE}.
310 * @param assertion program assertion
311 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_START}.
323 * @param group group of target processes
324 * @param assertion program assertion
325 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_COMPLETE}.
338 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_POST}.
350 * @param group group of origin processes
351 * @param assertion program assertion
352 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_WAIT}.
365 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_TEST}.
377 * @return true if success
378 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_LOCK}.
390 * @param lockType either MPI.LOCK_EXCLUSIVE or MPI.LOCK_SHARED
391 * @param rank rank of locked window
392 * @param assertion program assertion
393 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_UNLOCK}.
406 * @param rank rank of window
407 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_SET_ERRHANDLER}.
419 * @param errhandler new MPI error handler for window
420 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_GET_ERRHANDLER}.
433 * @return MPI error handler currently associated with window
434 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_CALL_ERRHANDLER}.
446 * @param errorCode error code
447 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Create a new attribute key.
459 * <p>Java binding of the MPI operation {@code MPI_WIN_CREATE_KEYVAL}.
460 * @return attribute key for future access
461 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Frees an attribute key.
473 * <p>Java binding of the MPI operation {@code MPI_WIN_FREE_KEYVAL}.
474 * @param keyval attribute key
475 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Stores attribute value associated with a key.
487 * <p>Java binding of the MPI operation {@code MPI_WIN_SET_ATTR}.
488 * @param keyval attribute key
489 * @param value attribute value
490 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Retrieves attribute value by key.
503 * <p>Java binding of the MPI operation {@code MPI_WIN_GET_ATTR}.
504 * @param keyval attribute key
505 * @return attribute value or null if no attribute is associated with the key.
506 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Deletes an attribute value associated with a key.
519 * <p>Java binding of the MPI operation {@code MPI_WIN_DELETE_ATTR}.
520 * @param keyval attribute key
521 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_WIN_FREE}.
533 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_GET_INFO}.
545 * @return Info Info object associated with this window
546 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_SET_INFO}.
559 * @param info the new info
560 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * <p>Java binding of the MPI operation {@code MPI_RPUT}.
573 * @param origin_addr initial address of origin buffer
574 * @param origin_count number of entries in origin buffer
575 * @param origin_datatype datatype of each entry in origin buffer
576 * @param target_rank rank of target
577 * @param target_disp displacement from start of window to target buffer
578 * @param target_count number of entries in target buffer
579 * @param target_datatype datatype of each entry in target buffer
580 * @return RMA request
581 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_RGET}.
604 * @param origin origin buffer
605 * @param orgCount number of entries in origin buffer
606 * @param orgType datatype of each entry in origin buffer
607 * @param targetRank rank of target
608 * @param targetDisp displacement from start of window to target buffer
609 * @param targetCount number of entries in target buffer
610 * @param targetType datatype of each entry in target buffer
611 * @return RMA request
612 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_RACCUMULATE}.
637 * @param origin origin buffer
638 * @param orgCount number of entries in origin buffer
639 * @param orgType datatype of each entry in origin buffer
640 * @param targetRank rank of target
641 * @param targetDisp displacement from start of window to target buffer
642 * @param targetCount number of entries in target buffer
643 * @param targetType datatype of each entry in target buffer
644 * @param op reduce operation
645 * @return RMA request
646 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_GET_ACCUMULATE}.
671 * @param origin origin buffer
672 * @param orgCount number of entries in origin buffer
673 * @param orgType datatype of each entry in origin buffer
674 * @param resultAddr result buffer
675 * @param resultCount number of entries in result buffer
676 * @param resultType datatype of each entry in result buffer
677 * @param targetRank rank of target
678 * @param targetDisp displacement from start of window to target buffer
679 * @param targetCount number of entries in target buffer
680 * @param targetType datatype of each entry in target buffer
681 * @param op reduce operation
682 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_RGET_ACCUMULATE}.
710 * @param origin origin buffer
711 * @param orgCount number of entries in origin buffer
712 * @param orgType datatype of each entry in origin buffer
713 * @param resultAddr result buffer
714 * @param resultCount number of entries in result buffer
715 * @param resultType datatype of each entry in result buffer
716 * @param targetRank rank of target
717 * @param targetDisp displacement from start of window to target buffer
718 * @param targetCount number of entries in target buffer
719 * @param targetType datatype of each entry in target buffer
720 * @param op reduce operation
721 * @return RMA request
722 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_LOCK_ALL}.
751 * @param assertion program assertion
752 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_UNLOCK_ALL}.
765 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_SYNC}.
777 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_FLUSH}.
789 * @param targetRank rank of target window
790 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_FLUSH_ALL}.
802 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_COMPARE_AND_SWAP}.
814 * @param origin origin buffer
815 * @param compareAddr compare buffer
816 * @param resultAddr result buffer
817 * @param targetType datatype of each entry in target buffer
818 * @param targetRank rank of target
819 * @param targetDisp displacement from start of window to target buffer
820 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of {@code MPI_FETCH_AND_OP}.
842 * @param origin origin buffer
843 * @param resultAddr result buffer
844 * @param dataType datatype of entry in origin, result, and target buffers
845 * @param targetRank rank of target
846 * @param targetDisp displacement from start of window to target buffer
847 * @param op reduce operation
848 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_FLUSH_LOCAL}.
870 * @param targetRank rank of target window
871 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_FLUSH_LOCAL_ALL}.
884 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_GET_NAME}.
897 * @return the name associated with this window
898 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 * Java binding of the MPI operation {@code MPI_WIN_SET_NAME}.
910 * @param name the name to associate with this window
911 * @throws MPIException Signals that an MPI exception of some sort has occurred.
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 } // Win