-
Notifications
You must be signed in to change notification settings - Fork 7
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
Issue96 #110
Merged
Issue96 #110
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e890c4a
Add example with two different basic datatypes (utlimately for valida…
gvallee eae2b2a
Datatype size bugfix
gvallee cb5c4ad
Update copyright statement
gvallee a576e59
Validation code for datatypes' sizes
gvallee f0878e9
Update/add copyright statements.
gvallee 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 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 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,106 @@ | ||
/************************************************************************* | ||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. | ||
* | ||
* See LICENSE.txt for license information | ||
************************************************************************/ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <assert.h> | ||
#include "mpi.h" | ||
|
||
#define MPICHECK(c) \ | ||
do \ | ||
{ \ | ||
if (c != MPI_SUCCESS) \ | ||
{ \ | ||
fprintf(stderr, "MPI command failed\n"); \ | ||
return 1; \ | ||
} \ | ||
} while (0); | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int i; | ||
int world_size; | ||
int world_rank; | ||
int *send_buffer_int; | ||
int *recv_buffer_int; | ||
double *send_buffer_double; | ||
double *recv_buffer_double; | ||
int *send_count; | ||
int *recv_count; | ||
int *recv_displ; | ||
int *send_displ; | ||
|
||
MPICHECK(MPI_Init(&argc, &argv)); | ||
MPICHECK(MPI_Comm_size(MPI_COMM_WORLD, &world_size)); | ||
MPICHECK(MPI_Comm_rank(MPI_COMM_WORLD, &world_rank)); | ||
|
||
send_buffer_int = (int *)calloc(world_size * world_size, sizeof(int)); | ||
assert(send_buffer_int); | ||
recv_buffer_int = (int *)calloc(world_size * world_size, sizeof(int)); | ||
assert(recv_buffer_int); | ||
send_buffer_double = (double *)calloc(world_size * world_size, sizeof(double)); | ||
assert(send_buffer_double); | ||
recv_buffer_double = (double *)calloc(world_size * world_size, sizeof(double)); | ||
assert(recv_buffer_double); | ||
send_count = calloc(world_size, sizeof(int)); | ||
assert(send_count); | ||
recv_count = calloc(world_size, sizeof(int)); | ||
assert(recv_count); | ||
send_displ = calloc(world_size, sizeof(int)); | ||
assert(send_displ); | ||
recv_displ = calloc(world_size, sizeof(int)); | ||
assert(recv_displ); | ||
|
||
for (i = 0; i < world_size * world_size; i++) | ||
{ | ||
send_buffer_int[i] = i + 10 * world_rank; | ||
} | ||
|
||
for (i = 0; i < world_size * world_size; i++) | ||
{ | ||
send_buffer_double[i] = i + 10 * world_rank; | ||
} | ||
|
||
for (i = 0; i < world_size; i++) | ||
{ | ||
send_count[i] = 1; | ||
recv_count[i] = 1; | ||
recv_displ[i] = 0; | ||
send_displ[i] = 0; | ||
} | ||
|
||
if (world_rank == 0) | ||
{ | ||
int s; | ||
MPI_Type_size(MPI_INT, &s); | ||
fprintf(stdout, "Size of MPI_INT: %d\n", s); | ||
MPI_Type_size(MPI_DOUBLE, &s); | ||
fprintf(stdout, "Size of MPI_DOUBLE: %d\n", s); | ||
} | ||
|
||
MPICHECK(MPI_Alltoallv(send_buffer_int, send_count, send_displ, MPI_INT, | ||
recv_buffer_int, recv_count, recv_displ, MPI_INT, | ||
MPI_COMM_WORLD)); | ||
|
||
MPICHECK(MPI_Alltoallv(send_buffer_double, send_count, send_displ, MPI_DOUBLE, | ||
recv_buffer_double, recv_count, recv_displ, MPI_DOUBLE, | ||
MPI_COMM_WORLD)); | ||
|
||
free(send_buffer_int); | ||
free(recv_buffer_int); | ||
free(send_buffer_double); | ||
free(recv_buffer_double); | ||
free(send_count); | ||
free(recv_count); | ||
free(send_displ); | ||
free(recv_displ); | ||
MPI_Finalize(); | ||
return EXIT_SUCCESS; | ||
|
||
exit_on_failure: | ||
MPI_Finalize(); | ||
return EXIT_FAILURE; | ||
} |
This file contains 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 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
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.
This is the same as for alltoall.c, which may of course be what you want. For alltoall it is not necesary to gather the send types because the counts are gathered and bocksize = sendtypesize * sendcount is a constant, so having gathered the sendcounts the sendtypesize used at each node can be inferred. Does something similar apply to the more complicated alltollv - I have not worked it out yet but man for alltoallv says this, which may be helpful:
"When a pair of processes exchanges data, each may pass different element count and datatype arguments so long as the sender specifies the same amount of data to send (in bytes) as the receiver expects to receive.
"Note that process i may send a different amount of data to process j than it receives from process j. Also, a process may send entirely different amounts of data to different processes in the communicator. "
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 think I am missing something:
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 agree it should be a separate issue. Just thought it worth a precautionary heads up before you work on the golang consumer of this data. Observation - the github interface is not so good a drawing attention to motivation for and decisions on scope of changes - or am I still a newbie looking in the wrong place?!
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.
Issue #111