Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill trailing spaces and tabs in MBI files
[simgrid.git] / teshsuite / smpi / MBI / CollLocalConcurrencyGenerator.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 3, requires MPI 3 implementation
15
16 BEGIN_MPI_FEATURES
17   P2P!basic: Lacking
18   P2P!nonblocking: Lacking
19   P2P!persistent: Lacking
20   COLL!basic: Lacking
21   COLL!nonblocking: @{icollfeature}@
22   COLL!persistent: @{pcollfeature}@
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 #define buff_size 128
39
40 int main(int argc, char **argv) {
41   int nprocs = -1;
42   int rank = -1;
43   int root = 0;
44
45   MPI_Init(&argc, &argv);
46   MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
47   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
48   printf("Hello from rank %d \\n", rank);
49
50   if (nprocs < 2)
51     printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
52
53   int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
54   MPI_Op op = MPI_SUM;
55   MPI_Comm newcom = MPI_COMM_WORLD;
56   MPI_Datatype type = MPI_INT;
57
58   @{init}@
59   @{start}@
60    @{operation}@
61   @{write}@ /* MBIERROR */
62   @{fini}@
63   @{free}@
64
65   MPI_Finalize();
66   printf("Rank %d finished normally\\n", rank);
67   return 0;
68 }
69 """
70
71 for c in icoll + pcoll:
72     patterns = {}
73     patterns = {'c': c}
74     patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
75     patterns['icollfeature'] = 'Yes' if c in icoll else 'Lacking'
76     patterns['pcollfeature'] = 'Yes' if c in pcoll else 'Lacking'
77     patterns['c'] = c
78     patterns['init'] = init[c]("1")
79     patterns['start'] = start[c]("1")
80     patterns['fini'] = fini[c]("1")
81     patterns['operation'] = operation[c]("1")
82     patterns['write'] = write[c]("1")
83     patterns['free'] = free[c]("1")
84
85     replace = patterns
86     replace['shortdesc'] = 'Local concurrency with a collective'
87     replace['longdesc'] = f'The buffer in {c} is modified before the call has been completed.'
88     replace['outcome'] = 'ERROR: LocalConcurrency'
89     replace['errormsg'] = 'Local Concurrency with a collective. The buffer in @{c}@ is modified at @{filename}@:@{line:MBIERROR}@ whereas there is no guarantee the call has been completed.'
90     make_file(template, f'LocalConcurrency_{c}_nok.c', replace)