Skip to content

Commit 3d06268

Browse files
author
Damian Rouson
committed
Merge branch 'issue-610-fix-change-team' of
https://github.com/nathanweeks/OpenCoarrays into add-fortran-assertions
2 parents 59c3e7a + 01ed2f0 commit 3d06268

File tree

6 files changed

+59
-23
lines changed

6 files changed

+59
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ if(opencoarrays_aware_compiler)
718718
add_caf_test(alloc_comp_get_convert_nums 2 alloc_comp_get_convert_nums)
719719
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8)
720720
add_caf_test(team_number 2 team_number)
721+
add_caf_test(teams_subset 3 teams_subset)
721722
add_caf_test(get_communicator 3 get_communicator)
722723
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
723724
endif()

prerequisites/install-functions/build_opencoarrays.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build_opencoarrays()
77
find_or_install mpich
88
info "Invoking find_or_install cmake"
99
find_or_install cmake
10-
build_path="${build_path}"/opencoarrays/$("${opencoarrays_src_dir}"/install.sh -V opencoarrays)
10+
build_path="${build_path}"/opencoarrays/$("${OPENCOARRAYS_SRC_DIR}"/install.sh -V opencoarrays)
1111
if [[ -d "${build_path}" ]]; then
1212
rm -rf "${build_path}"
1313
fi
@@ -44,8 +44,8 @@ build_opencoarrays()
4444
set_or_print_installation_path
4545

4646
info "Configuring OpenCoarrays in ${PWD} with the command:"
47-
info "CC=\"${CC}\" FC=\"${FC}\" $CMAKE \"${opencoarrays_src_dir}\" \"${WDEVFLAG}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\" -DMPIEXEC=\"${MPIEXEC}\" -DMPI_C_COMPILER=\"${MPICC}\" -DMPI_Fortran_COMPILER=\"${MPIFC}\""
48-
CC="${CC}" FC="${FC}" $CMAKE "${opencoarrays_src_dir}" "${WDEVFLAG}" -DCMAKE_INSTALL_PREFIX="${install_path}" -DMPIEXEC="${MPIEXEC}" -DMPI_C_COMPILER="${MPICC}" -DMPI_Fortran_COMPILER="${MPIFC}"
47+
info "CC=\"${CC}\" FC=\"${FC}\" $CMAKE \"${OPENCOARRAYS_SRC_DIR}\" \"${WDEVFLAG}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\" -DMPIEXEC=\"${MPIEXEC}\" -DMPI_C_COMPILER=\"${MPICC}\" -DMPI_Fortran_COMPILER=\"${MPIFC}\""
48+
CC="${CC}" FC="${FC}" $CMAKE "${OPENCOARRAYS_SRC_DIR}" "${WDEVFLAG}" -DCMAKE_INSTALL_PREFIX="${install_path}" -DMPIEXEC="${MPIEXEC}" -DMPI_C_COMPILER="${MPICC}" -DMPI_Fortran_COMPILER="${MPIFC}"
4949
info "Building OpenCoarrays in ${PWD} with the command make -j${num_threads}"
5050
make "-j${num_threads}"
5151
if [[ ! -z ${SUDO:-} ]]; then

