-
Notifications
You must be signed in to change notification settings - Fork 2
Remove C-Wrapper for MPI_Init #16
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
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
program test_mpi_init_rank_size | ||
use mpi | ||
implicit none | ||
integer :: ierr, rank, size | ||
|
||
! Initialize MPI | ||
call MPI_Init(ierr) | ||
if (ierr /= MPI_SUCCESS) then | ||
print *, "MPI_Init failed with error code: ", ierr | ||
stop 1 | ||
end if | ||
|
||
! Get rank and size | ||
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) | ||
if (ierr /= MPI_SUCCESS) then | ||
print *, "MPI_Comm_rank failed with error code: ", ierr | ||
call MPI_Finalize(ierr) | ||
stop 1 | ||
end if | ||
|
||
call MPI_Comm_size(MPI_COMM_WORLD, size, ierr) | ||
if (ierr /= MPI_SUCCESS) then | ||
print *, "MPI_Comm_size failed with error code: ", ierr | ||
call MPI_Finalize(ierr) | ||
stop 1 | ||
end if | ||
|
||
print *, "Hello from rank ", rank, " of ", size | ||
|
||
! Finalize MPI | ||
call MPI_Finalize(ierr) | ||
if (ierr /= MPI_SUCCESS) then | ||
print *, "MPI_Finalize failed with error code: ", ierr | ||
stop 1 | ||
end if | ||
end program test_mpi_init_rank_size |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do both the arguments have to be pass-by-value here? What if I keep it
intent(inout)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see an explanation for why this needs to be passed with
value
attribute with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that passing pointers/reference would make it complex , Hence to keep it safe i used value
Although i didn't checked with intent(inout)
So this is the current situation
Wihout
value
attribute all tests passes locallywith
intent(inout)
lfortran failswith this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I tried locally, and when no intent is specified, then
./run_tests.sh
passes with both LFortran and GFortran.While, when
intent(inout)
is specified, then LFortran fails, but GFortran succeeds. By default, when no intent is specified, then the intent is actuallyintent(inout)
I think.So, there is anyways a bug in LFortran, which should be extracted and reported against LFortran.
I don't really understand this. @certik any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reading: https://docs.open-mpi.org/en/v5.0.x/man-openmpi/man3/MPI_Init.3.html#description, which says:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's Do one thing
We know that LFortran gives error in the intent(inout) declaration
So for now let me create an MRE and open an issue on LFortran and till then we would use value parameter,
Once that issue is resolved we will remove this workaround and things won't get blocked.
Here is the MRE:-lfortran/lfortran#6696
What's your view @gxyd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me create issue in this repo too so that we do not skip it
Here:- #27
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned here, LFortran doesn't fail when no intent is specified, so we still need to answer, whether
value
is the correct way or not specifying any intent at all.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess maybe we need to look at any documentation for what to use
My intuition is not to use value or intent at all, (also i used GROK to do some research and the first thing it told me is not to use it)
maybe i read it somewhere, but i did not found the exact line stating that which parameter is ideal enough.
As with the value approach we might add an extra instruction of storing and then loading
Also i referred this https://gcc.gnu.org/onlinedocs/gfortran/Interoperable-Subroutines-and-Functions.html
It does not use intent(),
Also intent should not affect the passing of the objects at the runtime right?
Hence that issue iss the one which we have to fix at lfortran, but what i feel what ideal to do is not to use anything at all, until unless something comes up again with similar argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, it makes it clear that we don't need
value
attribute specified here.