-
Notifications
You must be signed in to change notification settings - Fork 897
Implement Connectivity.java example using Java bindings #13201
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
base: main
Are you sure you want to change the base?
Conversation
Hello! The Git Commit Checker CI bot found a few problems with this PR: a46c371: Create Connectivity.java and be able to compile/ru...
Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks! |
2 similar comments
Hello! The Git Commit Checker CI bot found a few problems with this PR: a46c371: Create Connectivity.java and be able to compile/ru...
Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks! |
Hello! The Git Commit Checker CI bot found a few problems with this PR: a46c371: Create Connectivity.java and be able to compile/ru...
Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks! |
dad9cfe
to
448388b
Compare
Hi @jsquyres, can you review my PR when you have the chance? Thank you! |
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 not quite sure how the extra mpi.h.in / python changes came into this PR. Can you rebase to the current tip of main
and avoid including Howard's commit here?
For more information see MPI-3 section 14.3.2. | ||
* ``MPI_T_BIND_MPI_SESSION``: MPI session | ||
|
||
For more information see MPI-4 section 14.3.2. |
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.
The MPI tools chapter moved in MPI-4.
For more information see MPI-4 section 14.3.2. | |
For more information see MPI-4.1 section 15.3.2. |
examples/Connectivity.java
Outdated
@@ -0,0 +1,66 @@ | |||
/* | |||
* Test the connectivity between all processes | |||
* WIP |
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.
Remove WIP.
examples/Connectivity.java
Outdated
MPI.Init(args); | ||
|
||
/* | ||
* MPI_COMM_WORLD is the communicator provided when MPI is |
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.
* MPI_COMM_WORLD is the communicator provided when MPI is | |
* MPI.COMM_WORLD is the communicator provided when MPI is |
examples/Connectivity.java
Outdated
int myRank = MPI.COMM_WORLD.getRank(); | ||
int numProcesses = MPI.COMM_WORLD.getSize(); | ||
Status status; | ||
int verbose = 0; |
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.
Should this be a boolean instead of an integer?
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.
Yes. Not sure why the C example uses an integer. Is that standard C convention?
examples/Connectivity.java
Outdated
String processorName = MPI.getProcessorName(); | ||
|
||
for (int i = 0; i < numProcesses; i++) { | ||
if (myRank == i) { /* Find current process */ |
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 don't know the Java ecosystem at all -- is it more common for single-line comments to be //
instead of /* ... */
?
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.
Other Java programs here that I've seen use both, but mostly use /*.
examples/Connectivity.java
Outdated
System.out.printf("Checking connection between rank %d on %s and rank %d\n", i, processorName, | ||
j); | ||
|
||
int[] dataBuffer = { myRank }; /* |
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.
There's mixing of styles here: end-of-line comments and before-the-line comments. We should probably be consistent.
In the majority of the rest of the Open MPI code base (and in examples/connectivity.c
), we use before-the-line comments. That might be a good choice here, for consistency.
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.
Ok, I will fix that to strictly use before-the-line comments.
examples/Connectivity.java
Outdated
* Data buffer to be sent to next process (in this case, only send | ||
* rank num) | ||
*/ | ||
int[] recBuffer = new int[1]; /* Data buffer that current process receives from previous process */ |
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.
In connectivity_c.c
, the variables are named rank
and peer
. If this example is meant to be the Java version of the C example, it might be good to make them similar in spirit -- e.g., have the variable names and meanings agree.
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.
Got it. I will rename them to rank
and peer
.
examples/Connectivity.java
Outdated
|
||
/* Process must send message first then wait to receive to avoid deadlock */ | ||
MPI.COMM_WORLD.send(dataBuffer, 1, MPI.INT, j, myRank); | ||
MPI.COMM_WORLD.recv(recBuffer, 1, MPI.INT, j, j); |
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.
Heh. I guess we hadn't really looked closely at connectivity_c.c
before, because technically this is a deadlock -- using a blocking send to send to yourself might block and might not. In this case, it (most likely) won't because the message is so short -- but it definitely could.
This example -- and the C example -- should likely be fixed.
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.
Ok, interesting. Should I use non-blocking iSend
and iRecv
instead to fix this?
examples/Connectivity.java
Outdated
} | ||
} else if (myRank > i) { | ||
int[] dataBuffer = { myRank }; | ||
int[] recBuffer = new int[1]; |
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.
Is there a reason to use a fixed array for dataBuffer
and an alloc'ed buffer for recBuffer
? I.e., why the difference?
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 used a fixed array for data buffer because I thought it would be fine prepopulating the array with myRank
since I knew I would be sending that, but I will keep it consistent in this next push. Also, I will be using IntBuffer
instead of int[]
for iSend and iRecv methods.
Signed-off-by: vdhyasani17 <[email protected]>
Add comments to explain the functionality Signed-off-by: vdhyasani17 <[email protected]>
Fix comment semantics and structure Add -v verbose check Signed-off-by: vdhyasani17 <[email protected]>
af303de
to
64badb5
Compare
Sorry, I had some issues with rebasing, so all of my commits are now underneath the comments. |
[WIP] This adds a Java version of the connectivity example using Open MPI's Java bindings. It demonstrates basic point-to-point communication and serves as a reference for Java-based MPI applications. The functionality will be the same as connectivity_c.c.