Skip to content

Commit 5661643

Browse files
committed
Fixes for use with gcc<16.
1 parent 680df81 commit 5661643

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ endif()
233233
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0.0 ) )
234234
add_definitions(-DGCC_GE_8) # Tell library to build against GFortran 8.x bindings w/ descriptor change
235235
endif()
236-
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15.0.0 ) )
236+
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS_EQUAL 15.0.0 ) )
237237
add_definitions(-DGCC_GE_15) # Tell library to build against GFortran 15.x bindings
238238
endif()
239-
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 16.0.0 ) )
239+
if ( gfortran_compiler AND ( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0 ) )
240240
add_definitions(-DGCC_GE_16) # Tell library to build against GFortran 16.x bindings
241241
endif()
242242

src/runtime-libraries/mpi/mpi_caf.c

+67-5
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static win_sync *pending_puts = NULL;
226226
/* Linked list of static coarrays registered. Do not expose to public in the
227227
* header, because it is implementation specific.
228228
*
229-
* From gcc-15 on, this list is contained in the teams handling. */
229+
* From gcc-16 on, this list is contained in the teams handling. */
230230
struct caf_allocated_tokens_t
231231
{
232232
caf_token_t token;
@@ -839,7 +839,11 @@ handle_is_present_message(ct_msg_t *msg, void *baseptr)
839839
+= sizeof_desc_for_rank(GFC_DESCRIPTOR_RANK((gfc_descriptor_t *)ptr));
840840
}
841841
else
842+
#ifdef GCC_GE_16
842843
ptr = &baseptr;
844+
#else
845+
ptr = baseptr;
846+
#endif
843847

