Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill trailing spaces and tabs in MBI files
[simgrid.git] / teshsuite / smpi / MBI / P2PLocalConcurrencyGenerator.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: MBI
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: Lacking
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 dest=0, src=0;
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   if (nprocs < 2)
52     printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
53
54   MPI_Comm newcom = MPI_COMM_WORLD;
55   MPI_Datatype type = MPI_INT;
56
57   @{init1}@
58   @{init2}@
59   if (rank == 0) {
60     dest = 1; src = 1;
61     @{operation1}@
62     @{start1}@
63     @{write1}@ /* MBIERROR1 */
64     @{fini1}@
65     @{free1}@
66   }else if (rank == 1){
67     dest = 0; src = 0;
68     @{operation2}@
69     @{start2}@
70     @{write2}@ /* MBIERROR2 */
71     @{fini2}@
72     @{free2}@
73   }
74
75   MPI_Finalize();
76   printf("Rank %d finished normally\\n", rank);
77   return 0;
78 }
79 """
80
81
82 for s in send + isend + psend:
83     for r in irecv + precv + recv:
84         patterns = {}
85         patterns = {'s': s, 'r': r}
86         patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
87         patterns['p2pfeature'] = 'Yes' if s in send else 'Lacking'
88         patterns['ip2pfeature'] = 'Yes' if r in irecv else 'Lacking'
89         patterns['persfeature'] = 'Yes' if r in precv else 'Lacking'
90         patterns['s'] = s
91         patterns['r'] = r
92         patterns['init1'] = init[s]("1")
93         patterns['init2'] = init[r]("2")
94         patterns['fini1'] = fini[s]("1")
95         patterns['fini2'] = fini[r]("2")
96         patterns['start1'] = start[s]("1")
97         patterns['start2'] = start[r]("2")
98         patterns['operation1'] = operation[s]("1")
99         patterns['operation2'] = operation[r]("2")
100         patterns['write1'] = write[s]("1")
101         patterns['write2'] = write[r]("2")
102         patterns['free1'] = free[s]("1")
103         patterns['free2'] = free[r]("2")
104
105         # Generate a message race
106         if s in send and r in irecv + precv:
107             replace = patterns
108             replace['shortdesc'] = ' Local Concurrency with a P2P'
109             replace['longdesc'] = f'The message buffer in {r} is modified before the call has been completed.'
110             replace['outcome'] = 'ERROR: LocalConcurrency'
111             replace['errormsg'] = 'Local Concurrency with a P2P. The receive buffer in @{r}@ is modified at @{filename}@:@{line:MBIERROR2}@ whereas there is no guarantee the message has been received.'
112             make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)
113         if s in isend + psend and r in recv:
114             replace = patterns
115             replace['shortdesc'] = ' Local Concurrency with a P2P'
116             replace['longdesc'] = f'The message buffer in {s} is modified before the call has been completed.'
117             replace['outcome'] = 'ERROR: LocalConcurrency'
118             replace['errormsg'] = 'Local Concurrency with a P2P. The send buffer in @{s}@ is modified at @{filename}@:@{line:MBIERROR1}@ whereas there is no guarantee the message has been sent.'
119             make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)
120         if s in isend + psend and r in irecv + precv:
121             replace = patterns
122             replace['shortdesc'] = ' Local Concurrency with a P2P'
123             replace['longdesc'] = f'The message buffer in {s} and {r} are modified before the calls have completed.'
124             replace['outcome'] = 'ERROR: LocalConcurrency'
125             replace['errormsg'] = 'Local Concurrency with a P2P. The message buffers in @{s}@ and @{r}@ are modified at @{filename}@:@{line:MBIERROR1}@ and @{filename}@:@{line:MBIERROR2}@ whereas there is no guarantee the calls have been completed.'
126             make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)