This source file includes following definitions.
- init
- setBasic
- setBasic
- getDatatype
- getLb
- getExtent
- getLbExtent
- getLbExtent
- getTrueLb
- getTrueExtent
- getTrueLbExtent
- getTrueLbExtent
- getSize
- getSize
- commit
- commit
- free
- free
- isNull
- clone
- dup
- dup
- createContiguous
- getContiguous
- createVector
- getVector
- createHVector
- getHVector
- createIndexed
- getIndexed
- createHIndexed
- getHIndexed
- createStruct
- getStruct
- createResized
- getResized
- setName
- setName
- getName
- getName
- createKeyval
- createKeyval_jni
- freeKeyval
- freeKeyval_jni
- setAttr
- setAttr
- getAttr
- getAttr
- deleteAttr
- deleteAttr
- getOffset
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 package mpi;
50
51 import java.nio.*;
52
53
54
55
56 public final class Datatype implements Freeable, Cloneable
57 {
58 protected long handle;
59 protected int baseType;
60 protected int baseSize;
61
62
63 private int lb, extent, trueLb, trueExtent;
64
65 protected static final int NULL = 0;
66 protected static final int BYTE = 1;
67 protected static final int CHAR = 2;
68 protected static final int SHORT = 3;
69 protected static final int BOOLEAN = 4;
70 protected static final int INT = 5;
71 protected static final int LONG = 6;
72 protected static final int FLOAT = 7;
73 protected static final int DOUBLE = 8;
74 protected static final int PACKED = 9;
75 protected static final int INT2 = 10;
76 protected static final int SHORT_INT = 11;
77 protected static final int LONG_INT = 12;
78 protected static final int FLOAT_INT = 13;
79 protected static final int DOUBLE_INT = 14;
80 protected static final int FLOAT_COMPLEX = 15;
81 protected static final int DOUBLE_COMPLEX = 16;
82
83 static
84 {
85 init();
86 }
87
88 private static native void init();
89
90
91
92
93
94
95
96
97
98
99 protected Datatype()
100 {
101 }
102
103 protected void setBasic(int type)
104 {
105 baseType = type;
106 handle = getDatatype(type);
107 baseSize = type == NULL ? 0 : getSize(handle);
108 }
109
110 protected void setBasic(int type, Datatype oldType)
111 {
112 baseType = oldType.baseType;
113 handle = getDatatype(type);
114 baseSize = oldType.baseSize;
115 }
116
117 private static native long getDatatype(int type);
118
119
120
121
122 private Datatype(Datatype oldType, long handle)
123 {
124 baseType = oldType.baseType;
125 baseSize = oldType.baseSize;
126 this.handle = handle;
127 }
128
129
130
131
132 private Datatype(int baseType, int baseSize, long handle)
133 {
134 this.baseType = baseType;
135 this.baseSize = baseSize;
136 this.handle = handle;
137 }
138
139
140
141
142
143
144
145 public int getLb() throws MPIException
146 {
147 if(extent == 0)
148 getLbExtent();
149
150 return lb;
151 }
152
153
154
155
156
157
158
159 public int getExtent() throws MPIException
160 {
161 if(extent == 0)
162 getLbExtent();
163
164 return extent;
165 }
166
167 private void getLbExtent() throws MPIException
168 {
169 MPI.check();
170 int lbExt[] = new int[2];
171 getLbExtent(handle, lbExt);
172 lb = lbExt[0] / baseSize;
173 extent = lbExt[1] / baseSize;
174 }
175
176 private native void getLbExtent(long handle, int[] lbExt);
177
178
179
180
181
182
183
184 public int getTrueLb() throws MPIException
185 {
186 if(trueExtent == 0)
187 getTrueLbExtent();
188
189 return trueLb;
190 }
191
192
193
194
195
196
197
198 public int getTrueExtent() throws MPIException
199 {
200 if(trueExtent == 0)
201 getTrueLbExtent();
202
203 return trueExtent;
204 }
205
206 private void getTrueLbExtent() throws MPIException
207 {
208 MPI.check();
209 int lbExt[] = new int[2];
210 getTrueLbExtent(handle, lbExt);
211 trueLb = lbExt[0] / baseSize;
212 trueExtent = lbExt[1] / baseSize;
213 }
214
215 private native void getTrueLbExtent(long handle, int[] lbExt);
216
217
218
219
220
221
222
223
224 public int getSize() throws MPIException
225 {
226 MPI.check();
227 return getSize(handle) / baseSize;
228 }
229
230 private native int getSize(long type);
231
232
233
234
235
236
237 public void commit() throws MPIException
238 {
239 MPI.check();
240 commit(handle);
241 }
242
243 private native void commit(long type);
244
245
246
247
248
249
250 @Override public void free() throws MPIException
251 {
252 MPI.check();
253 handle = free(handle);
254 }
255
256 private native long free(long type) throws MPIException;
257
258
259
260
261
262 public boolean isNull()
263 {
264 return handle == MPI.DATATYPE_NULL.handle;
265 }
266
267
268
269
270
271
272
273 @Override public Datatype clone()
274 {
275 try
276 {
277 return dup();
278 }
279 catch(MPIException e)
280 {
281 throw new RuntimeException(e.getMessage());
282 }
283 }
284
285
286
287
288
289
290 public Datatype dup() throws MPIException
291 {
292 MPI.check();
293 return new Datatype(this, dup(handle));
294 }
295
296 private native long dup(long type) throws MPIException;
297
298
299
300
301
302
303
304
305
306
307
308
309 public static Datatype createContiguous(int count, Datatype oldType)
310 throws MPIException
311 {
312 MPI.check();
313 return new Datatype(oldType, getContiguous(count, oldType.handle));
314 }
315
316 private static native long getContiguous(int count, long oldType);
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331 public static Datatype createVector(int count, int blockLength,
332 int stride, Datatype oldType)
333 throws MPIException
334 {
335 MPI.check();
336 long handle = getVector(count, blockLength, stride, oldType.handle);
337 return new Datatype(oldType, handle);
338 }
339
340 private static native long getVector(
341 int count, int blockLength, int stride, long oldType)
342 throws MPIException;
343
344
345
346
347
348
349
350
351
352
353
354
355
356 public static Datatype createHVector(int count, int blockLength,
357 int stride, Datatype oldType)
358 throws MPIException
359 {
360 MPI.check();
361 long handle = getHVector(count, blockLength, stride, oldType.handle);
362 return new Datatype(oldType, handle);
363 }
364
365 private static native long getHVector(
366 int count, int blockLength, int stride, long oldType)
367 throws MPIException;
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384 public static Datatype createIndexed(int[] blockLengths,
385 int[] displacements, Datatype oldType)
386 throws MPIException
387 {
388 MPI.check();
389 long handle = getIndexed(blockLengths, displacements, oldType.handle);
390 return new Datatype(oldType, handle);
391 }
392
393 private static native long getIndexed(
394 int[] blockLengths, int[] displacements, long oldType)
395 throws MPIException;
396
397
398
399
400
401
402
403
404
405
406
407
408 public static Datatype createHIndexed(int[] blockLengths,
409 int[] displacements, Datatype oldType)
410 throws MPIException
411 {
412 MPI.check();
413 long handle = getHIndexed(blockLengths, displacements, oldType.handle);
414 return new Datatype(oldType, handle);
415 }
416
417 private static native long getHIndexed(
418 int[] blockLengths, int[] displacements, long oldType)
419 throws MPIException;
420
421
422
423
424
425
426
427
428
429
430
431
432
433 public static Datatype createStruct(int[] blockLengths,
434 int[] displacements, Datatype[] types)
435 throws MPIException
436 {
437 MPI.check();
438 long handle = getStruct(blockLengths, displacements, types);
439 return new Datatype(MPI.BYTE, handle);
440 }
441
442 private static native long getStruct(
443 int[] blockLengths, int[] displacements, Datatype[] types)
444 throws MPIException;
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460 public static Datatype createResized(Datatype oldType, int lb, int extent)
461 throws MPIException
462 {
463 MPI.check();
464 long handle = getResized(oldType.handle, lb, extent);
465 return new Datatype(oldType, handle);
466 }
467
468 private static native long getResized(long oldType, int lb, int extent);
469
470
471
472
473
474
475 public void setName(String name) throws MPIException
476 {
477 MPI.check();
478 setName(handle, name);
479 }
480
481 private native void setName(long handle, String name) throws MPIException;
482
483
484
485
486
487
488 public String getName() throws MPIException
489 {
490 MPI.check();
491 return getName(handle);
492 }
493
494 private native String getName(long handle) throws MPIException;
495
496
497
498
499
500
501
502 public static int createKeyval() throws MPIException
503 {
504 MPI.check();
505 return createKeyval_jni();
506 }
507
508 private static native int createKeyval_jni() throws MPIException;
509
510
511
512
513
514
515
516 public static void freeKeyval(int keyval) throws MPIException
517 {
518 MPI.check();
519 freeKeyval_jni(keyval);
520 }
521
522 private static native void freeKeyval_jni(int keyval) throws MPIException;
523
524
525
526
527
528
529
530
531 public void setAttr(int keyval, Object value) throws MPIException
532 {
533 MPI.check();
534 setAttr(handle, keyval, MPI.attrSet(value));
535 }
536
537 private native void setAttr(long type, int keyval, byte[] value)
538 throws MPIException;
539
540
541
542
543
544
545
546
547 public Object getAttr(int keyval) throws MPIException
548 {
549 MPI.check();
550 Object obj = getAttr(handle, keyval);
551 return obj instanceof byte[] ? MPI.attrGet((byte[])obj) : obj;
552 }
553
554 private native Object getAttr(long type, int keyval) throws MPIException;
555
556
557
558
559
560
561
562 public void deleteAttr(int keyval) throws MPIException
563 {
564 MPI.check();
565 deleteAttr(handle, keyval);
566 }
567
568 private native void deleteAttr(long type, int keyval) throws MPIException;
569
570
571
572
573
574
575 protected int getOffset(Object buffer)
576 {
577 return baseSize * ((Buffer)buffer).arrayOffset();
578 }
579
580 }