File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,29 @@ JNIEXPORT jlong JNICALL Java_mpi_Win_create_dynamicWin(
5555 return (jlong )win ;
5656}
5757
58+ JNIEXPORT void JNICALL Java_mpi_Win_attach (
59+ JNIEnv * env , jobject jthis , jobject jBase ,
60+ jint size )
61+ {
62+ void * base = (* env )-> GetDirectBufferAddress (env , jBase );
63+ MPI_Win win ;
64+
65+ int rc = MPI_Win_attach (win , base , (MPI_Aint )size );
66+
67+ ompi_java_exceptionCheck (env , rc );
68+ }
69+
70+ JNIEXPORT void JNICALL Java_mpi_Win_detach (
71+ JNIEnv * env , jobject jthis , jobject jBase )
72+ {
73+ void * base = (* env )-> GetDirectBufferAddress (env , jBase );
74+ MPI_Win win ;
75+
76+ int rc = MPI_Win_detach (win , base );
77+
78+ ompi_java_exceptionCheck (env , rc );
79+ }
80+
5881JNIEXPORT jlong JNICALL Java_mpi_Win_getGroup (
5982 JNIEnv * env , jobject jthis , jlong win )
6083{
Original file line number Diff line number Diff line change @@ -97,6 +97,51 @@ private int getBaseType(Datatype orgType, Datatype targetType)
9797 return baseType ;
9898}
9999
100+ /**
101+ * Java binding of {@code MPI_WIN_ATTACH}.
102+ * @param assertion program assertion
103+ */
104+ public void attach (Buffer base , int size ) throws MPIException
105+ {
106+ MPI .check ();
107+ if (!base .isDirect ())
108+ throw new IllegalArgumentException ("The buffer must be direct." );
109+
110+ int baseSize ;
111+
112+ if (base instanceof ByteBuffer )
113+ baseSize = 1 ;
114+ else if (base instanceof CharBuffer || base instanceof ShortBuffer )
115+ baseSize = 2 ;
116+ else if (base instanceof IntBuffer || base instanceof FloatBuffer )
117+ baseSize = 4 ;
118+ else if (base instanceof LongBuffer || base instanceof DoubleBuffer )
119+ baseSize = 8 ;
120+ else
121+ throw new AssertionError ();
122+
123+ int sizeBytes = size * baseSize ,
124+
125+ attach (handle , base , size );
126+ }
127+
128+ private native void attach (long win , Buffer base , int size ) throws MPIException ;
129+
130+ /**
131+ * Java binding of {@code MPI_WIN_DETACH}.
132+ * @param assertion program assertion
133+ */
134+ public void detach (Buffer base ) throws MPIException
135+ {
136+ MPI .check ();
137+ if (!base .isDirect ())
138+ throw new IllegalArgumentException ("The buffer must be direct." );
139+
140+ detach (handle , base );
141+ }
142+
143+ private native void detach (long win , Buffer base ) throws MPIException ;
144+
100145/**
101146 * Java binding of the MPI operation {@code MPI_GET_GROUP}.
102147 * @return group of processes which share access to the window
You can’t perform that action at this time.
0 commit comments