Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Resynch MBI generators with upstream
[simgrid.git] / teshsuite / smpi / MBI / P2PInvalidComGenerator.py
1 #! /usr/bin/python3
2 import os
3 import sys
4 from generator_utils import *
5
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
8
9   Origin: @{origin}@
10
11   Description: @{shortdesc}@
12     @{longdesc}@
13
14    Version of MPI: Conforms to MPI 1.1, does not require MPI 2 implementation
15
16 BEGIN_MPI_FEATURES
17   P2P!basic: @{p2pfeature}@
18   P2P!nonblocking: @{ip2pfeature}@
19   P2P!persistent: @{persfeature}@
20   COLL!basic: Lacking
21   COLL!nonblocking: Lacking
22   COLL!persistent: Lacking
23   COLL!tools: Yes
24   RMA: Lacking
25 END_MPI_FEATURES
26
27 BEGIN_MBI_TESTS
28   $ mpirun -np 2 ${EXE}
29   | @{outcome}@
30   | @{errormsg}@
31 END_MBI_TESTS
32 //////////////////////       End of MBI headers        /////////////////// */
33
34 #include <mpi.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37
38
39 int main(int argc, char **argv) {
40   int nprocs = -1;
41   int rank = -1;
42   int src=0, dest=1;
43   int stag = 0, rtag = 0;
44   int buff_size = 1;
45
46   MPI_Init(&argc, &argv);
47   MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
48   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
49   printf("Hello from rank %d \\n", rank);
50
51   MPI_Datatype type = MPI_INT;
52   MPI_Comm newcom = MPI_COMM_WORLD;
53
54   @{init1}@
55   @{init2}@
56   if (rank == 0) {
57     @{change_com1}@
58     @{operation1}@ /* MBIERROR1 */
59     @{start1}@
60     @{fini1}@
61   }else if (rank == 1) {
62     @{change_com2}@
63     @{operation2}@ /* MBIERROR2 */
64     @{start2}@
65     @{fini2}@
66   }
67   @{free1}@
68   @{free2}@
69
70   if(newcom != MPI_COMM_NULL && newcom != MPI_COMM_WORLD)
71     MPI_Comm_free(&newcom);
72
73   MPI_Finalize();
74   printf("Rank %d finished normally\\n", rank);
75   return 0;
76 }
77 """
78
79
80 for p1 in send + isend + psend:
81     for p2 in recv + irecv + precv:
82         patterns = {}
83         patterns = {'p1': p1, 'p2': p2}
84         patterns['origin'] = "MBI"
85         patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
86         patterns['p2pfeature'] = 'Yes' if p1 in send or p2 in recv  else 'Lacking'
87         patterns['ip2pfeature'] = 'Yes' if p1 in isend or p2 in irecv  else 'Lacking'
88         patterns['persfeature'] = 'Yes' if p1 in psend or p2 in precv  else 'Lacking'
89         patterns['p1'] = p1
90         patterns['p2'] = p2
91         patterns['init1'] = init[p1]("1")
92         patterns['init2'] = init[p2]("2")
93         patterns['start1'] = start[p1]("1")
94         patterns['start2'] = start[p2]("2")
95         patterns['fini1'] = fini[p1]("1")
96         patterns['fini2'] = fini[p2]("2")
97         patterns['operation1'] = operation[p1]("1") #send
98         patterns['operation2'] = operation[p2]("2") #recv
99         patterns['free1'] = free[p1]("1")
100         patterns['free2'] = free[p2]("2")
101         patterns['change_com1'] = ""
102         patterns['change_com2'] = ""
103
104         replace = patterns
105         replace['origin'] = "inspired from MPI-Corrbench"
106         replace['shortdesc'] = 'Point to point @{p2}@ has an invalid communicator'
107         replace['longdesc'] = 'MPI_COMM_NULL used in point to point @{p2}@'
108         replace['outcome'] = 'ERROR: InvalidCommunicator'
109         replace['errormsg'] = 'Invalid Communicator. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ uses a null communicator.'
110         replace['change_com2'] = 'newcom = MPI_COMM_NULL;'
111         make_file(template, f'InvalidParam_ComNull_{p2}_{p1}nok.c', replace)
112
113         replace = patterns
114         replace['shortdesc'] = 'Point to point @{p2}@ has an invalid communicator'
115         replace['longdesc'] = 'MPI_COMM_NULL used in point to point @{p2}@'
116         replace['outcome'] = 'ERROR: InvalidCommunicator'
117         replace['errormsg'] = 'Invalid Communicator. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ uses a null communicator.'
118         replace['change_com1'] = 'newcom = MPI_COMM_NULL;'
119         replace['change_com2'] = ""
120         make_file(template, f'InvalidParam_ComNull_{p1}_{p2}nok.c', replace)
121