Skip to content

Handle Integer type arrays for MPI_Allreduce #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

adit4443ya
Copy link
Collaborator

@adit4443ya adit4443ya commented Mar 18, 2025

This changes mandates to change the MPI_INTEGER value for which I have to edit some datatype checks in mpi_wrapper.c

Things would break i guess
But this needs strong review before merging

Cc:-@gxyd

@adit4443ya adit4443ya requested a review from gxyd March 18, 2025 19:24
@adit4443ya
Copy link
Collaborator Author

adit4443ya commented Mar 18, 2025

The GFortran checks are passing locally
@gxyd Can you try it on your system?

@gxyd
Copy link
Collaborator

gxyd commented Mar 19, 2025

@gxyd Can you try it on your system?

I tried this:

> FC="gfortran" ./run_tests.sh
+ MPIEXEC=/Users/gxyd/miniforge3/envs/pot3d_build/bin/mpiexec
++ uname
+ [[ Darwin == \L\i\n\u\x ]]
+ CC=clang
+ clang -I/Users/gxyd/miniforge3/envs/pot3d_build/include -c ../src/mpi_wrapper.c
+ gfortran -c ../src/mpi_c_bindings.f90
../src/mpi_c_bindings.f90:89:132:

   89 |         subroutine c_mpi_allreduce_scalar(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                                                    1
Error: Line truncated at (1) [-Werror=line-truncation]
../src/mpi_c_bindings.f90:89:110:

   89 |         subroutine c_mpi_allreduce_scalar(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                              1
Error: Unterminated character constant beginning at (1)
../src/mpi_c_bindings.f90:90:52:

   90 |             use iso_c_binding, only: c_int, c_double
      |                                                    1
Error: Unexpected USE statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:91:49:

   91 |             real(c_double), intent(in) :: sendbuf
      |                                                 1
Error: Unexpected data declaration statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:92:17:

   92 |             real(c_double), intent(out) :: recvbuf
      |                 1
Error: Parameter ‘c_double’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:93:20:

   93 |             integer(c_int), intent(in) :: count, datatype, op, comm
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:94:20:

   94 |             integer(c_int), intent(out), optional :: ierror
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:95:11:

   95 |         end subroutine
      |           1
Error: Expecting END INTERFACE statement at (1)
../src/mpi_c_bindings.f90:97:132:

   97 |         subroutine c_mpi_allreduce_1d(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                                                    1
Error: Line truncated at (1) [-Werror=line-truncation]
../src/mpi_c_bindings.f90:97:132:

   97 |         subroutine c_mpi_allreduce_1d(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                                                    1
Error: Missing closing paren for binding label at (1)
../src/mpi_c_bindings.f90:98:52:

   98 |             use iso_c_binding, only: c_int, c_double
      |                                                    1
Error: Unexpected USE statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:99:49:

   99 |             real(c_double), intent(in) :: sendbuf
      |                                                 1
Error: Unexpected data declaration statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:100:17:

  100 |             real(c_double), dimension(*), intent(out) :: recvbuf
      |                 1
Error: Parameter ‘c_double’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:101:20:

  101 |             integer(c_int), intent(in) :: count, datatype, op, comm
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:102:20:

  102 |             integer(c_int), intent(out), optional :: ierror
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:103:11:

  103 |         end subroutine
      |           1
Error: Expecting END INTERFACE statement at (1)
../src/mpi_c_bindings.f90:105:132:

  105 |         subroutine c_mpi_allreduce_array_real(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                                                    1
Error: Line truncated at (1) [-Werror=line-truncation]
../src/mpi_c_bindings.f90:105:114:

  105 |         subroutine c_mpi_allreduce_array_real(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_real")
      |                                                                                                                  1
Error: Unterminated character constant beginning at (1)
../src/mpi_c_bindings.f90:106:52:

  106 |             use iso_c_binding, only: c_int, c_double
      |                                                    1
Error: Unexpected USE statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:107:64:

  107 |             real(c_double), dimension(*), intent(in)  :: sendbuf
      |                                                                1
Error: Unexpected data declaration statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:108:17:

  108 |             real(c_double), dimension(*), intent(out) :: recvbuf
      |                 1
Error: Parameter ‘c_double’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:109:20:

  109 |             integer(c_int), intent(in) :: count, datatype, op, comm
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:110:20:

  110 |             integer(c_int), intent(out), optional :: ierror
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:111:11:

  111 |         end subroutine c_mpi_allreduce_array_real
      |           1
Error: Expecting END INTERFACE statement at (1)
../src/mpi_c_bindings.f90:113:132:

  113 |         subroutine c_mpi_allreduce_array_int(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_int")
      |                                                                                                                                    1
Error: Line truncated at (1) [-Werror=line-truncation]
../src/mpi_c_bindings.f90:113:113:

  113 |         subroutine c_mpi_allreduce_array_int(sendbuf, recvbuf, count, datatype, op, comm, ierror) bind(C, name="mpi_allreduce_wrapper_int")
      |                                                                                                                 1
Error: Unterminated character constant beginning at (1)
../src/mpi_c_bindings.f90:114:52:

  114 |             use iso_c_binding, only: c_int, c_double
      |                                                    1
Error: Unexpected USE statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:115:64:

  115 |             integer(c_int), dimension(*), intent(in)  :: sendbuf
      |                                                                1
Error: Unexpected data declaration statement in INTERFACE block at (1)
../src/mpi_c_bindings.f90:116:20:

  116 |             integer(c_int), dimension(*), intent(out) :: recvbuf
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:117:20:

  117 |             integer(c_int), intent(in) :: count, datatype, op, comm
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:118:20:

  118 |             integer(c_int), intent(out), optional :: ierror
      |                    1
Error: Parameter ‘c_int’ at (1) has not been declared or is a variable, which does not reduce to a constant expression
../src/mpi_c_bindings.f90:119:11:

  119 |         end subroutine c_mpi_allreduce_array_int
      |           1
Error: Expecting END INTERFACE statement at (1)
f951: some warnings being treated as errors

> echo $?
1

@adit4443ya adit4443ya force-pushed the Allreduce_Int branch 2 times, most recently from 10f57ca to 2de4072 Compare March 20, 2025 22:59
@adit4443ya
Copy link
Collaborator Author

Ohh it was just line truncation error
Now CI should pass

@adit4443ya
Copy link
Collaborator Author

@gxyd
I guess this can be merged

Copy link
Collaborator

@gxyd gxyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, apologies, I missed this PR earlier.

@gxyd
Copy link
Collaborator

gxyd commented Mar 21, 2025

It requires resolving conflicts now, can you please with that, once that's done, we can squash and merge the commit.

This changes mandates to change the MPI_INTEGER value for which I have to edit datatype checks in mpi_wrapper.c
@adit4443ya adit4443ya merged commit 7f3a580 into lfortran:main Mar 21, 2025
8 checks passed
@adit4443ya
Copy link
Collaborator Author

Thanks for the review!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants