source: CIVL/mods/dev.civl.com/notes/notes.txt@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 5.4 KB
Line 
1
2TASS incorporation:
3
4Model:
5
6 Types:
7 MPIComm
8 MPIStatus
9 MPIRequest
10
11 Constants:
12 MPI_INT, MPI_DOUBLE, MPI_FLOAT, MPI_CHAR, ...
13 MPI_
14
15 Statements:
16 MPISendStatement
17 MPIRecvStatement
18 MPIBarrierStatement
19 MPIIsendStatement
20 MPIIrecvStatement
21 MPIWaitStatement
22
23 Expressions:
24 NemptyExpression
25 NfullExpression
26
27State: communicator? good enough for blocking communication.
28nonblocking requires more stateful message (see MPI Spin)
29
30ModelBuilder:
31needs to work from AST which is C+MPI code.
32
33--
34
35
36
37Fundamentals:
38
39expression: $length(array)
40expression: $append(array, element)
41$concatenate, $remove,
42
43/* A system type for any segment of memory used as a buffer,
44 * formed using union types */
45typedef struct __bundle__ $bundle;
46
47/* Creates a buffer from the memory region specified by
48 * ptr and size, copying the data into the new buffer */
49$bundle $bundle_pack(void *ptr, int size);
50
51/* Copies the data out of the buffer into the region
52 * specified */
53void $bundle_unpack($bundle bundle, void *ptr, int size);
54
55/* creates a new comm from the given sequence of processes,
56 * by allocating memory and copying the process sequence;
57 * the new comm has no messages */
58$comm $comm_create(int nprocs, $proc * procs);
59
60/* adds the message to the comm */
61void $comm_enqueue($comm * comm, $message * message);
62
63/* finds the first matching message, removes it from
64 * comm, and returns pointer to message */
65$message * $comm_dequeue($comm * comm, int source, int dest, int tag);
66
67
68Action Plan:
69 - add a CIVLBundleType, similar to CIVLHeapType
70 - collect all types during model building
71 - complete the CIVLBundleType by giving it the list of all types,
72 and the symbolic type which is the union of array of t_i
73 - defined $bundle_pack in executor by:
74 1. let v = dereference ptr* (just first element)
75 2. let t = v.type();
76 3. array-of-t is the type of the bundle you will make by cases:
77a. is ptr to a variable, or an array element pointer, etc.
78create the new value of type array-of-t.
79 4. cast that to type bundleSymbolicType.
80 5. assign it to lhs.
81
82
83
84
85Consider CIVL-C dropping C's awful pointer-array pun.
86No automatic conversions. (Just drop them if language is CIVL-C).
87
88f(double[] a) : really takes an array of double, not pointer.
89double[] f(...) : returns an array of double
90
91To get the C behavior:
92
93f(double *p) {...}
94
95to call f: f(&a[0]);
96
97
98
99
100
101
102How hard would it be to add a new type: $sequence<T>
103to the language? Like vector or variable length array.
104Then define functions like $append, $add, $remove,
105$subseq, blah blah: but these are all generic.
106Need concept of generic functions. Could make them
107operations.
108
109$buffer $buffer_create(void *ptr, $type element_type, int count);
110
111$buffer $buffer_pack(void *ptr, int size);
112
113Problem: what if type of ptr is just void*. Won't know statically
114all the types to form the union type. Without some sort of flow
115analysis, will have to assume every type is possible.
116
117flow analysis: look at occurrences of $buffer_pack
118if type of expression ptr is void*, look at what goes into that
119expression. pointer arithmetic: ptr argument, trace back
120through assignments, function calls. forget it.
121
122need union of all types.
123
124**** collect all types used in model **** easy
125
126
127
128do essentially the same thing, but take different args.
129If the element type is complete (and hence can use sizeof)
130the first can be defined as
131 $buffer_pack(ptr, count*sizeof(t))
132
133
134
135Messages:
136
137$message_pack has to produce a message, but how?
138Use union type.
139Union over all types which can occur in message_pack.
140Inject.
141Need to extract value from slice of array.
142Wish I had symbolic operators for that.
143Could be single variable, entire array, slice of array
144slice of array: copy elements if concrete bounds, else
145need array - lambda (not yet implemented)
146
147stick in union type.
148
149tyedef struct __buffer__ __buffer__;
150typedef struct __message__ {
151 int source;
152 int dest;
153 int tag;
154 __buffer__ data;
155 int size;
156}
157
158Translate __buffer__ to CIVLBufferType.
159Symbolic type: symbolicBufferType:
160Union-of-array-of-t_i, where t_i ranges over all types
161occuring in message pack calls.
162
163Implement $message_pack : just to create buffer
164
165
166How about relaxing restriction from C that element types of
167arrays must be complete? Instead just generate error
168if you try to take sizeof such a thing.
169Instead of
170(double*)$malloc(&h, size)
171 how about
172$alloc(&h, typeof(double), count);
173
174void* $alloc($heap *h, $type type, int count);
175
176Add to grammar: "$typeof(sizeable)" just like sizeof, but
177don't care about completeness.
178no sizeof required. Type of typeof is $dynamic. Why not "type".
179---
180
181
182Add C++ parameterized type: at least in some cases.
183
184$seq<T>
185$set<T>
186$map<K,V>
187
188This will also require parameterized functions. Yuck. Notation?
189
190<T> $set<T> $union($set<T> s1, $set<T> s2);
191
192These are all scalar types, i.e., just values.
193You can add functions to unpack them into arrays.
194
195
196Do a value dataflow analysis. Loop: widening operator
197
198Get recurrency analysis for loop.
199That means solving for variables in terms of the number of loop
200iterations.
201Esp. if linear.
202
203
204To check an error condition can't happen.
205
206For every expression e, generate the error expression ef
207(error free) of e, which is a boolean error-free expression
208which holds iff e is error-free.
209
210ef(a[i]) : i>=0 AND i<length(a)
211ef(p&&q) : ef(p) AND ((NOT p) IMPLIES ef(q))
212ef(p||q) : ef(p) AND (p IMPLIES ef(q))
213eq(!p) : ef(p)
214ef(*p) : ef(p) AND derefable(p)
Note: See TracBrowser for help on using the repository browser.