@@ -120,40 +120,40 @@ function Abort(comm::Comm, errcode::Integer)
120
120
end
121
121
122
122
function Initialized ()
123
- flag = Array ( Cint, 1 )
123
+ flag = Ref { Cint} ( )
124
124
ccall (MPI_INITIALIZED, Void, (Ptr{Cint}, Ptr{Cint}), flag, & 0 )
125
- flag[1 ] != 0
125
+ flag[] != 0
126
126
end
127
127
128
128
function Finalized ()
129
- flag = Array ( Cint, 1 )
129
+ flag = Ref { Cint} ( )
130
130
ccall (MPI_FINALIZED, Void, (Ptr{Cint}, Ptr{Cint}), flag, & 0 )
131
- flag[1 ] != 0
131
+ flag[] != 0
132
132
end
133
133
134
134
function Comm_dup (comm:: Comm )
135
- newcomm = Array ( Cint, 1 )
135
+ newcomm = Ref { Cint} ( )
136
136
ccall (MPI_COMM_DUP, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
137
137
& comm. val, newcomm, & 0 )
138
- MPI. Comm (newcomm[1 ])
138
+ MPI. Comm (newcomm[])
139
139
end
140
140
141
141
function Comm_free (comm:: Comm )
142
142
ccall (MPI_COMM_FREE, Void, (Ptr{Cint}, Ptr{Cint}), & comm. val, & 0 )
143
143
end
144
144
145
145
function Comm_rank (comm:: Comm )
146
- rank = Array ( Cint, 1 )
146
+ rank = Ref { Cint} ( )
147
147
ccall (MPI_COMM_RANK, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
148
148
& comm. val, rank, & 0 )
149
- Int (rank[1 ])
149
+ Int (rank[])
150
150
end
151
151
152
152
function Comm_size (comm:: Comm )
153
- size = Array ( Cint, 1 )
153
+ size = Ref { Cint} ( )
154
154
ccall (MPI_COMM_SIZE, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
155
155
& comm. val, size, & 0 )
156
- Int (size[1 ])
156
+ Int (size[])
157
157
end
158
158
159
159
# Point-to-point communication
@@ -167,22 +167,22 @@ function Probe(src::Integer, tag::Integer, comm::Comm)
167
167
end
168
168
169
169
function Iprobe (src:: Integer , tag:: Integer , comm:: Comm )
170
- flag = Array ( Cint, 1 )
170
+ flag = Ref { Cint} ( )
171
171
stat = Status ()
172
172
ccall (MPI_IPROBE, Void,
173
173
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
174
174
& src, & tag, & comm. val, flag, stat. val, & 0 )
175
- if flag[1 ] == 0
176
- return ( false , nothing )
175
+ if flag[] == 0
176
+ return false , nothing
177
177
end
178
- ( true , stat)
178
+ true , stat
179
179
end
180
180
181
181
function Get_count {T<:MPIDatatype} (stat:: Status , :: Type{T} )
182
- count = Array ( Cint, 1 )
182
+ count = Ref { Cint} ( )
183
183
ccall (MPI_GET_COUNT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
184
184
stat. val, & mpitype (T), count, & 0 )
185
- Int (count[1 ])
185
+ Int (count[])
186
186
end
187
187
188
188
function Send {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
@@ -210,12 +210,12 @@ end
210
210
211
211
function Isend {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
212
212
dest:: Integer , tag:: Integer , comm:: Comm )
213
- rval = Array ( Cint, 1 )
213
+ rval = Ref { Cint} ( )
214
214
ccall (MPI_ISEND, Void,
215
215
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
216
216
Ptr{Cint}, Ptr{Cint}),
217
217
buf, & count, & mpitype (T), & dest, & tag, & comm. val, rval, & 0 )
218
- Request (rval[1 ], buf)
218
+ Request (rval[], buf)
219
219
end
220
220
221
221
function Isend {T<:MPIDatatype} (buf:: Array{T} , dest:: Integer , tag:: Integer ,
@@ -249,9 +249,9 @@ function Recv!{T<:MPIDatatype}(buf::Array{T}, src::Integer, tag::Integer,
249
249
end
250
250
251
251
function Recv {T<:MPIDatatype} (:: Type{T} , src:: Integer , tag:: Integer , comm:: Comm )
252
- buf = Array (T, 1 )
252
+ buf = Ref{T}
253
253
stat = Recv! (buf, src, tag, comm)
254
- (buf[1 ], stat)
254
+ (buf[], stat)
255
255
end
256
256
257
257
function recv (src:: Integer , tag:: Integer , comm:: Comm )
@@ -264,12 +264,12 @@ end
264
264
265
265
function Irecv! {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
266
266
src:: Integer , tag:: Integer , comm:: Comm )
267
- rval = Array ( Cint, 1 )
267
+ val = Ref { Cint} ( )
268
268
ccall (MPI_IRECV, Void,
269
269
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
270
270
Ptr{Cint}, Ptr{Cint}),
271
- buf, & count, & mpitype (T), & src, & tag, & comm. val, rval , & 0 )
272
- Request (rval[ 1 ], buf)
271
+ buf, & count, & mpitype (T), & src, & tag, & comm. val, val , & 0 )
272
+ Request (val[ ], buf)
273
273
end
274
274
275
275
function Irecv! {T<:MPIDatatype} (buf:: Array{T} , src:: Integer , tag:: Integer ,
@@ -297,11 +297,11 @@ function Wait!(req::Request)
297
297
end
298
298
299
299
function Test! (req:: Request )
300
- flag = Array ( Cint, 1 )
300
+ flag = Ref { Cint} ( )
301
301
stat = Status ()
302
302
ccall (MPI_TEST, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
303
303
& req. val, flag, stat. val, & 0 )
304
- if flag[1 ] == 0
304
+ if flag[] == 0
305
305
return (false , nothing )
306
306
end
307
307
req. buffer = nothing
@@ -349,12 +349,12 @@ end
349
349
function Waitany! (reqs:: Array{Request,1} )
350
350
count = length (reqs)
351
351
reqvals = [reqs[i]. val for i in 1 : count]
352
- ind = Array ( Cint, 1 )
352
+ ind = Ref { Cint} ( )
353
353
stat = Status ()
354
354
ccall (MPI_WAITANY, Void,
355
355
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
356
356
& count, reqvals, index, statvals, & 0 )
357
- index = ind[1 ]
357
+ index = ind[]
358
358
reqs[index]. val = reqvals[index]
359
359
reqa[index]. buffer = nothing
360
360
(index, stat)
@@ -363,16 +363,16 @@ end
363
363
function Testany! (reqs:: Array{Request,1} )
364
364
count = length (reqs)
365
365
reqvals = [reqs[i]. val for i in 1 : count]
366
- ind = Array ( Cint, 1 )
367
- flag = Array ( Cint, 1 )
366
+ ind = Ref { Cint} ( )
367
+ flag = Ref { Cint} ( )
368
368
stat = Status ()
369
369
ccall (MPI_TESTANY, Void,
370
370
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
371
371
& count, reqvals, ind, flag, stat. val, & 0 )
372
- if flag[1 ] == 0
372
+ if flag[] == 0
373
373
return (false , 0 , nothing )
374
374
end
375
- index = ind[1 ]
375
+ index = ind[]
376
376
reqs[index]. val = reqvals[index]
377
377
reqs[index]. buffer = nothing
378
378
(true , index, stat)
@@ -381,13 +381,13 @@ end
381
381
function Waitsome! (reqs:: Array{Request,1} )
382
382
count = length (reqs)
383
383
reqvals = [reqs[i]. val for i in 1 : count]
384
- outcnt = Array ( Cint, 1 )
384
+ outcnt = Ref { Cint} ( )
385
385
inds = Array (Cint, count)
386
386
statvals = Array (Cint, MPI_STATUS_SIZE, count)
387
387
ccall (MPI_WAITSOME, Void,
388
388
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
389
389
& count, reqvals, outcnt, inds, statvals, & 0 )
390
- outcount = outcnt[1 ]
390
+ outcount = outcnt[]
391
391
# This can happen if there were no valid requests
392
392
if outcount == MPI_UNDEFINED
393
393
outcount = 0
@@ -408,13 +408,13 @@ end
408
408
function Testsome! (reqs:: Array{Request,1} )
409
409
count = length (reqs)
410
410
reqvals = [reqs[i]. val for i in 1 : count]
411
- outcnt = Array ( Cint, 1 )
411
+ outcnt = Ref { Cint} ( )
412
412
inds = Array (Cint, count)
413
413
statvals = Array (Cint, MPI_STATUS_SIZE, count)
414
414
ccall (MPI_TESTSOME, Void,
415
415
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
416
416
& count, reqvals, outcnt, inds, statvals, & 0 )
417
- outcount = outcnt[1 ]
417
+ outcount = outcnt[]
418
418
# This can happen if there were no valid requests
419
419
if outcount == MPI_UNDEFINED
420
420
outcount = 0
0 commit comments