Skip to content

Commit c638cfc

Browse files
author
Adriel Poo-Armas
committed
Initial part comm test
1 parent 5940bf3 commit c638cfc

18 files changed

+125
-206
lines changed

part-comm/.test_negPartError.c.swp

12 KB
Binary file not shown.

part-comm/test.c

-74
This file was deleted.

part-comm/test_commOrder0.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ double message [PARTITIONS * COUNT];
1919

2020
//MPI variable declarations
2121
int src = 0, dest = 1, tag = 100, flag = 0;
22-
int myrank, provided, len, i, j;
23-
char hostname[MPI_MAX_PROCESSOR_NAME];
22+
int myrank, provided, i, j;
2423
MPI_Count partitions = PARTITIONS;
2524
MPI_Request request;
2625

@@ -29,7 +28,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2928
if (provided < MPI_THREAD_SERIALIZED)
3029
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3130
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
32-
MPI_Get_processor_name(hostname, &len);
3331

3432
if (myrank == 0)
3533
{

part-comm/test_commOrder1.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ int main (int argc, char *argv[])
1818
double message [PARTITIONS * COUNT];
1919

2020
//MPI variable declaration
21-
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
22-
int myrank, provided, len, i, j;
23-
char hostname[MPI_MAX_PROCESSOR_NAME];
21+
int src = 0, dest = 1, tag = 100, flag = 0;
22+
int myrank, provided, i, j;
2423
MPI_Count partitions = PARTITIONS;
2524
MPI_Request request;
2625

@@ -29,7 +28,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2928
if (provided < MPI_THREAD_SERIALIZED)
3029
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3130
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
32-
MPI_Get_processor_name(hostname, &len);
3331

3432
if (myrank == 0)
3533
{

part-comm/test_commOrder2.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ double message [PARTITIONS * COUNT];
1919

2020
//MPI variables declaration
2121
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
22-
int myrank, provided, len, i, j;
23-
char hostname[MPI_MAX_PROCESSOR_NAME];
22+
int myrank, provided, i, j;
2423
MPI_Count partitions = PARTITIONS;
2524
MPI_Request request;
2625

@@ -29,7 +28,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2928
if (provided < MPI_THREAD_SERIALIZED)
3029
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3130
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
32-
MPI_Get_processor_name(hostname, &len);
3331

3432
if (myrank == 0)
3533
{

part-comm/test_commOrder3.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ double message [PARTITIONS * COUNT];
2222

2323
//MPI variables declarations
2424
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
25-
int myrank, provided, len, timer, trigger, i, j;
26-
char hostname[MPI_MAX_PROCESSOR_NAME];
25+
int myrank, provided, timer, trigger, i, j;
2726
MPI_Count partitions = PARTITIONS;
2827
MPI_Request request;
2928

@@ -32,7 +31,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
3231
if (provided < MPI_THREAD_SERIALIZED)
3332
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3433
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
35-
MPI_Get_processor_name(hostname, &len);
3634

3735
if (myrank == 0)
3836
{

part-comm/test_negPartError.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ MPI_Count partitions = 0 - PARTITIONS;
2222

2323
//MPI variables declarations
2424
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
25-
int myrank, provided, len, i, j;
26-
char hostname[MPI_MAX_PROCESSOR_NAME];
25+
int myrank, provided, i, j;
2726
MPI_Request request;
2827

2928
//Initializing threaded MPI
3029
MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
3130
if (provided < MPI_THREAD_SERIALIZED)
3231
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3332
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
34-
MPI_Get_processor_name(hostname, &len);
3533

3634
if (myrank == 0)
3735
{
@@ -69,7 +67,7 @@ else if (myrank == 1)
6967
//Test the buffer to check that the message was recieved correctly
7068
for (i = 0; i < (PARTITIONS * COUNT); i++)
7169
{
72-
assert(message[i] = (i+1));
70+
assert(message[i] == (i+1));
7371
}
7472
printf("Test Passed Succesfully\n");
7573
MPI_Request_free(&request);

part-comm/test_nullBuff.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ double message [PARTITIONS * COUNT];
1919

2020
//MPI variables declarations
2121
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
22-
int myrank, provided, len, i, j;
23-
char hostname[MPI_MAX_PROCESSOR_NAME];
22+
int myrank, provided, i, j;
2423
MPI_Count partitions = PARTITIONS;
2524
MPI_Request request;
2625

@@ -29,7 +28,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2928
if (provided < MPI_THREAD_SERIALIZED)
3029
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3130
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
32-
MPI_Get_processor_name(hostname, &len);
3331

3432
if (myrank == 0)
3533
{

part-comm/test_parrived.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ double message [PARTITIONS * COUNT];
2424

2525
//MPI variables declarations
2626
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0, counter = 0 ;
27-
int myrank, provided, len, timer, trigger, i, j;
28-
char hostname[MPI_MAX_PROCESSOR_NAME];
27+
int myrank, provided, timer, trigger, i, j;
2928
MPI_Count partitions = PARTITIONS;
3029
MPI_Request request;
3130

@@ -34,7 +33,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
3433
if (provided < MPI_THREAD_SERIALIZED)
3534
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3635
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
37-
MPI_Get_processor_name(hostname, &len);
3836

3937
if (myrank == 0)
4038
{

part-comm/test_partComm.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ double message [PARTITIONS * COUNT];
1818

1919
//MPI variables declarations
2020
int src = 0, dest = 1, tag = 100, flag = 0;
21-
int myrank, provided, len, i, j;
22-
char hostname[MPI_MAX_PROCESSOR_NAME];
21+
int myrank, provided, i, j;
2322
MPI_Count partitions = PARTITIONS;
2423
MPI_Request request;
2524

@@ -28,7 +27,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2827
if (provided < MPI_THREAD_SERIALIZED)
2928
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3029
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
31-
MPI_Get_processor_name(hostname, &len);
3230

3331
if (myrank == 0)
3432
{

part-comm/test_preadyError0.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
* Shows the behavior of the communication when Pready is call on an partition that doesn't exist.
44
* This action should be erroneous.
55
*/
6-
/*Partitions MPI Unit Test
7-
* *
8-
* * Shows the behavior of the communication when Pready is call on an already active partition.
9-
* * This action should be erroneous.
10-
* */
11-
126

137
#include <stdio.h>
148
#include <stdlib.h>
@@ -25,8 +19,7 @@ double message [PARTITIONS * COUNT];
2519

2620
//MPI variable declaration
2721
int src = 0, dest = 1, tag = 100, flag = 0;
28-
int myrank, provided, len, i, j;
29-
char hostname[MPI_MAX_PROCESSOR_NAME];
22+
int myrank, provided, i, j;
3023
MPI_Count partitions = PARTITIONS;
3124
MPI_Request request;
3225

@@ -35,7 +28,6 @@ MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
3528
if (provided < MPI_THREAD_SERIALIZED)
3629
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
3730
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
38-
MPI_Get_processor_name(hostname, &len);
3931

4032
if (myrank == 0)
4133
{

part-comm/test_preadyError1.c

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*Partitions MPI Unit Test
2+
*
3+
* Shows the behavior of the communication when Pready is call on an already active partition.
4+
* This action should be erroneous.
5+
*/
6+
7+
18
#include <stdio.h>
29
#include <stdlib.h>
310
#include "mpi.h"
@@ -8,36 +15,44 @@
815

916
int main (int argc, char *argv[])
1017
{
18+
//Buffer message
1119
double message [PARTITIONS * COUNT];
12-
int src = 0, dest = 1, tag = 100, flag = 0, flag2 = 0;
13-
int myrank, provided, len, i, j;
14-
int partitionsList[];
15-
char hostname[MPI_MAX_PROCESSOR_NAME];
20+
21+
//Defining an array of partitions
22+
int partitionsList[8];
23+
24+
//MPI varaibles declarations
25+
int src = 0, dest = 1, tag = 100, flag = 0;
26+
int myrank, provided, i, j;
1627
MPI_Count partitions = PARTITIONS;
1728
MPI_Request request;
1829

30+
//Initializing threaded MPI
1931
MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &provided);
2032
if (provided < MPI_THREAD_SERIALIZED)
2133
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
2234
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
23-
MPI_Get_processor_name(hostname, &len);
2435

2536
if (myrank == 0)
2637
{
2738
MPI_Psend_init(message, partitions, COUNT, MPI_DOUBLE, dest, tag, MPI_COMM_WORLD, MPI_INFO_NULL, &request);
2839
MPI_Start(&request);
2940

41+
//Iterating through each buffer partition, filling them and marking them ready to send
3042
for (i = 0; i < partitions; i++)
3143
{
3244
for (j = (i*COUNT); j < ((i+1)*COUNT); j++)
3345
{
3446
message[j] = j+1;
3547
}
36-
partitionList[i] = i;
48+
partitionsList[i] = i;
3749
MPI_Pready(i, request);
3850
}
51+
52+
//Mark ready all of the partitions, which are already declared ready/active
3953
MPI_Pready_list(partitions, partitionsList, request);
4054

55+
//Test for overall send operation completion
4156
while (!flag)
4257
{
4358
MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
@@ -49,14 +64,16 @@ else if (myrank == 1)
4964
MPI_Precv_init(message, partitions, COUNT, MPI_DOUBLE, src, tag, MPI_COMM_WORLD, MPI_INFO_NULL, &request);
5065
MPI_Start(&request);
5166

67+
//Test for overall recieve operation completion
5268
while (!flag)
5369
{
5470
MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
5571
}
56-
72+
73+
//Test the buffer to check that the message was recieved correctly
5774
for (i = 0; i < (PARTITIONS * COUNT); i++)
5875
{
59-
assert(message[i] = (i+1));
76+
assert(message[i] == (i+1));
6077
}
6178
printf("Test Passed Succesfully\n");
6279
MPI_Request_free(&request);

0 commit comments

Comments
 (0)