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$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18 /*
19 * This file is almost a complete re-write for Open MPI compared to the
20 * original mpiJava package. Its license and copyright are listed below.
21 * See <path to ompi/mpi/java/README> for more information.
22 */
23 /*
24 Licensed under the Apache License, Version 2.0 (the "License");
25 you may not use this file except in compliance with the License.
26 You may obtain a copy of the License at
27
28 http://www.apache.org/licenses/LICENSE-2.0
29
30 Unless required by applicable law or agreed to in writing, software
31 distributed under the License is distributed on an "AS IS" BASIS,
32 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 See the License for the specific language governing permissions and
34 limitations under the License.
35 */
36 /*
37 * File : mpi_Intercomm.c
38 * Headerfile : mpi_Intercomm.h
39 * Author : Xinying Li
40 * Created : Thu Apr 9 12:22:15 1998
41 * Revision : $Revision: 1.3 $
42 * Updated : $Date: 2003/01/16 16:39:34 $
43 * Copyright: Northeast Parallel Architectures Center
44 * at Syracuse University 1998
45 */
46
47 #include "ompi_config.h"
48
49 #ifdef HAVE_TARGETCONDITIONALS_H
50 #include <TargetConditionals.h>
51 #endif
52
53 #include "mpi.h"
54 #include "mpi_Intercomm.h"
55 #include "mpiJava.h"
56
57
58 /*
59 * Class: mpi_Intercomm
60 * Method: getRemoteSize_jni
61 * Signature: ()I
62 */
63 JNIEXPORT jint JNICALL Java_mpi_Intercomm_getRemoteSize_1jni(
64 JNIEnv *env, jobject jthis)
65 {
66 int size, rc;
67
68 rc = MPI_Comm_remote_size(
69 (MPI_Comm)((*env)->GetLongField(env,jthis,ompi_java.CommHandle)),
70 &size);
71
72 ompi_java_exceptionCheck(env, rc);
73 return size;
74 }
75
76 /*
77 * Class: mpi_Intercomm
78 * Method: getRemoteGroup_jni
79 * Signature: ()J
80 */
81 JNIEXPORT jlong JNICALL Java_mpi_Intercomm_getRemoteGroup_1jni(
82 JNIEnv *env, jobject jthis)
83 {
84 MPI_Group group;
85
86 int rc = MPI_Comm_remote_group(
87 (MPI_Comm)((*env)->GetLongField(env,jthis,ompi_java.CommHandle)),
88 &group);
89
90 ompi_java_exceptionCheck(env, rc);
91 return (jlong)group;
92 }
93
94 /*
95 * Class: mpi_Intercomm
96 * Method: merge_jni
97 * Signature: (Z)Lmpi/Intracomm;
98 */
99 JNIEXPORT jlong JNICALL Java_mpi_Intercomm_merge_1jni(
100 JNIEnv *env, jobject jthis, jboolean high)
101 {
102 MPI_Comm newintracomm;
103
104 int rc = MPI_Intercomm_merge(
105 (MPI_Comm)((*env)->GetLongField(env,jthis,ompi_java.CommHandle)),
106 high, &newintracomm);
107
108 ompi_java_exceptionCheck(env, rc);
109 return (jlong)newintracomm;
110 }
111
112 /*
113 * Class: mpi_Intercomm
114 * Method: getParent_jni
115 * Signature: ()J
116 */
117 JNIEXPORT jlong JNICALL Java_mpi_Intercomm_getParent_1jni(
118 JNIEnv *env, jclass clazz)
119 {
120 MPI_Comm parent;
121 int rc = MPI_Comm_get_parent(&parent);
122 ompi_java_exceptionCheck(env, rc);
123 return (jlong)parent;
124 }