forked from jeffhammond/foMPI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule_fompi.f90
634 lines (458 loc) · 21.5 KB
/
module_fompi.f90
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
! Copyright (c) 2012 The Tru stees of University of Illinois. All rights reserved.
! Use of this source code is governed by a BSD-style license that can be
! found in the LICENSE file.
module fompi
use mpi
implicit none
! constants for win_create_flavor
integer, parameter :: fompi_win_flavor_create = 0
integer, parameter :: fompi_win_flavor_allocate = 1
integer, parameter :: fompi_win_flavor_dynamic = 2
! constants for win_model
integer, parameter :: fompi_win_separate = 0
integer, parameter :: fompi_win_unified = 1
! asserts for one-sided communication
integer, parameter :: fompi_mode_nocheck = 1024
integer, parameter :: fompi_mode_nostore = 2048
integer, parameter :: fompi_mode_noput = 4096
integer, parameter :: fompi_mode_noprecede = 8192
integer, parameter :: fompi_mode_nosucceed = 16384
! error codes
integer, parameter :: fompi_error_rma_no_sync = 1
integer, parameter :: fompi_error_rma_datatype_mismatch = 2
integer, parameter :: fompi_error_rma_no_lock_holding = 3
integer, parameter :: fompi_error_rma_sync_conflict = 4
integer, parameter :: fompi_error_rma_write_shared_conflict = 5
integer, parameter :: fompi_error_rma_win_mem_not_found = 6
integer, parameter :: fompi_op_not_supported = 7
integer, parameter :: fompi_mpi_datatype_not_supported = 8
integer, parameter :: fompi_mpi_name_abreviated = 9
! constants for foMPI_OP
! TODO: not real MPI_Op objects
! the numbers should be contiguous, since some sanity tests rely on that fact
integer, parameter :: fompi_sum = 0
integer, parameter :: fompi_prod = 1
integer, parameter :: fompi_max = 2
integer, parameter :: fompi_min = 3
integer, parameter :: fompi_land = 4
integer, parameter :: fompi_lor = 5
integer, parameter :: fompi_lxor = 6
integer, parameter :: fompi_band = 7
integer, parameter :: fompi_bor = 8
integer, parameter :: fompi_bxor = 9
integer, parameter :: fompi_maxloc = 10
integer, parameter :: fompi_minloc = 11
integer, parameter :: fompi_replace = 12
integer, parameter :: fompi_no_op = 13
! constants for lock type
integer, parameter :: fompi_lock_shared = 1
integer, parameter :: fompi_lock_exclusive = 2
! constants for attributes
integer, parameter :: fompi_win_base = 0
integer, parameter :: fompi_win_size = 1
integer, parameter :: fompi_win_disp_unit = 2
integer, parameter :: fompi_win_create_flavor = 3
integer, parameter :: fompi_win_model = 4
integer, parameter :: fompi_request_null = -1
integer, parameter :: fompi_undefined = 17383
integer, parameter :: fompi_win_null = -1
interface
! window creation
! subroutine foMPI_Win_create( base, size, disp_unit, info, comm, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: base ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: size
! integer, intent(in) :: disp_unit
! integer, intent(in) :: info
! integer, intent(in) :: comm
! integer, intent(out) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Win_create
subroutine foMPI_Win_create_dynamic( info, comm, win, ierror )
integer, intent(in) :: info
integer, intent(in) :: comm
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_create_dynamic
subroutine foMPI_Win_free( win, ierror )
integer, intent(inout) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_free
! subroutine foMPI_Win_attach( win, base, size, ierror )
!
! use mpi
!
! integer, intent(in) :: win
! integer, dimension(:), intent(inout) :: base ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: size
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Win_attach
! subroutine foMPI_Win_detach( win, base, ierror )
!
! integer, intent(in) :: win
! integer, dimension(:), intent(inout) :: base ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Win_detach
! synchronization
subroutine foMPI_Win_fence( assert, win, ierror )
integer, intent(in) :: assert
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_fence
subroutine foMPI_Win_start( group, assert, win, ierror )
integer, intent(in) :: group
integer, intent(in) :: assert
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_start
subroutine foMPI_Win_complete( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_complete
subroutine foMPI_Win_post( group, assert, win, ierror )
integer, intent(in) :: group
integer, intent(in) :: assert
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_post
subroutine foMPI_Win_wait( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_wait
subroutine foMPI_Win_test( win, flag, ierror )
integer, intent(in) :: win
logical, intent(out) :: flag
integer, intent(out) :: ierror
end subroutine foMPI_Win_test
subroutine foMPI_Win_lock( lock_type, rank, assert, win, &
ierror )
integer, intent(in) :: lock_type
integer, intent(in) :: rank
integer, intent(in) :: assert
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_lock
subroutine foMPI_Win_unlock( rank, win, ierror )
integer, intent(in) :: rank
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_unlock
subroutine foMPI_Win_lock_all( assert, win, ierror )
integer, intent(in) :: assert
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_lock_all
subroutine foMPI_Win_unlock_all( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_unlock_all
subroutine foMPI_Win_flush( rank, win, ierror )
integer, intent(in) :: rank
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_flush
subroutine foMPI_Win_flush_all( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_flush_all
subroutine foMPI_Win_flush_local( rank, win, ierror )
integer, intent(in) :: rank
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_flush_local
subroutine foMPI_Win_flush_local_all( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_flush_local_all
subroutine foMPI_Win_sync( win, ierror )
integer, intent(in) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_sync
! communication
! subroutine foMPI_Put( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Put
! subroutine foMPI_Get( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(out) :: origin_addr ! intent correct? ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Get
! subroutine foMPI_Accumulate( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, op, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: op
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Accumulate
! subroutine foMPI_Get_accumulate( origin_addr, origin_count, &
! origin_datatype, result_addr, result_count, result_datatype, &
! target_rank, target_disp, target_count, target_datatype, op, &
! win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, dimension(:), intent(out) :: result_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: result_count
! integer, intent(in) :: result_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: op
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Get_accumulate
! subroutine foMPI_Fetch_and_op( origin_addr, result_addr, &
! datatype, target_rank, target_disp, op, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, dimension(:), intent(out) :: result_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: op
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Fetch_and_op
! subroutine foMPI_Compare_and_swap( origin_addr, compare_addr, &
! result_addr, datatype, target_rank, target_disp, win, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, dimension(:), intent(in) :: compare_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, dimension(:), intent(out) :: result_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: win
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Compare_and_swap
! request based communication
! subroutine foMPI_Rput( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, win, request, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: win
! integer, intent(out) :: request
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Rput
! subroutine foMPI_Rget( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, win, request, ierror )
!
! use mpi
!
! integer, dimension(:), intent(out) :: origin_addr ! intent correct? ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: win
! integer, intent(out) :: request
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Rget
! subroutine foMPI_Raccumulate( origin_addr, origin_count, &
! origin_datatype, target_rank, target_disp, target_count, &
! target_datatype, op, win, request, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: op
! integer, intent(in) :: win
! integer, intent(out) :: request
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Raccumulate
! subroutine foMPI_Rget_accumulate( origin_addr, origin_count, &
! origin_datatype, result_addr, result_count, result_datatype, &
! target_rank, target_disp, target_count, target_datatype, op, &
! win, request, ierror )
!
! use mpi
!
! integer, dimension(:), intent(in) :: origin_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: origin_count
! integer, intent(in) :: origin_datatype
! integer, dimension(:), intent(out) :: result_addr ! doesn't work since array is assume-shaped, and also would only be working with integer
! integer, intent(in) :: result_count
! integer, intent(in) :: result_datatype
! integer, intent(in) :: target_rank
! integer(kind=MPI_ADDRESS_KIND), intent(in) :: target_disp
! integer, intent(in) :: target_count
! integer, intent(in) :: target_datatype
! integer, intent(in) :: op
! integer, intent(in) :: win
! integer, intent(out) :: request
! integer, intent(out) :: ierror
!
! end subroutine foMPI_Rget_accumulate
! window attributes
subroutine foMPI_Win_get_group( win, group, ierror )
integer, intent(in) :: win
integer, intent(out) :: group
integer, intent(out) :: ierror
end subroutine foMPI_Win_get_group
subroutine foMPI_Win_set_name( win, win_name, ierror )
integer, intent(in) :: win
character*(*), intent(in) :: win_name
integer, intent(out) :: ierror
end subroutine foMPI_Win_set_name
subroutine foMPI_Win_get_name( win, win_name, result_len, ierror )
integer, intent(in) :: win
character*(*), intent(out) :: win_name
integer, intent(out) :: result_len
integer, intent(out) :: ierror
end subroutine foMPI_Win_get_name
subroutine foMPI_Win_create_keyval( win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state, ierror )
use mpi
external :: win_copy_attr_fn
external :: win_delete_attr_fn
integer, intent(inout) :: win_keyval
integer(kind=MPI_ADDRESS_KIND) :: extra_state
integer, intent(out) :: ierror
end subroutine foMPI_Win_create_keyval
subroutine foMPI_Win_free_keyval( win_keyval, ierror )
integer, intent(inout) :: win_keyval
integer, intent(out) :: ierror
end subroutine foMPI_Win_free_keyval
subroutine foMPI_Win_set_attr( win, win_keyval, attribute_val, ierror )
use mpi
integer, intent(in) :: win
integer, intent(in) :: win_keyval
integer(kind=MPI_ADDRESS_KIND), intent(in) :: attribute_val
integer, intent(out) :: ierror
end subroutine foMPI_Win_set_attr
subroutine foMPI_Win_get_attr( win, win_keyval, attribute_val, flag, ierror )
use mpi
integer, intent(in) :: win
integer, intent(in) :: win_keyval
integer(kind=MPI_ADDRESS_KIND), intent(out) :: attribute_val
logical, intent(out) :: flag
integer, intent(out) :: ierror
end subroutine foMPI_Win_get_attr
subroutine foMPI_Win_delete_attr( win, win_keyval, ierror )
integer, intent(in) :: win
integer, intent(in) :: win_keyval
integer, intent(out) :: ierror
end subroutine foMPI_Win_delete_attr
! overloaded functions
subroutine foMPI_Init( ierror )
integer, intent(out) :: ierror
end subroutine foMPI_Init
subroutine foMPI_Finalize( ierror )
integer, intent(out) :: ierror
end subroutine foMPI_Finalize
subroutine foMPI_Wait( request, fstatus, ierror )
use mpi
integer, intent(inout) :: request
integer, dimension(MPI_STATUS_SIZE), intent(out) :: fstatus
integer, intent(out) :: ierror
end subroutine foMPI_Wait
subroutine foMPI_Test( request, flag, fstatus, ierror )
use mpi
integer, intent(inout) :: request
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(out) :: fstatus
integer, intent(out) :: ierror
end subroutine foMPI_Test
subroutine foMPI_Type_free( datatype, ierror )
integer, intent(inout) :: datatype
integer, intent(out) :: ierror
end subroutine foMPI_Type_free
end interface
interface foMPI_Win_allocate
!procedure foMPI_Win_allocate, foMPI_Win_allocate_cptr
subroutine foMPI_Win_allocate( size, disp_unit, info, comm, baseptr, win, ierror )
use mpi
integer(kind=MPI_ADDRESS_KIND), intent(in) :: size
integer, intent(in) :: disp_unit
integer, intent(in) :: info
integer, intent(in) :: comm
integer(kind=MPI_ADDRESS_KIND) :: baseptr ! removed intent, so Fortran accepts null()
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine foMPI_Win_allocate
subroutine foMPI_Win_allocate_cptr( size, disp_unit, info, comm, baseptr, win, ierror )
use, intrinsic :: iso_c_binding, only: c_ptr
use mpi
integer(kind=MPI_ADDRESS_KIND), intent(in) :: size
integer, intent(in) :: disp_unit
integer, intent(in) :: info
integer, intent(in) :: comm
type(c_ptr) :: baseptr ! removed intent, so Fortran accepts null()
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine
end interface foMPI_Win_allocate
end module fompi