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
+
1
8
#include <stdio.h>
2
9
#include <stdlib.h>
3
10
#include "mpi.h"
8
15
9
16
int main (int argc , char * argv [])
10
17
{
18
+ //Buffer message
11
19
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 ;
16
27
MPI_Count partitions = PARTITIONS ;
17
28
MPI_Request request ;
18
29
30
+ //Initializing threaded MPI
19
31
MPI_Init_thread (& argc , & argv , MPI_THREAD_SERIALIZED , & provided );
20
32
if (provided < MPI_THREAD_SERIALIZED )
21
33
MPI_Abort (MPI_COMM_WORLD , EXIT_FAILURE );
22
34
MPI_Comm_rank (MPI_COMM_WORLD , & myrank );
23
- MPI_Get_processor_name (hostname , & len );
24
35
25
36
if (myrank == 0 )
26
37
{
27
38
MPI_Psend_init (message , partitions , COUNT , MPI_DOUBLE , dest , tag , MPI_COMM_WORLD , MPI_INFO_NULL , & request );
28
39
MPI_Start (& request );
29
40
41
+ //Iterating through each buffer partition, filling them and marking them ready to send
30
42
for (i = 0 ; i < partitions ; i ++ )
31
43
{
32
44
for (j = (i * COUNT ); j < ((i + 1 )* COUNT ); j ++ )
33
45
{
34
46
message [j ] = j + 1 ;
35
47
}
36
- partitionList [i ] = i ;
48
+ partitionsList [i ] = i ;
37
49
MPI_Pready (i , request );
38
50
}
51
+
52
+ //Mark ready all of the partitions, which are already declared ready/active
39
53
MPI_Pready_list (partitions , partitionsList , request );
40
54
55
+ //Test for overall send operation completion
41
56
while (!flag )
42
57
{
43
58
MPI_Test (& request , & flag , MPI_STATUS_IGNORE );
@@ -49,14 +64,16 @@ else if (myrank == 1)
49
64
MPI_Precv_init (message , partitions , COUNT , MPI_DOUBLE , src , tag , MPI_COMM_WORLD , MPI_INFO_NULL , & request );
50
65
MPI_Start (& request );
51
66
67
+ //Test for overall recieve operation completion
52
68
while (!flag )
53
69
{
54
70
MPI_Test (& request , & flag , MPI_STATUS_IGNORE );
55
71
}
56
-
72
+
73
+ //Test the buffer to check that the message was recieved correctly
57
74
for (i = 0 ; i < (PARTITIONS * COUNT ); i ++ )
58
75
{
59
- assert (message [i ] = (i + 1 ));
76
+ assert (message [i ] == (i + 1 ));
60
77
}
61
78
printf ("Test Passed Succesfully\n" );
62
79
MPI_Request_free (& request );
0 commit comments