Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unnecessary newlines.
[simgrid.git] / teshsuite / smpi / MBI / RMARemoteRemoteConcurrencyGenerator.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 2, requires MPI 3 implementation (for lock_all/unlock_all epochs)
15
16 BEGIN_MPI_FEATURES
17         P2P!basic: Lacking 
18         P2P!nonblocking: Lacking
19         P2P!persistent: Lacking
20         COLL!basic: Lacking
21         COLL!nonblocking: Lacking
22         COLL!persistent: Lacking
23         COLL!tools: Lacking
24         RMA: @{rmafeature}@
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 N 1
39
40 int main(int argc, char **argv) {
41   int nprocs = -1;
42   int rank = -1;
43         MPI_Win win;
44   int winbuf[100] = {0};
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_Datatype type = MPI_INT;
55         int target = 1;
56
57   MPI_Win_create(&winbuf, 100 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
58
59         @{init1}@ 
60
61   @{epoch}@
62
63         if (rank == 0 || rank == 2) {
64         @{operation1}@ /* MBIERROR1 */
65         }
66
67   @{finEpoch}@
68
69   MPI_Win_free(&win);
70
71   MPI_Finalize();
72   return 0;
73 }
74 """
75
76
77 for e in epoch:
78     for p1 in get + put: 
79         patterns = {}
80         patterns = {'e': e, 'p1': p1}
81         patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'  
82         patterns['rmafeature'] = 'Yes'
83         patterns['p1'] = p1 
84         patterns['e'] = e 
85         patterns['epoch'] = epoch[e]("1") 
86         patterns['finEpoch'] = finEpoch[e]("1") 
87         patterns['init1'] = init[p1]("1") 
88         patterns['operation1'] = operation[p1]("1") 
89
90                 # Generate a data race (Get + Get/load/store/Put)
91         replace = patterns 
92         replace['shortdesc'] = 'Global Concurrency error.' 
93         replace['longdesc'] = 'Global Concurrency error. Both processes 0 and 2 access the window in process 1 with @{p1}@'
94         replace['outcome'] = 'ERROR: GlobalConcurrency' 
95         replace['errormsg'] = 'Global Concurrency error. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ conflicts in process 1'
96         make_file(template, f'GlobalConcurrency_rr_{e}_{p1}_nok.c', replace)