Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / MBI / RMAArgGenerator.py
1 #! /usr/bin/python3
2 import os
3 import sys
4 import generator_utils as gen
5
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
8
9   Origin: @{origin}@
10
11   Description: @{shortdesc}@
12     @{longdesc}@
13
14
15 BEGIN_MPI_FEATURES
16   P2P!basic: Lacking
17   P2P!nonblocking: Lacking
18   P2P!persistent: Lacking
19   COLL!basic: Lacking
20   COLL!nonblocking: Lacking
21   COLL!persistent: Lacking
22   COLL!tools: Lacking
23   RMA: @{rmafeature}@
24 END_MPI_FEATURES
25
26 BEGIN_MBI_TESTS
27   $ mpirun -np 2 ${EXE}
28   | @{outcome}@
29   | @{errormsg}@
30 END_MBI_TESTS
31 //////////////////////       End of MBI headers        /////////////////// */
32
33 #include <mpi.h>
34 #include <stddef.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 #define N 10
39
40 int main(int argc, char **argv) {
41   int rank, numProcs;
42
43   MPI_Init(&argc, &argv);
44   MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
45   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
46
47   int *winbuf = (int *)malloc(N * sizeof(int));
48
49   MPI_Win win;
50   MPI_Win_create(&winbuf, N * sizeof(int), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
51
52   MPI_Datatype type = MPI_INT;
53   int target = (rank + 1) % numProcs;
54
55   if(rank == 0){
56     @{epoch}@
57     @{change_arg}@
58     @{init}@
59      @{operation}@ /* MBIERROR2 */
60
61     @{finEpoch}@
62   } else {
63     @{epoch}@
64
65     @{finEpoch}@
66   }
67
68   MPI_Win_free(&win);
69
70   free(winbuf);
71
72   MPI_Finalize();
73   return 0;
74 }
75 """
76
77
78 for e in gen.epoch:
79     for p in gen.rma:
80         patterns = {}
81         patterns = {'e': e, 'p': p}
82         patterns['origin'] = "MBI"
83         patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
84         patterns['rmafeature'] = 'Yes'
85         patterns['p'] = p
86         patterns['e'] = e
87         patterns['epoch'] = gen.epoch[e]("1")
88         patterns['finEpoch'] = gen.finEpoch[e]("1")
89         patterns['init'] = gen.init[p]("1")
90         patterns['operation'] = gen.operation[p]("1")
91         patterns['change_arg'] = ""
92
93         # Generate a code with a null type
94         replace = patterns.copy()
95         replace['shortdesc'] = 'Invalid argument in one-sided operation.'
96         replace['longdesc'] = 'A one-sided operation has MPI_DATATYPE_NULL as a type.'
97         replace['outcome'] = 'ERROR: InvalidDatatype'
98         replace['change_arg'] = 'type = MPI_DATATYPE_NULL;'
99         replace['errormsg'] = '@{p}@ at @{filename}@:@{line:MBIERROR}@ has MPI_DATATYPE_NULL as a type'
100         gen.make_file(template, f'InvalidParam_BufferNullCond_{e}_{p}_nok.c', replace)
101
102         # Generate a code with an invalid type
103         replace = patterns.copy()
104         replace['shortdesc'] = 'Invalid argument in one-sided operation.'
105         replace['longdesc'] = 'Use of an invalid datatype in one-sided operation.'
106         replace['outcome'] = 'ERROR: InvalidDatatype'
107         replace['change_arg'] = 'MPI_Type_contiguous (2, MPI_INT, &type); MPI_Type_commit(&type);MPI_Type_free(&type); /* MBIERROR2 */'
108         replace['errormsg'] = 'Invalid Datatype in @{p}@ at @{filename}@:@{line:MBIERROR}@'
109         gen.make_file(template, f'InvalidParam_DatatypeCond_{e}_{p}_nok.c', replace)