prerequisites/install-functions/report_results.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ report_results()
3434
# Prepend the OpenCoarrays license to the setup.sh script:
3535
while IFS='' read -r line || [[ -n "${line}" ]]; do
3636
echo "# ${line}" >> setup.sh
37-
done < "${opencoarrays_src_dir}/LICENSE"
37+
done < "${OPENCOARRAYS_SRC_DIR}/LICENSE"
3838
while IFS='' read -r line || [[ -n "${line}" ]]; do
3939
echo "# ${line}" >> setup.csh
40-
done < "${opencoarrays_src_dir}/LICENSE"
40+
done < "${OPENCOARRAYS_SRC_DIR}/LICENSE"
4141
echo "# " | tee -a setup.csh setup.sh
4242
echo "# Execute this script via the following command: " | tee -a setup.csh setup.sh
4343
echo "# source ${install_path%/}/setup.sh " | tee -a setup.csh setup.sh
@@ -49,18 +49,18 @@ report_results()
4949
echo "else " >> setup.sh
5050
echo " if ! [[ \"\${PATH}\" =~ \"${cmake_install_path}\" ]] ; then " >> setup.sh
5151
echo " export PATH=\"${cmake_install_path%/}\":\${PATH} " >> setup.sh
52-
echo " fi " >> setup.sh
52+
echo " fi " >> setup.sh
5353
echo "fi " >> setup.sh
54-
echo "set path = (\"${cmake_install_path%/}\" \"\$path\") " >> setup.csh
54+
echo "set path = (\"${cmake_install_path%/}\" \$path) " >> setup.csh
5555
fi
5656
if [[ -x "${fully_qualified_FC}" ]]; then
5757
echo "# Prepend the compiler path to the PATH environment variable:" | tee -a setup.sh setup.csh
58-
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
58+
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
5959
echo " export PATH=\"${compiler_install_root%/}/bin\" " >> setup.sh
6060
echo "else " >> setup.sh
61-
echo " export PATH=\"${compiler_install_root%/}/bin:\${PATH}\" " >> setup.sh
61+
echo " export PATH=\"${compiler_install_root%/}/bin:\${PATH}\" " >> setup.sh
6262
echo "fi " >> setup.sh
63-
echo "set path = (\"${compiler_install_root%/}\"/bin \"\$path\") " >> setup.csh
63+
echo "set path (\"${compiler_install_root%/}\"/bin \$path) " >> setup.csh
6464
fi
6565
LD_LIB_P_VAR=LD_LIBRARY_PATH
6666
if [[ "${OSTYPE:-}" =~ [Dd]arwin ]]; then
@@ -74,23 +74,23 @@ report_results()
7474
echo "else " >> setup.sh
7575
echo " export ${LD_LIB_P_VAR}=\"${compiler_lib_paths%/}:\${!LD_LIB_P_VAR}\" " >> setup.sh
7676
echo "fi " >> setup.sh
77-
echo "set LD_LIBRARY_PATH = (\"${compiler_lib_paths%/}\" \"\${LD_LIBRARY_PATH}\") " >> setup.csh
77+
echo "setenv LD_LIBRARY_PATH \"${compiler_lib_paths%/}:\${LD_LIBRARY_PATH}\" " >> setup.csh
7878
fi
79-
echo " " >> setup.sh
79+
echo " " >> setup.sh
8080
if [[ -x "${mpi_install_root}/bin/mpifort" ]]; then
8181
echo "# Prepend the MPI path to the PATH environment variable:" | tee -a setup.sh setup.csh
82-
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
83-
echo " export PATH=\"${mpi_install_root%/}/bin\" " >> setup.sh
82+
echo "if [[ -z \"\${PATH}\" ]]; then " >> setup.sh
83+
echo " export PATH=\"${mpi_install_root%/}/bin\" " >> setup.sh
8484
echo "else " >> setup.sh
8585
echo " export PATH=\"${mpi_install_root%/}/bin\":\${PATH} " >> setup.sh
8686
echo "fi " >> setup.sh
87-
echo "set path = (\"${mpi_install_root%/}\"/bin \"\$path\") " >> setup.csh
87+
echo "set path = (\"${mpi_install_root%/}/bin\" \$path) " >> setup.csh
8888
fi
8989
# In all likelihood, the following paths are only needed if OpenCoarrays built them,
9090
# In by far the most common such use case, they would have been built in a recursive
9191
# build of all the OpenCoarrays dependency tree (rather than built indvidually via
9292
# ./install --package) so we only need check the default location in which OpenCoarrays
93-
# would install them. If they are not there, then it is very likely the case that the
93+
# would install them. If they are not there, then it is very likely the case that the
9494
# the system versions of these packages are present and in the user's path or that the
9595
# user doesn't need them at all (e.g. there was no need to build gfortran from source).
9696
flex_install_path=$("${build_script}" -P flex)
@@ -100,7 +100,7 @@ report_results()
100100
echo " export PATH=\"${flex_install_path}/bin\" " >> setup.sh
101101
echo "else " >> setup.sh
102102
echo " export PATH=\"${flex_install_path}/bin\":\${PATH} " >> setup.sh
103-
echo "set path = (\"$flex_install_path\"/bin \"\$path\") " >> setup.csh
103+
echo "set path = (\"$flex_install_path\"/bin \$path) " >> setup.csh
104104
echo "fi " >> setup.sh
105105
fi
106106
bison_install_path=$("${build_script}" -P bison)
@@ -111,7 +111,7 @@ report_results()
111111
echo "else " >> setup.sh
112112
echo " export PATH=\"${bison_install_path}/bin\":\${PATH} " >> setup.sh
113113
echo "fi " >> setup.sh
114-
echo "set path = (\"$bison_install_path\"/bin \"\$path\") " >> setup.csh
114+
echo "set path = (\"$bison_install_path\"/bin \$path) " >> setup.csh
115115
fi
116116
m4_install_path=$("${build_script}" -P m4)
117117
if [[ -x "${m4_install_path}/bin/m4" ]]; then
@@ -121,7 +121,7 @@ report_results()
121121
echo "else " >> setup.sh
122122
echo " export PATH=\"${m4_install_path}/bin\":\${PATH} " >> setup.sh
123123
echo "fi " >> setup.sh
124-
echo "set path = (\"$m4_install_path\"/bin \"\$path\") " >> setup.csh
124+
echo "set path = (\"$m4_install_path\"/bin \$path) " >> setup.csh
125125
fi
126126
opencoarrays_install_path="${install_path}"
127127
if [[ -x "${opencoarrays_install_path}/bin/caf" ]]; then
@@ -131,7 +131,7 @@ report_results()
131131
echo "else " >> setup.sh
132132
echo " export PATH=\"${opencoarrays_install_path%/}/bin\":\${PATH} " >> setup.sh
133133
echo "fi " >> setup.sh
134-
echo "set path = (\"${opencoarrays_install_path%/}\"/bin \"\$path\") " >> setup.csh
134+
echo "set path = (\"${opencoarrays_install_path%/}\"/bin \$path) " >> setup.csh
135135
fi
136136
if ${SUDO:-} mv setup.sh "${opencoarrays_install_path}"; then
137137
setup_sh_location=${opencoarrays_install_path}

