| 1 |
|
|---|
| 2 | TASS incorporation:
|
|---|
| 3 |
|
|---|
| 4 | Model:
|
|---|
| 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 |
|
|---|
| 27 | State: communicator? good enough for blocking communication.
|
|---|
| 28 | nonblocking requires more stateful message (see MPI Spin)
|
|---|
| 29 |
|
|---|
| 30 | ModelBuilder:
|
|---|
| 31 | needs to work from AST which is C+MPI code.
|
|---|
| 32 |
|
|---|
| 33 | --
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | Fundamentals:
|
|---|
| 38 |
|
|---|
| 39 | expression: $length(array)
|
|---|
| 40 | expression: $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 */
|
|---|
| 45 | typedef 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 */
|
|---|
| 53 | void $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 */
|
|---|
| 61 | void $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 |
|
|---|
| 68 | Action 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:
|
|---|
| 77 | a. is ptr to a variable, or an array element pointer, etc.
|
|---|
| 78 | create 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 |
|
|---|
| 85 | Consider CIVL-C dropping C's awful pointer-array pun.
|
|---|
| 86 | No automatic conversions. (Just drop them if language is CIVL-C).
|
|---|
| 87 |
|
|---|
| 88 | f(double[] a) : really takes an array of double, not pointer.
|
|---|
| 89 | double[] f(...) : returns an array of double
|
|---|
| 90 |
|
|---|
| 91 | To get the C behavior:
|
|---|
| 92 |
|
|---|
| 93 | f(double *p) {...}
|
|---|
| 94 |
|
|---|
| 95 | to call f: f(&a[0]);
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | How hard would it be to add a new type: $sequence<T>
|
|---|
| 103 | to the language? Like vector or variable length array.
|
|---|
| 104 | Then define functions like $append, $add, $remove,
|
|---|
| 105 | $subseq, blah blah: but these are all generic.
|
|---|
| 106 | Need concept of generic functions. Could make them
|
|---|
| 107 | operations.
|
|---|
| 108 |
|
|---|
| 109 | $buffer $buffer_create(void *ptr, $type element_type, int count);
|
|---|
| 110 |
|
|---|
| 111 | $buffer $buffer_pack(void *ptr, int size);
|
|---|
| 112 |
|
|---|
| 113 | Problem: what if type of ptr is just void*. Won't know statically
|
|---|
| 114 | all the types to form the union type. Without some sort of flow
|
|---|
| 115 | analysis, will have to assume every type is possible.
|
|---|
| 116 |
|
|---|
| 117 | flow analysis: look at occurrences of $buffer_pack
|
|---|
| 118 | if type of expression ptr is void*, look at what goes into that
|
|---|
| 119 | expression. pointer arithmetic: ptr argument, trace back
|
|---|
| 120 | through assignments, function calls. forget it.
|
|---|
| 121 |
|
|---|
| 122 | need union of all types.
|
|---|
| 123 |
|
|---|
| 124 | **** collect all types used in model **** easy
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | do essentially the same thing, but take different args.
|
|---|
| 129 | If the element type is complete (and hence can use sizeof)
|
|---|
| 130 | the first can be defined as
|
|---|
| 131 | $buffer_pack(ptr, count*sizeof(t))
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | Messages:
|
|---|
| 136 |
|
|---|
| 137 | $message_pack has to produce a message, but how?
|
|---|
| 138 | Use union type.
|
|---|
| 139 | Union over all types which can occur in message_pack.
|
|---|
| 140 | Inject.
|
|---|
| 141 | Need to extract value from slice of array.
|
|---|
| 142 | Wish I had symbolic operators for that.
|
|---|
| 143 | Could be single variable, entire array, slice of array
|
|---|
| 144 | slice of array: copy elements if concrete bounds, else
|
|---|
| 145 | need array - lambda (not yet implemented)
|
|---|
| 146 |
|
|---|
| 147 | stick in union type.
|
|---|
| 148 |
|
|---|
| 149 | tyedef struct __buffer__ __buffer__;
|
|---|
| 150 | typedef struct __message__ {
|
|---|
| 151 | int source;
|
|---|
| 152 | int dest;
|
|---|
| 153 | int tag;
|
|---|
| 154 | __buffer__ data;
|
|---|
| 155 | int size;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | Translate __buffer__ to CIVLBufferType.
|
|---|
| 159 | Symbolic type: symbolicBufferType:
|
|---|
| 160 | Union-of-array-of-t_i, where t_i ranges over all types
|
|---|
| 161 | occuring in message pack calls.
|
|---|
| 162 |
|
|---|
| 163 | Implement $message_pack : just to create buffer
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 | How about relaxing restriction from C that element types of
|
|---|
| 167 | arrays must be complete? Instead just generate error
|
|---|
| 168 | if you try to take sizeof such a thing.
|
|---|
| 169 | Instead of
|
|---|
| 170 | (double*)$malloc(&h, size)
|
|---|
| 171 | how about
|
|---|
| 172 | $alloc(&h, typeof(double), count);
|
|---|
| 173 |
|
|---|
| 174 | void* $alloc($heap *h, $type type, int count);
|
|---|
| 175 |
|
|---|
| 176 | Add to grammar: "$typeof(sizeable)" just like sizeof, but
|
|---|
| 177 | don't care about completeness.
|
|---|
| 178 | no sizeof required. Type of typeof is $dynamic. Why not "type".
|
|---|
| 179 | ---
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 | Add C++ parameterized type: at least in some cases.
|
|---|
| 183 |
|
|---|
| 184 | $seq<T>
|
|---|
| 185 | $set<T>
|
|---|
| 186 | $map<K,V>
|
|---|
| 187 |
|
|---|
| 188 | This will also require parameterized functions. Yuck. Notation?
|
|---|
| 189 |
|
|---|
| 190 | <T> $set<T> $union($set<T> s1, $set<T> s2);
|
|---|
| 191 |
|
|---|
| 192 | These are all scalar types, i.e., just values.
|
|---|
| 193 | You can add functions to unpack them into arrays.
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 | Do a value dataflow analysis. Loop: widening operator
|
|---|
| 197 |
|
|---|
| 198 | Get recurrency analysis for loop.
|
|---|
| 199 | That means solving for variables in terms of the number of loop
|
|---|
| 200 | iterations.
|
|---|
| 201 | Esp. if linear.
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | To check an error condition can't happen.
|
|---|
| 205 |
|
|---|
| 206 | For every expression e, generate the error expression ef
|
|---|
| 207 | (error free) of e, which is a boolean error-free expression
|
|---|
| 208 | which holds iff e is error-free.
|
|---|
| 209 |
|
|---|
| 210 | ef(a[i]) : i>=0 AND i<length(a)
|
|---|
| 211 | ef(p&&q) : ef(p) AND ((NOT p) IMPLIES ef(q))
|
|---|
| 212 | ef(p||q) : ef(p) AND (p IMPLIES ef(q))
|
|---|
| 213 | eq(!p) : ef(p)
|
|---|
| 214 | ef(*p) : ef(p) AND derefable(p)
|
|---|