1
1
openmpi/examples/oshmem_symmetric_data.java
Oscar Vega-Gisbert c58900da95 Java-oshmem: some examples
This commit was SVN r31844.
2014-05-20 21:47:45 +00:00

50 строки
1.2 KiB
Java

import shmem.*;
import java.nio.*;
public class oshmem_symmetric_data
{
private static final int SIZE = 16;
public static void main(String[] args) throws ShMemException
{
ShMem.startPEs(0);
int numPE = ShMem.getNumPEs(),
myPE = ShMem.getMyPE();
int[] source = new int[SIZE];
Addr target = new Addr(4 * SIZE); // int is 4 bytes
if(myPE == 0)
{
// initialize array
for(int i = 0; i < SIZE; i++)
source[i] = i;
// local, not symmetric
// static makes it symmetric
// put "size" words into target on each PE
for(int i = 1; i < numPE; i++)
target.putInt(source, SIZE, i);
}
ShMem.barrierAll(); // sync sender and receiver
if(myPE != 0)
{
StringBuilder sb = new StringBuilder();
sb.append("Target on PE "+ myPE +" is \t");
IntBuffer buf = target.asIntBuffer();
for(int i = 0; i < SIZE; i++)
sb.append(buf.get(i) +" \t");
sb.append('\n');
System.out.print(sb);
}
ShMem.barrierAll(); // sync before exiting
target.free();
}
}