844848
accessor_hash_table[msg->accessor_index].u.is_present(
845849
add_data, &msg->dest_image, &result, ptr, &src_token, 0);
@@ -5740,11 +5744,11 @@ team_translate(int *remote_image, int *this_image,
57405744
caf_token_t token __attribute__((unused)), int image_index,
57415745
caf_team_t *team, int *team_number, int *stat)
57425746
{
5747+
#ifdef GCC_GE_16
57435748
MPI_Group world_group, team_group, remote_group;
57445749
int ierr, trans, team_id = current_team->team_list_elem->team_id;
57455750
MPI_Comm remote_comm = MPI_COMM_NULL;
57465751

5747-
#ifdef GCC_GE_16
57485752
if (team)
57495753
{
57505754
caf_team_stack_node_t *cur = current_team;
@@ -5777,7 +5781,6 @@ team_translate(int *remote_image, int *this_image,
57775781
return false;
57785782
}
57795783
}
5780-
#endif
57815784

57825785
ierr = MPI_Comm_group(CAF_COMM_WORLD, &world_group);
57835786
chk_err(ierr);
@@ -5803,6 +5806,27 @@ team_translate(int *remote_image, int *this_image,
58035806
chk_err(ierr);
58045807
dprint("this: %d -> %d, rmt: %d -> %d on team %d.\n", caf_this_image,
58055808
*this_image + 1, image_index, *remote_image + 1, team_id);
5809+
#else
5810+
MPI_Group current_team_group, win_group;
5811+
int ierr, trans_ranks[2];
5812+
5813+
ierr = MPI_Comm_group(CAF_COMM_WORLD, &current_team_group);
5814+
chk_err(ierr);
5815+
ierr = MPI_Win_get_group(*TOKEN(token), &win_group);
5816+
chk_err(ierr);
5817+
ierr = MPI_Group_translate_ranks(current_team_group, 2,
5818+
(int[]){image_index - 1, mpi_this_image},
5819+
win_group, trans_ranks);
5820+
chk_err(ierr);
5821+
*remote_image = trans_ranks[0];
5822+
*this_image = trans_ranks[1];
5823+
ierr = MPI_Group_free(&current_team_group);
5824+
chk_err(ierr);
5825+
ierr = MPI_Group_free(&win_group);
5826+
chk_err(ierr);
5827+
dprint("this: %d -> %d, rmt: %d -> %d.\n", caf_this_image, *this_image + 1,
5828+
image_index, *remote_image + 1);
5829+
#endif
58065830
return true;
58075831
}
58085832

@@ -5895,7 +5919,11 @@ PREFIX(get_from_remote)(caf_token_t token, const gfc_descriptor_t *opt_src_desc,
58955919
msg->transfer_size = dst_size;
58965920
msg->opt_charlen = opt_src_charlen ? *opt_src_charlen : 0;
58975921
msg->win = *TOKEN(token);
5922+
#ifdef GCC_GE_16
58985923
msg->dest_image = this_image;
5924+
#else
5925+
msg->dest_image = mpi_this_image;
5926+
#endif
58995927
msg->dest_tag = CAF_CT_TAG + 1;
59005928
msg->dest_opt_charlen = opt_dst_charlen ? *opt_dst_charlen : 1;
59015929
msg->flags = (opt_dst_desc ? CT_DST_HAS_DESC : 0)
@@ -5939,8 +5967,13 @@ PREFIX(get_from_remote)(caf_token_t token, const gfc_descriptor_t *opt_src_desc,
59395967
"for internal buffer in get_from_remote().");
59405968
}
59415969
dprint("waiting to receive %zd bytes from %d.\n", dst_size, remote_image);
5970+
#ifdef GCC_GE_16
59425971
ierr = MPI_Recv(t_buff, dst_size, MPI_BYTE, remote_image, msg->dest_tag,
59435972
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
5973+
#else
5974+
ierr = MPI_Recv(t_buff, dst_size, MPI_BYTE, image_index - 1, msg->dest_tag,
5975+
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
5976+
#endif
59445977
chk_err(ierr);
59455978
dprint("received %zd bytes as requested from %d.\n", dst_size,
59465979
remote_image);
@@ -5958,8 +5991,13 @@ PREFIX(get_from_remote)(caf_token_t token, const gfc_descriptor_t *opt_src_desc,
59585991

59595992
dprint("probing for incoming message from %d, tag %d.\n", image_index - 1,
59605993
msg->dest_tag);
5994+
#ifdef GCC_GE_16
5995+
ierr = MPI_Mprobe(remote_image, msg->dest_tag, CAF_COMM_WORLD, &msg_han,
5996+
&status);
5997+
#else
59615998
ierr = MPI_Mprobe(image_index - 1, msg->dest_tag, CAF_COMM_WORLD, &msg_han,
59625999
&status);
6000+
#endif
59636001
chk_err(ierr);
59646002
if (ierr == MPI_SUCCESS)
59656003
{
@@ -6062,8 +6100,14 @@ PREFIX(is_present_on_remote)(caf_token_t token, const int image_index,
60626100
void *src_ptr = ((mpi_caf_token_t *)token)->memptr;
60636101

60646102
dprint("Shortcutting due to self access on image %d.\n", image_index);
6065-
accessor_hash_table[is_present_index].u.is_present(
6066-
add_data, &this_image, &result, &src_ptr, &src_token, 0);
6103+
accessor_hash_table[is_present_index].u.is_present(add_data, &this_image,
6104+
&result,
6105+
#ifdef GCC_GE_16
6106+
&src_ptr,
6107+
#else
6108+
src_ptr,
6109+
#endif
6110+
&src_token, 0);
60676111

60686112
return result;
60696113
}
@@ -6281,7 +6325,11 @@ PREFIX(send_to_remote)(caf_token_t token, gfc_descriptor_t *opt_dst_desc,
62816325
msg->transfer_size = src_size;
62826326
msg->opt_charlen = opt_src_charlen ? *opt_src_charlen : 0;
62836327
msg->win = *TOKEN(token);
6328+
#ifdef GCC_GE_16
62846329
msg->dest_image = this_image;
6330+
#else
6331+
msg->dest_image = mpi_this_image;
6332+
#endif
62856333
msg->dest_tag = CAF_CT_TAG + 1;
62866334
msg->dest_opt_charlen = opt_dst_charlen ? *opt_dst_charlen : 1;
62876335
msg->flags = (opt_dst_desc ? CT_DST_HAS_DESC : 0)
@@ -6324,8 +6372,13 @@ PREFIX(send_to_remote)(caf_token_t token, gfc_descriptor_t *opt_dst_desc,
63246372
char c;
63256373
dprint("waiting to receive 1 byte from %d on tag %d.\n", remote_image,
63266374
msg->dest_tag);
6375+
#ifdef GCC_GE_16
63276376
ierr = MPI_Recv(&c, 1, MPI_BYTE, remote_image, msg->dest_tag,
63286377
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
6378+
#else
6379+
ierr = MPI_Recv(&c, 1, MPI_BYTE, image_index - 1, msg->dest_tag,
6380+
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
6381+
#endif
63296382
chk_err(ierr);
63306383
dprint("received 1 byte as requested from %d on tag %d.\n", remote_image,
63316384
msg->dest_tag);
@@ -6548,7 +6601,11 @@ PREFIX(transfer_between_remotes)(
65486601
dst_msg->transfer_size = src_size;
65496602
dst_msg->opt_charlen = opt_src_charlen ? *opt_src_charlen : 0;
65506603
dst_msg->win = *TOKEN(dst_token);
6604+
#ifdef GCC_GE_16
65516605
dst_msg->dest_image = this_image;
6606+
#else
6607+
dst_msg->dest_image = mpi_this_image;
6608+
#endif
65526609
dst_msg->dest_tag = CAF_CT_TAG + 1;
65536610
dst_msg->dest_opt_charlen = opt_dst_charlen ? *opt_dst_charlen : 1;
65546611
dst_msg->flags
@@ -6593,8 +6650,13 @@ PREFIX(transfer_between_remotes)(
65936650
char c;
65946651
dprint("waiting to receive 1 byte from %d on tag %d.\n", dst_remote_image,
65956652
dst_msg->dest_tag);
6653+
#ifdef GCC_GE_16
65966654
ierr = MPI_Recv(&c, 1, MPI_BYTE, dst_remote_image, dst_msg->dest_tag,
65976655
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
6656+
#else
6657+
ierr = MPI_Recv(&c, 1, MPI_BYTE, dst_image_index - 1, dst_msg->dest_tag,
6658+
CAF_COMM_WORLD, MPI_STATUS_IGNORE);
6659+
#endif
65986660
chk_err(ierr);
65996661
if (dst_stat)
66006662
*dst_stat = c;

src/tests/unit/teams/team_number.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ program main
4343

4444
call assert(team_number()==standard_initial_value,"initial team number conforms with Fortran standard before 'change team'")
4545

46-
#ifdef GCC_GE_15
46+
#ifdef GCC_GE_16
4747
call assert(team_number(get_team(current_team))==standard_initial_value,"initial team number conforms with Fortran standard before 'change team'")
4848
#endif
4949

0 commit comments

Comments
 (0)