Skip to content

Commit

Permalink
Merge pull request #16 from N00byKing/fix_testcases
Browse files Browse the repository at this point in the history
Fix unrelated issues in test cases
  • Loading branch information
ttm02 authored Feb 13, 2025
2 parents c89a836 + ec45ecd commit aa58f38
Show file tree
Hide file tree
Showing 93 changed files with 248 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_INT, global_sum, 1, MPI_INT, null_comm);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Count-1.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 2, MPI_INT, global_sum, 2, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Count-2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_INT, global_sum, 2, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Count-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, -1, MPI_INT, global_sum, 2, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Count-4.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_INT, global_sum, -1, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_INT, global_sum, 1, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Type-1.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_DOUBLE, global_sum, 1, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Type-2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_INT, global_sum, 1, MPI_DOUBLE, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Type-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_DOUBLE, global_sum, 1, MPI_DOUBLE, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIAllgather-Type-4.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
MPI_Allgather(&local_sum, 1, MPI_UNSIGNED, global_sum, 1, MPI_UNSIGNED, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);

MPI_Comm *comm = NULL;
MPI_Comm comm = NULL;
MPI_Reduce(&local_sum, &global_sum, 1, MPI_INT, MPI_SUM, 0, comm);

if (myRank == 0) {
Expand Down
12 changes: 6 additions & 6 deletions micro-benches/0-level/coll/ArgError-MPIReduce-Count-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
#include <stddef.h>
#include <stdio.h>
/*
* Too many elements in Reduce call. (line 20)
* Reduce call data types do not match. (line 20)
*/
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum = 4;
int global_sum = 0;
int local_sum[5] = {4, 4, 4, 4, 4};
int global_sum[5] = {0};

MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);

