Skip to content

Commit 1da451b

Browse files
committed
Really fix #411 on all mpi-installations reliably.
Fix #411. Fix #412.
1 parent e3b827f commit 1da451b

File tree

7 files changed

+45
-21
lines changed

7 files changed

+45
-21
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,9 @@ if(opencoarrays_aware_compiler)
595595
add_mpi_test(get-put-alloc-comp 3 ${tests_root}/regression/reported/issue-422-send-get)
596596
endif()
597597

598+
add_mpi_test(event_post_1 4 ${tests_root}/unit/events/event_post_1)
598599
# Fixed GCC 7 regressions, should run on GCC 6 and 7
599-
add_mpi_test(event-post 3 ${tests_root}/regression/reported/event-post)
600+
add_mpi_test(event_post_2 3 ${tests_root}/unit/events/event_post_2)
600601

601602
# These co_reduce (#172, fixed by PR #332, addl discussion in PR
602603
# #331) tests are for bugs not regressions. Should be fixed in all

src/mpi/mpi_caf.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4454,39 +4454,36 @@ PREFIX (event_wait) (caf_token_t token, size_t index,
44544454
int until_count, int *stat,
44554455
char *errmsg, int errmsg_len)
44564456
{
4457-
int ierr=0,count=0,i,image=caf_this_image-1;
4458-
int *var=NULL,flag,old=0;
4459-
int newval=0;
4457+
int ierr = 0, count = 0, i, image = caf_this_image - 1;
4458+
int *var = NULL, flag, old = 0;
4459+
int newval = 0;
44604460
const int spin_loop_max = 20000;
44614461
MPI_Win *p = TOKEN(token);
44624462
const char msg[] = "Error on event wait";
44634463

44644464
if(stat != NULL)
44654465
*stat = 0;
44664466

4467-
MPI_Win_get_attr(*p,MPI_WIN_BASE,&var,&flag);
4467+
MPI_Win_get_attr (*p, MPI_WIN_BASE, &var, &flag);
44684468

44694469
for(i = 0; i < spin_loop_max; ++i)
44704470
{
4471-
MPI_Win_sync(*p);
4471+
MPI_Win_sync (*p);
44724472
count = var[index];
44734473
if(count >= until_count)
44744474
break;
44754475
}
44764476

4477-
i=1;
4477+
i = 1;
44784478
while(count < until_count)
4479-
/* for(i = 0; i < spin_loop_max; ++i) */
4480-
{
4481-
MPI_Win_sync(*p);
4482-
count = var[index];
4483-
/* if(count >= until_count) */
4484-
/* break; */
4485-
usleep(10*i);
4486-
i++;
4487-
/* Needed to enforce MPI progress */
4488-
CAF_Win_unlock (image, *p);
4489-
}
4479+
{
4480+
MPI_Win_sync (*p);
4481+
count = var[index];
4482+
usleep (10 * i);
4483+
++i;
4484+
/* Needed to enforce MPI progress */
4485+
MPI_Win_flush (image, *p);
4486+
}
44904487

44914488
newval = -until_count;
44924489

src/tests/regression/reported/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ target_link_libraries(source-alloc-sync OpenCoarrays)
1313
add_executable(convert-before-put issue-292-convert-type-before-put.f90)
1414
target_link_libraries(convert-before-put OpenCoarrays)
1515

16-
add_executable(event-post issue-293-silent-event-failure.F90)
17-
target_link_libraries(event-post OpenCoarrays)
18-
1916
add_executable(issue-422-send issue-422-send.F90)
2017
target_link_libraries(issue-422-send OpenCoarrays)
2118

src/tests/unit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if (${opencoarrays_aware_compiler})
44
add_subdirectory(init_register)
55
add_subdirectory(collectives)
66
add_subdirectory(sync)
7+
add_subdirectory(events)
78
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7)
89
add_subdirectory(fail_images)
910
endif()

src/tests/unit/events/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Fortran tests
2+
3+
add_executable(event_post_1 event_post_1.f90)
4+
target_link_libraries(event_post_1 OpenCoarrays)
5+
6+
add_executable(event_post_2 event_post_2.f90)
7+
target_link_libraries(event_post_2 OpenCoarrays)
8+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
program event_post_1
2+
use iso_fortran_env
3+
implicit none
4+
5+
type(event_type), allocatable :: snd_copied(:)[:]
6+
7+
associate(me => this_image(), np => num_images())
8+
allocate(snd_copied(np)[*])
9+
if (me == 2) print*,'I am image 2, I am posting to 4'
10+
if (me == 2) event post(snd_copied(2)[4])
11+
if (me == 2) print*,' I am image 2, I have posted to 4'
12+
if (me == 4) then
13+
event wait(snd_copied(2))
14+
print *, 'Test passed.'
15+
end if
16+
if (allocated(snd_copied)) deallocate(snd_copied)
17+
end associate
18+
end program event_post_1
19+
! vim:ts=2:sts=2:sw=2:
20+

0 commit comments

Comments
 (0)