Skip to content

Commit 2a97b6c

Browse files
committed
fortran: add a bunch of collective tests
thanks to claude-sonnet-4-5-20250929-v1:0 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 1c45ea3 commit 2a97b6c

104 files changed

Lines changed: 10393 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ collective-big-count/test_scatter
3333
collective-big-count/test_scatterv
3434
collective-big-count/*_uniform_count
3535

36+
fortran/collectives/*.o
37+
fortran/collectives/*_f08
38+
fortran/collectives/*_f90
39+
3640
comm_split_type/cmsplit_type
3741

3842
singleton/hello_c

fortran/Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- makefile -*-
2+
#
3+
# Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# $HEADER$
6+
#
7+
8+
ACLOCAL_AMFLAGS = -I config
9+
10+
# The reporting subdir must be built before all others
11+
12+
SUBDIRS = collectives

fortran/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Fortran tests
2+
3+
A bunch of fortran tests (use mpi and use mpi_f08 as mpif.h is dead and deprecated and should not be used).
4+
This testsuite will only work with an MPI implementation that supports MPI 4.1 or higher
5+
6+
Dirt simple configury for now.
7+
8+
# Compile
9+
```
10+
$ ./autogen.sh && ./configure FC=mpifort && make
11+
12+
# Run
13+
Only support run by hand or via a script or something for now

fortran/autogen.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
autoreconf -ivf

fortran/collectives/Makefile.am

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# -*- makefile -*-
2+
#
3+
4+
bin_PROGRAMS = allgather_f90 \
5+
allgatherv_f90 \
6+
allreduce_f90 \
7+
alltoall_f90 \
8+
alltoallv_f90 \
9+
alltoallw_f90 \
10+
exscan_f90 \
11+
gather_f90 \
12+
gatherv_f90 \
13+
reduce_f90 \
14+
reduce_loc_f90 \
15+
reduce_scatter_f90 \
16+
reduce_scatter_block_f90 \
17+
scan_f90 \
18+
scatter_f90 \
19+
scatterv_f90 \
20+
allgather_f08 \
21+
allgatherv_f08 \
22+
allreduce_f08 \
23+
alltoall_f08 \
24+
alltoallv_f08 \
25+
alltoallw_f08 \
26+
bcast_f08 \
27+
exscan_f08 \
28+
gather_f08 \
29+
gatherv_f08 \
30+
reduce_f08 \
31+
reduce_loc_f08 \
32+
reduce_scatter_f08 \
33+
reduce_scatter_block_f08 \
34+
scan_f08 \
35+
scatter_f08 \
36+
scatter_init_f08 \
37+
scatterv_f08 \
38+
ineighbor_alltoallv_f90 \
39+
ineighbor_alltoallw_f90 \
40+
neighbor_alltoallv_f90 \
41+
neighbor_alltoallv_init_f90 \
42+
neighbor_alltoallw_f90 \
43+
neighbor_alltoallw_init_f90 \
44+
ineighbor_alltoallv_f08 \
45+
ineighbor_alltoallw_f08 \
46+
neighbor_alltoallv_f08 \
47+
neighbor_alltoallv_init_f08 \
48+
neighbor_alltoallw_f08 \
49+
neighbor_alltoallw_init_f08 \
50+
ibarrier_f90 \
51+
iallgather_f90 \
52+
ireduce_scatter_f90 \
53+
ireduce_scatter_block_f90 \
54+
iallgatherv_f90 \
55+
iallreduce_f90 \
56+
iscan_f90 \
57+
iscatter_f90 \
58+
iscatterv_f90 \
59+
ibarrier_f08 \
60+
iallgather_f08 \
61+
ireduce_scatter_f08 \
62+
ireduce_scatter_block_f08 \
63+
iallgatherv_f08 \
64+
iallreduce_f08 \
65+
iscan_f08 \
66+
iscatter_f08 \
67+
iscatterv_f08 \
68+
allgather_init_f90 \
69+
allgatherv_init_f90 \
70+
allreduce_init_f90 \
71+
alltoall_init_f90 \
72+
alltoallv_init_f90 \
73+
alltoallw_init_f90 \
74+
barrier_init_f90 \
75+
bcast_init_f90 \
76+
gather_init_f90 \
77+
gatherv_init_f90 \
78+
reduce_init_f90 \
79+
reduce_scatter_block_init_f90 \
80+
reduce_scatter_init_f90 \
81+
scan_init_f90 \
82+
scatter_init_f90 \
83+
scatterv_init_f90 \
84+
allgather_init_f08 \
85+
allgatherv_init_f08 \
86+
allreduce_init_f08 \
87+
alltoall_init_f08 \
88+
alltoallv_init_f08 \
89+
alltoallw_init_f08 \
90+
barrier_init_f08 \
91+
bcast_init_f08 \
92+
gather_init_f08 \
93+
gatherv_init_f08 \
94+
reduce_init_f08 \
95+
reduce_scatter_block_init_f08 \
96+
reduce_scatter_init_f08 \
97+
scan_init_f08 \
98+
scatter_init_f08 \
99+
scatterv_init_f08
100+
101+
bcast_f08_SOURCES = bcast_f08.f90
102+
ibarrier_f90_SOURCES = ibarrier_f90.f90
103+
ibarrier_f08_SOURCES = ibarrier_f08.f90
104+
barrier_init_f90_SOURCES = barrier_init_f90.f90
105+
barrier_init_f08_SOURCES = barrier_init_f08.f90
106+
bcast_init_f90_SOURCES = bcast_init_f90.f90
107+
bcast_init_f08_SOURCES = bcast_init_f08.f90
108+
ineighbor_alltoallv_f90_SOURCES = ineighbor_alltoallv_f90.f90
109+
ineighbor_alltoallw_f90_SOURCES = ineighbor_alltoallw_f90.f90
110+
neighbor_alltoallv_f90_SOURCES = neighbor_alltoallv_f90.f90
111+
neighbor_alltoallv_init_f90_SOURCES = neighbor_alltoallv_init_f90.f90
112+
neighbor_alltoallw_f90_SOURCES = neighbor_alltoallw_f90.f90
113+
neighbor_alltoallw_init_f90_SOURCES = neighbor_alltoallw_init_f90.f90
114+
ineighbor_alltoallv_f08_SOURCES = ineighbor_alltoallv_f08.f90
115+
ineighbor_alltoallw_f08_SOURCES = ineighbor_alltoallw_f08.f90
116+
neighbor_alltoallv_f08_SOURCES = neighbor_alltoallv_f08.f90
117+
neighbor_alltoallv_init_f08_SOURCES = neighbor_alltoallv_init_f08.f90
118+
neighbor_alltoallw_f08_SOURCES = neighbor_alltoallw_f08.f90
119+
neighbor_alltoallw_init_f08_SOURCES = neighbor_alltoallw_init_f08.f90
120+
allgather_f90_SOURCES = allgather_f90.f90
121+
allgather_init_f90_SOURCES = allgather_init_f90.f90
122+
allgatherv_f90_SOURCES = allgatherv_f90.f90
123+
allgatherv_init_f90_SOURCES = allgatherv_init_f90.f90
124+
allreduce_f90_SOURCES = allreduce_f90.f90
125+
allreduce_init_f90_SOURCES = allreduce_init_f90.f90
126+
alltoall_f90_SOURCES = alltoall_f90.f90
127+
alltoall_init_f90_SOURCES = alltoall_init_f90.f90
128+
alltoallv_f90_SOURCES = alltoallv_f90.f90
129+
alltoallv_init_f90_SOURCES = alltoallv_init_f90.f90
130+
alltoallw_f90_SOURCES = alltoallw_f90.f90
131+
alltoallw_init_f90_SOURCES = alltoallw_init_f90.f90
132+
exscan_f90_SOURCES = exscan_f90.f90
133+
gather_f90_SOURCES = gather_f90.f90
134+
gather_init_f90_SOURCES = gather_init_f90.f90
135+
gatherv_f90_SOURCES = gatherv_f90.f90
136+
gatherv_init_f90_SOURCES = gatherv_init_f90.f90
137+
iallgather_f90_SOURCES = iallgather_f90.f90
138+
iallgatherv_f90_SOURCES = iallgatherv_f90.f90
139+
iallreduce_f90_SOURCES = iallreduce_f90.f90
140+
ireduce_scatter_f90_SOURCES = ireduce_scatter_f90.f90
141+
ireduce_scatter_block_f90_SOURCES = ireduce_scatter_block_f90.f90
142+
iscan_f90_SOURCES = iscan_f90.f90
143+
iscatter_f90_SOURCES = iscatter_f90.f90
144+
iscatterv_f90_SOURCES = iscatterv_f90.f90
145+
reduce_f90_SOURCES = reduce_f90.f90
146+
reduce_init_f90_SOURCES = reduce_init_f90.f90
147+
reduce_loc_f90_SOURCES = reduce_loc_f90.f90
148+
reduce_scatter_f90_SOURCES = reduce_scatter_f90.f90
149+
reduce_scatter_block_f90_SOURCES = reduce_scatter_block_f90.f90
150+
reduce_scatter_block_init_f90_SOURCES = reduce_scatter_block_init_f90.f90
151+
reduce_scatter_init_f90_SOURCES = reduce_scatter_init_f90.f90
152+
scan_f90_SOURCES = scan_f90.f90
153+
scan_init_f90_SOURCES = scan_init_f90.f90
154+
scatter_f90_SOURCES = scatter_f90.f90
155+
scatter_init_f90_SOURCES = scatter_init_f90.f90
156+
scatterv_f90_SOURCES = scatterv_f90.f90
157+
scatterv_init_f90_SOURCES = scatterv_init_f90.f90
158+
allgather_f08_SOURCES = allgather_f08.f90
159+
allgather_init_f08_SOURCES = allgather_init_f08.f90
160+
allgatherv_f08_SOURCES = allgatherv_f08.f90
161+
allgatherv_init_f08_SOURCES = allgatherv_init_f08.f90
162+
allreduce_f08_SOURCES = allreduce_f08.f90
163+
allreduce_init_f08_SOURCES = allreduce_init_f08.f90
164+
alltoall_f08_SOURCES = alltoall_f08.f90
165+
alltoall_init_f08_SOURCES = alltoall_init_f08.f90
166+
alltoallv_f08_SOURCES = alltoallv_f08.f90
167+
alltoallv_init_f08_SOURCES = alltoallv_init_f08.f90
168+
alltoallw_f08_SOURCES = alltoallw_f08.f90
169+
alltoallw_init_f08_SOURCES = alltoallw_init_f08.f90
170+
exscan_f08_SOURCES = exscan_f08.f90
171+
gather_f08_SOURCES = gather_f08.f90
172+
gather_init_f08_SOURCES = gather_init_f08.f90
173+
gatherv_f08_SOURCES = gatherv_f08.f90
174+
gatherv_init_f08_SOURCES = gatherv_init_f08.f90
175+
iallgather_f08_SOURCES = iallgather_f08.f90
176+
iallgatherv_f08_SOURCES = iallgatherv_f08.f90
177+
iallreduce_f08_SOURCES = iallreduce_f08.f90
178+
ireduce_scatter_f08_SOURCES = ireduce_scatter_f08.f90
179+
ireduce_scatter_block_f08_SOURCES = ireduce_scatter_block_f08.f90
180+
iscan_f08_SOURCES = iscan_f08.f90
181+
iscatter_f08_SOURCES = iscatter_f08.f90
182+
iscatterv_f08_SOURCES = iscatterv_f08.f90
183+
reduce_f08_SOURCES = reduce_f08.f90
184+
reduce_init_f08_SOURCES = reduce_init_f08.f90
185+
reduce_loc_f08_SOURCES = reduce_loc_f08.f90
186+
reduce_scatter_f08_SOURCES = reduce_scatter_f08.f90
187+
reduce_scatter_block_f08_SOURCES = reduce_scatter_block_f08.f90
188+
reduce_scatter_block_init_f08_SOURCES = reduce_scatter_block_init_f08.f90
189+
reduce_scatter_init_f08_SOURCES = reduce_scatter_init_f08.f90
190+
scan_f08_SOURCES = scan_f08.f90
191+
scan_init_f08_SOURCES = scan_init_f08.f90
192+
scatter_f08_SOURCES = scatter_f08.f90
193+
scatter_init_f08_SOURCES = scatter_init_f08.f90
194+
scatterv_f08_SOURCES = scatterv_f08.f90
195+
scatterv_init_f08_SOURCES = scatterv_init_f08.f90
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
!
2+
! $HEADER$
3+
!
4+
!****************************************************************************
5+
!
6+
! MESSAGE PASSING INTERFACE TEST CASE SUITE
7+
!
8+
! Copyright IBM Corp. 1995
9+
!
10+
! IBM Corp. hereby grants a non-exclusive license to use, copy, modify, and
11+
! distribute this software for any purpose and without fee provided that the
12+
! above copyright notice and the following paragraphs appear in all copies.
13+
!
14+
! IBM Corp. makes no representation that the test cases comprising this
15+
! suite are correct or are an accurate representation of any standard.
16+
!
17+
! In no event shall IBM be liable to any party for direct, indirect, special
18+
! incidental, or consequential damage arising out of the use of this software
19+
! even if IBM Corp. has been advised of the possibility of such damage.
20+
!
21+
! IBM CORP. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED
22+
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
! PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS AND IBM
24+
! CORP. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
25+
! ENHANCEMENTS, OR MODIFICATIONS.
26+
!
27+
!****************************************************************************
28+
!
29+
! These test cases reflect an interpretation of the MPI Standard. They are
30+
! are, in most cases, unit tests of specific MPI behaviors. If a user of any
31+
! test case from this set believes that the MPI Standard requires behavior
32+
! different than that implied by the test case we would appreciate feedback.
33+
!
34+
! Comments may be sent to:
35+
! Richard Treumann
36+
! treumann@kgn.ibm.com
37+
!
38+
!****************************************************************************
39+
40+
program allgather_test
41+
use mpi_f08
42+
implicit none
43+
44+
integer, parameter :: MAXLEN = 1000
45+
integer, allocatable :: out(:), in(:)
46+
integer :: i, j, k
47+
integer :: myself, tasks
48+
integer :: ierr
49+
50+
call MPI_Init(ierr)
51+
call MPI_Comm_rank(MPI_COMM_WORLD, myself, ierr)
52+
call MPI_Comm_size(MPI_COMM_WORLD, tasks, ierr)
53+
54+
! Add this section because some os/architectures can't allocate
55+
! this much memory on the stack
56+
57+
allocate(in(MAXLEN * tasks), out(MAXLEN), stat=ierr)
58+
if (ierr /= 0) then
59+
write(*,*) "Doh! Rank ", myself, " was not able to allocate enough memory. MPI test aborted!"
60+
call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
61+
end if
62+
63+
j = 1
64+
do while (j <= MAXLEN)
65+
do i = 1, j
66+
out(i) = myself
67+
end do
68+
69+
call MPI_Allgather(out, j, MPI_INTEGER, in, j, MPI_INTEGER, MPI_COMM_WORLD, ierr)
70+
71+
do i = 0, tasks - 1
72+
do k = 1, j
73+
if (in(k + i * j) /= i) then
74+
write(*,*) "bad answer (", in(k), ") at index ", k + i * j - 1, &
75+
" of ", j * tasks, " (should be ", i, ")"
76+
call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
77+
end if
78+
end do
79+
end do
80+
81+
j = j * 10
82+
end do
83+
84+
call MPI_Barrier(MPI_COMM_WORLD, ierr)
85+
call MPI_Finalize(ierr)
86+
87+
! Clean up, 'cause it's the Right Thing to do
88+
deallocate(in, out)
89+
90+
end program allgather_test

0 commit comments

Comments
 (0)