Skip to content

Fix: use correct helper function #60

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 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mpi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void mpi_waitall_wrapper(int *count, int *array_of_requests_f,

void mpi_ssend_wrapper(double *buf, int *count, int *datatype_f, int *dest,
int *tag, int *comm_f, int *ierror) {
MPI_Datatype datatype = get_c_comm_from_fortran(*datatype_f);
MPI_Datatype datatype = get_c_datatype_from_fortran(*datatype_f);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think if you can also figure out a test case that fails if we don't use this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We definitely are lacking on tests it seems.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fails in the compilation step itself!!

 aditya-trivedi   tests    main ≡  ?10    FC='gfortran' ./run_tests.sh 
../src/mpi_wrapper.c: In function 'mpi_ssend_wrapper':
../src/mpi_wrapper.c:203:29: error: initialization of 'MPI_Datatype' {aka 'struct ompi_datatype_t *'} from incompatible pointer type 'MPI_Comm' {aka 'struct ompi_communicator_t *'} [-Wincompatible-pointer-types]
  203 |     MPI_Datatype datatype = get_c_comm_from_fortran(*datatype_f);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
      ```
      
      

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We definitely are lacking on tests it seems.

I'm adding it's test

Copy link
Collaborator

Choose a reason for hiding this comment

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

This fails in the compilation step itself!!

Are you sure that for you locally it's a failure and not a warning?

Can you please confirm this with value of echo $? that you get after running FC='gfortran' ./run_tests.sh?

Copy link
Collaborator

Choose a reason for hiding this comment

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

and if you think about the correctness then too the return type of the get_c_comm_from_fortran is of MPI_comm and we are assigning it to the MPI_datatype

That makes sense, what I'm trying to understand is so that what to fix in the CI so that we catch this error at the CI and don't have to rely on local machine for this error reproducibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes i will do that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here #65

Copy link
Collaborator Author

@adit4443ya adit4443ya Mar 31, 2025

Choose a reason for hiding this comment

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

Sometimes in my laptop this happens
even if i run compilation commands or runtests scripts then it uses the previously compiled version of files and i dont catch error , restarting machine helps a lot in this case

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sometimes in my laptop this happens
even if i run compilation commands or runtests scripts then it uses the previously compiled version of files and i dont catch error , restarting machine helps a lot in this case

Do you use git clean -dfx?


MPI_Comm comm = get_c_comm_from_fortran(*comm_f);
*ierror = MPI_Ssend(buf, *count, datatype, *dest, *tag, comm);
Expand Down
59 changes: 59 additions & 0 deletions tests/ssend_1.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
program ssend_example
use mpi
implicit none

integer, parameter :: ARRAY_SIZE = 10
integer :: rank, size, ierr, i
real(8) :: buffer(10)
integer :: tag = 100

! allocate(buffer(10))
! Initialize MPI environment
call MPI_Init(ierr)

! Get rank (process ID) and size (total number of processes)
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
call MPI_Comm_size(MPI_COMM_WORLD, size, ierr)

if (size < 2) then
if (rank == 0) then
print *, "This example requires at least 2 MPI processes"
end if
call MPI_Finalize(ierr)
stop
end if

! Process 0 sends data to process 1
if (rank == 0) then
! Initialize the buffer with some values
do i = 1, 10
buffer(i) = i * 10
end do

print *, "Process 0: Sending data using MPI_Ssend..."

! Using MPI_Ssend (synchronous send)
! This will block until process 1 starts receiving
call MPI_Ssend(buffer, 10, MPI_REAL8, 1, tag, MPI_COMM_WORLD, ierr)

print *, "Process 0: Send completed successfully"

! Process 1 receives data from process 0
else if (rank == 1) then

print *, "Process 1: Receiving data..."

! Clear the buffer
buffer = 0

! Receive the message
call MPI_Recv(buffer, 10, MPI_REAL8, 0, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr)

print *, "Process 1: Received data:"
! write(*, '(10I5)') buffer
print *, buffer
end if

! Finalize MPI environment
call MPI_Finalize(ierr)
end program ssend_example