src/mpi/mpi_caf.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8098,7 +8098,6 @@ void PREFIX(change_team) (caf_team_t *team,
80988098
caf_teams_list * tmp_list = NULL;
80998099
void *tmp_team;
81008100
MPI_Comm *tmp_comm;
8101-
int ierr = MPI_Barrier(CAF_COMM_WORLD); chk_err(ierr);
81028101

81038102
tmp_list = (struct caf_teams_list *)*team;
81048103
tmp_team = (void *)tmp_list->team;
@@ -8131,9 +8130,10 @@ void PREFIX(change_team) (caf_team_t *team,
81318130
tmp_team = tmp_used->team_list_elem->team;
81328131
tmp_comm = (MPI_Comm *)tmp_team;
81338132
CAF_COMM_WORLD = *tmp_comm;
8134-
ierr = MPI_Comm_rank(*tmp_comm,&caf_this_image); chk_err(ierr);
8133+
int ierr = MPI_Comm_rank(*tmp_comm,&caf_this_image); chk_err(ierr);
81358134
caf_this_image++;
81368135
ierr = MPI_Comm_size(*tmp_comm,&caf_num_images); chk_err(ierr);
8136+
ierr = MPI_Barrier(*tmp_comm); chk_err(ierr);
81378137
}
81388138

81398139
MPI_Fint
@@ -8178,7 +8178,6 @@ void PREFIX(end_team) (caf_team_t *team __attribute__((unused)))
81788178
tmp_team = tmp_used->team_list_elem->team;
81798179
tmp_comm = (MPI_Comm *)tmp_team;
81808180
CAF_COMM_WORLD = *tmp_comm;
8181-
ierr = MPI_Barrier(CAF_COMM_WORLD); chk_err(ierr);
81828181
/* CAF_COMM_WORLD = (MPI_Comm)*tmp_used->team_list_elem->team; */
81838182
ierr = MPI_Comm_rank(CAF_COMM_WORLD,&caf_this_image); chk_err(ierr);
81848183
caf_this_image++;

src/tests/unit/teams/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
caf_compile_executable(team_number team-number.f90)
2+
caf_compile_executable(teams_subset teams_subset.f90)
23
caf_compile_executable(get_communicator get-communicator.f90)

src/tests/unit/teams/teams_subset.f90

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
program teams_subset
2+
use iso_fortran_env, only : team_type
3+
implicit none
4+
5+
type(team_type) :: team
6+
integer :: initial_team_image, max_image(2), min_image(2), myteam
7+
8+
initial_team_image = this_image()
9+
10+
if (initial_team_image == 1 .or. initial_team_image == num_images()) then
11+
myteam = 1
12+
else
13+
myteam = 2
14+
end if
15+
16+
form team (myteam, team)
17+
18+
if (myteam == 1) then
19+
change team(team)
20+
max_image = [initial_team_image, this_image()]
21+
call co_max(max_image)
22+
min_image = [initial_team_image, this_image()]
23+
call co_min(min_image)
24+
end team
25+
if (any(min_image /= [1, 1]) .or. any(max_image /= [num_images(), 2])) then
26+
write(*,*) "Test failed."
27+
error stop
28+
end if
29+
end if
30+
31+
sync all
32+
33+
if (initial_team_image == 1) write(*,*) "Test passed."
34+
35+
end program

0 commit comments

Comments
 (0)