-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrequest.java
More file actions
204 lines (156 loc) · 5.37 KB
/
Copy pathPrequest.java
File metadata and controls
204 lines (156 loc) · 5.37 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* File : Prequest.java
* Author : Sang Lim, Xinying Li, Bryan Carpenter
* Created : Thu Apr 9 12:22:15 1998
* Revision : $Revision: 1.11 $
* Updated : $Date: 2001/10/22 21:07:55 $
* Copyright: Northeast Parallel Architectures Center
* at Syracuse University 1998
*/
/*
* Note: in the end there is no sensible way to use the native
* persistent requests here. For every `start'/`wait' cycle you need
* to do `get...Elements', `release...Elements', otherwise the behaviour
* is wrong if pinning isn't supported (because then get/release ops
* need active copying to move values between C and Java).
*
* (Even if pinning is supported, the arrays would have to be pinned
* almost permanently, which presumably isn't a good thing.)
*/
package mpi;
public class Prequest extends Request {
protected final static int MODE_STANDARD = 0 ;
protected final static int MODE_BUFFERED = 1 ;
protected final static int MODE_SYNCHRONOUS = 2 ;
protected final static int MODE_READY = 3 ;
private int src ;
/**
* Constructor used by `Send_init', etc.
*/
protected Prequest(int mode,
Object buf, int offset, int count, Datatype type,
int dest, int tag, Comm comm) {
opTag = Request.OP_SEND ;
this.mode = mode ;
this.buf = buf;
this.offset = offset;
this.count = count;
this.type = type;
this.dest = dest;
this.tag = tag;
this.comm = comm ;
if(type.isObject()) {
typeTag = Request.TYPE_OBJECT ;
length_buf = new int [2] ;
hdrReq = new Request() ;
}
else
typeTag = Request.TYPE_NORMAL ;
}
/**
* Constructor used by `Recv_init'.
*/
protected Prequest(Object buf, int offset, int count, Datatype type,
int source, int tag, Comm comm) {
opTag = Request.OP_RECV ;
this.buf = buf;
this.offset = offset;
this.count = count;
this.type = type;
this.src = source;
this.tag = tag;
this.comm = comm;
if(type.isObject()) {
typeTag = Request.TYPE_OBJECT ;
length_buf = new int [2] ;
}
else
typeTag = Request.TYPE_NORMAL ;
}
/**
* Activate a persistent communication request.
* Java binding of the MPI operation <tt>MPI_START</tt>.
* The communication is completed by using the request in
* one of the <tt>wait</tt> or <tt>test</tt> operations.
* On successful completion the request becomes inactive again.
* It can be reactivated by a further call to <tt>Start</tt>.
*/
public void Start() throws MPIException {
switch(typeTag) {
case TYPE_NORMAL :
switch(opTag) {
case OP_SEND :
switch(mode) {
case MODE_STANDARD :
comm.Isend(buf, offset, count, type, dest, tag, this);
break;
case MODE_BUFFERED :
comm.Ibsend(buf, offset, count, type, dest, tag, this);
break;
case MODE_SYNCHRONOUS :
comm.Issend(buf, offset, count, type, dest, tag, this);
break;
case MODE_READY :
comm.Irsend(buf, offset, count, type, dest, tag, this);
break;
}
break ;
case OP_RECV :
comm.Irecv(buf, offset, count, type, src, tag, this) ;
break ;
}
break ;
case TYPE_OBJECT :
switch(opTag) {
case OP_SEND :
byte [] byte_buf = comm.Object_Serialize(buf,offset,count,type);
length_buf[0] = byte_buf.length;
length_buf[1] = count ;
switch(mode) {
case MODE_STANDARD :
comm.Isend(length_buf, 0, 2, MPI.INT, dest, tag, hdrReq) ;
comm.Isend(byte_buf, 0, byte_buf.length,
MPI.BYTE, dest, tag, this);
break;
case MODE_BUFFERED :
comm.Ibsend(length_buf, 0, 2, MPI.INT, dest, tag, hdrReq) ;
comm.Ibsend(byte_buf, 0, byte_buf.length,
MPI.BYTE, dest, tag, this);
break;
case MODE_SYNCHRONOUS :
comm.Issend(length_buf, 0, 2, MPI.INT, dest, tag, hdrReq) ;
comm.Isend(byte_buf, 0, byte_buf.length,
MPI.BYTE, dest, tag, this);
break;
case MODE_READY :
comm.Irsend(length_buf, 0, 2, MPI.INT, dest, tag, hdrReq) ;
comm.Isend(byte_buf, 0, byte_buf.length,
MPI.BYTE, dest, tag, this);
break;
}
break ;
case OP_RECV :
comm.Irecv(length_buf, 0, 2, MPI.INT, src, tag, this) ;
break ;
}
break ;
}
}
//private native void start();
/**
* Activate a list of communication requests.
* <p>
* <table>
* <tr><td><tt> array_of_requests </tt></td><td> array of requests </tr>
* </table>
* <p>
* Java binding of the MPI operation <tt>MPI_STARTALL</tt>.
*/
public static void Startall(Prequest [] array_of_request)
throws MPIException {
int req_length = array_of_request.length ;
for (int i = 0; i<req_length; i++)
array_of_request[i].Start() ;
}
//private static native void startall(Prequest [] array_of_request);
}