if (myRank == 0) {
MPI_Reduce(&local_sum, &global_sum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(local_sum, global_sum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
} else {
MPI_Reduce(&local_sum, &global_sum, 5, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(local_sum, global_sum, 5, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
}

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
30 changes: 30 additions & 0 deletions micro-benches/0-level/coll/ArgError-MPIReduce-Count-3a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <mpi.h>
#include <stddef.h>
#include <stdio.h>
/*
* Reduce call attempts to read out of bounds. (line 20)
*/
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum = 4;
int global_sum = 0;

MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);

if (myRank == 0) {
MPI_Reduce(&local_sum, &global_sum, 5, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
} else {
MPI_Reduce(&local_sum, &global_sum, 5, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
}

if (myRank == 0) {
printf("Result: %d", global_sum);
}

MPI_Finalize();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_INT, root, MPI_COMM_NULL);
MPI_Scatter(local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_INT, root, MPI_COMM_NULL);

MPI_Finalize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
int root = 0;

MPI_Comm comm = NULL;
MPI_Scatter(&local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_INT, root, comm);
MPI_Scatter(local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_INT, root, comm);

MPI_Finalize();

Expand Down
6 changes: 3 additions & 3 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Count-1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#include <stddef.h>
#include <stdio.h>
/*
* Too many elements specified to send. (line 16)
* Scatter attempts to read out of bounds. (line 17)
*/
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[2] = {1, 1};
int global_sum = 0;
int global_sum[2] = {0, 0};

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(&local_sum, 2, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 2, MPI_INT, &global_sum, 2, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
22 changes: 22 additions & 0 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Count-1a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <mpi.h>
#include <stddef.h>
#include <stdio.h>
/*
* Scatter receive and send type signatures do not match. (line 17)
*/
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[4] = {1, 1, 1, 1};
int global_sum = 0;

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(local_sum, 2, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

return 0;
}
6 changes: 3 additions & 3 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Count-2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#include <stddef.h>
#include <stdio.h>
/*
* scatter has wrong number of elements for recv buffer. (line 16)
* Scatter has wrong number of elements for recv buffer. (line 16)
*/
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[2] = {1, 1};
int global_sum = 0;
int global_sum[3] = {0};

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_INT, &global_sum, 3, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_INT, global_sum, 3, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIScatter-Count-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

int root = 0;

MPI_Scatter(&local_sum, -1, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, -1, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIScatter-Count-4.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_INT, &global_sum, -1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_INT, &global_sum, -1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
2 changes: 1 addition & 1 deletion micro-benches/0-level/coll/ArgError-MPIScatter-Rank.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

int root = -1;

MPI_Scatter(&local_sum, 1, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_INT, global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_INT, global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
4 changes: 2 additions & 2 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Type-1.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[2] = {1, 1};
int global_sum = 0;
double global_sum = 0.0;

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_DOUBLE, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
4 changes: 2 additions & 2 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Type-2.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[2] = {1, 1};
double local_sum[2] = {1.0, 1.0};
int global_sum = 0;

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_INT, &global_sum, 1, MPI_DOUBLE, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_DOUBLE, &global_sum, 1, MPI_DOUBLE, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
4 changes: 2 additions & 2 deletions micro-benches/0-level/coll/ArgError-MPIScatter-Type-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ int main(int argc, char *argv[]) {
int myRank, numProcs;

int local_sum[2] = {1, 1};
int global_sum = 0;
unsigned int global_sum = 0;

MPI_Init(&argc, &argv);

int root = 0;

MPI_Scatter(&local_sum, 1, MPI_UNSIGNED, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Scatter(local_sum, 1, MPI_UNSIGNED, &global_sum, 1, MPI_UNSIGNED, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
6 changes: 3 additions & 3 deletions micro-benches/0-level/coll/ArgMismatch-MPIReduce-Count.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ int main(int argc, char *argv[]) {
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);

if (myRank == 0) {
MPI_Reduce(&local_sum, &global_sum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(local_sum, global_sum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
} else {
MPI_Reduce(&local_sum, &global_sum, 2, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(local_sum, global_sum, 2, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
}

if (myRank == 0) {
printf("Result: %d", global_sum);
printf("Result: %d", global_sum[0]);
}

MPI_Finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ int main(int argc, char *argv[]) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

if (rank == 0) {
MPI_Recv(&buffer, N, MPI_INT, 1, MSG_TAG_A, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(buffer, N, MPI_INT, 1, MSG_TAG_A, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Recv(&buffer2, N, MPI_INT, 1, MSG_TAG_B, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(buffer2, N, MPI_INT, 1, MSG_TAG_B, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
} else if (rank == 1) {
MPI_Send(&buffer, N, MPI_INT, 0, MSG_TAG_A, MPI_COMM_WORLD);
MPI_Send(&buffer2, N, MPI_INT, 0, MSG_TAG_B, MPI_COMM_WORLD);
MPI_Send(buffer, N, MPI_INT, 0, MSG_TAG_A, MPI_COMM_WORLD);
MPI_Send(buffer2, N, MPI_INT, 0, MSG_TAG_B, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
} else {
num_elements = 2;
}
MPI_Allgather(&local_sum, num_elements, MPI_INT, &global_sum, 1, MPI_INT, MPI_COMM_WORLD);
MPI_Allgather(&local_sum, num_elements, MPI_INT, global_sum, 1, MPI_INT, MPI_COMM_WORLD);

if (myRank == 0) {
printf("Result: %d %d\n", global_sum[0], global_sum[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
root = 0;
}

MPI_Gather(&local_sum, 1, MPI_INT, &global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);
MPI_Gather(&local_sum, 1, MPI_INT, global_sum, 1, MPI_INT, root, MPI_COMM_WORLD);

MPI_Finalize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
} else {
num_elems = 1;
}
MPI_Gather(&local_sum, 1, MPI_INT, &global_sum, num_elems, MPI_INT, root, MPI_COMM_WORLD);
MPI_Gather(&local_sum, 1, MPI_INT, global_sum, num_elems, MPI_INT, root, MPI_COMM_WORLD);
MPI_Finalize();

return 0;
Expand Down
Loading

0 comments on commit aa58f38

Please sign in to comment.