| 1 |
|
|---|
| 2 |
|
|---|
| 3 | Canonicalization: map
|
|---|
| 4 | Ref[h,i,l,0] -> Ref[h,i,l',0]
|
|---|
| 5 | H_p_s_v_i_l -> H_p_s_v_i_l' (symbolic constants)
|
|---|
| 6 | Perform substitution on the state
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | Fundamentals:
|
|---|
| 10 |
|
|---|
| 11 | expression: $length(array)
|
|---|
| 12 | expression: $append(array, element)
|
|---|
| 13 | $concatenate, $remove,
|
|---|
| 14 |
|
|---|
| 15 | /* A system type for any segment of memory used as a buffer,
|
|---|
| 16 | * formed using union types */
|
|---|
| 17 | typedef struct __bundle__ $bundle;
|
|---|
| 18 |
|
|---|
| 19 | /* Creates a buffer from the memory region specified by
|
|---|
| 20 | * ptr and size, copying the data into the new buffer */
|
|---|
| 21 | $bundle $bundle_pack(void *ptr, int size);
|
|---|
| 22 |
|
|---|
| 23 | /* Copies the data out of the buffer into the region
|
|---|
| 24 | * specified */
|
|---|
| 25 | void $bundle_unpack($bundle bundle, void *ptr, int size);
|
|---|
| 26 |
|
|---|
| 27 | /* creates a new comm from the given sequence of processes,
|
|---|
| 28 | * by allocating memory and copying the process sequence;
|
|---|
| 29 | * the new comm has no messages */
|
|---|
| 30 | $comm $comm_create(int nprocs, $proc * procs);
|
|---|
| 31 |
|
|---|
| 32 | /* adds the message to the comm */
|
|---|
| 33 | void $comm_enqueue($comm * comm, $message * message);
|
|---|
| 34 |
|
|---|
| 35 | /* finds the first matching message, removes it from
|
|---|
| 36 | * comm, and returns pointer to message */
|
|---|
| 37 | $message * $comm_dequeue($comm * comm, int source, int dest, int tag);
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | Action Plan:
|
|---|
| 41 | - add a CIVLBundleType, similar to CIVLHeapType
|
|---|
| 42 | - collect all types during model building
|
|---|
| 43 | - complete the CIVLBundleType by giving it the list of all types,
|
|---|
| 44 | and the symbolic type which is the union of array of t_i
|
|---|
| 45 | - defined $bundle_pack in executor by:
|
|---|
| 46 | 1. let v = dereference ptr* (just first element)
|
|---|
| 47 | 2. let t = v.type();
|
|---|
| 48 | 3. array-of-t is the type of the bundle you will make by cases:
|
|---|
| 49 | a. is ptr to a variable, or an array element pointer, etc.
|
|---|
| 50 | create the new value of type array-of-t.
|
|---|
| 51 | 4. cast that to type bundleSymbolicType.
|
|---|
| 52 | 5. assign it to lhs.
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | Consider CIVL-C dropping C's awful pointer-array pun.
|
|---|
| 58 | No automatic conversions. (Just drop them if language is CIVL-C).
|
|---|
| 59 |
|
|---|
| 60 | f(double[] a) : really takes an array of double, not pointer.
|
|---|
| 61 | double[] f(...) : returns an array of double
|
|---|
| 62 |
|
|---|
| 63 | To get the C behavior:
|
|---|
| 64 |
|
|---|
| 65 | f(double *p) {...}
|
|---|
| 66 |
|
|---|
| 67 | to call f: f(&a[0]);
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | How hard would it be to add a new type: $sequence<T>
|
|---|
| 75 | to the language? Like vector or variable length array.
|
|---|
| 76 | Then define functions like $append, $add, $remove,
|
|---|
| 77 | $subseq, blah blah: but these are all generic.
|
|---|
| 78 | Need concept of generic functions. Could make them
|
|---|
| 79 | operations.
|
|---|
| 80 |
|
|---|
| 81 | $buffer $buffer_create(void *ptr, $type element_type, int count);
|
|---|
| 82 |
|
|---|
| 83 | $buffer $buffer_pack(void *ptr, int size);
|
|---|
| 84 |
|
|---|
| 85 | Problem: what if type of ptr is just void*. Won't know statically
|
|---|
| 86 | all the types to form the union type. Without some sort of flow
|
|---|
| 87 | analysis, will have to assume every type is possible.
|
|---|
| 88 |
|
|---|
| 89 | flow analysis: look at occurrences of $buffer_pack
|
|---|
| 90 | if type of expression ptr is void*, look at what goes into that
|
|---|
| 91 | expression. pointer arithmetic: ptr argument, trace back
|
|---|
| 92 | through assignments, function calls. forget it.
|
|---|
| 93 |
|
|---|
| 94 | need union of all types.
|
|---|
| 95 |
|
|---|
| 96 | **** collect all types used in model **** easy
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | do essentially the same thing, but take different args.
|
|---|
| 101 | If the element type is complete (and hence can use sizeof)
|
|---|
| 102 | the first can be defined as
|
|---|
| 103 | $buffer_pack(ptr, count*sizeof(t))
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 | Messages:
|
|---|
| 108 |
|
|---|
| 109 | $message_pack has to produce a message, but how?
|
|---|
| 110 | Use union type.
|
|---|
| 111 | Union over all types which can occur in message_pack.
|
|---|
| 112 | Inject.
|
|---|
| 113 | Need to extract value from slice of array.
|
|---|
| 114 | Wish I had symbolic operators for that.
|
|---|
| 115 | Could be single variable, entire array, slice of array
|
|---|
| 116 | slice of array: copy elements if concrete bounds, else
|
|---|
| 117 | need array - lambda (not yet implemented)
|
|---|
| 118 |
|
|---|
| 119 | stick in union type.
|
|---|
| 120 |
|
|---|
| 121 | tyedef struct __buffer__ __buffer__;
|
|---|
| 122 | typedef struct __message__ {
|
|---|
| 123 | int source;
|
|---|
| 124 | int dest;
|
|---|
| 125 | int tag;
|
|---|
| 126 | __buffer__ data;
|
|---|
| 127 | int size;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | Translate __buffer__ to CIVLBufferType.
|
|---|
| 131 | Symbolic type: symbolicBufferType:
|
|---|
| 132 | Union-of-array-of-t_i, where t_i ranges over all types
|
|---|
| 133 | occuring in message pack calls.
|
|---|
| 134 |
|
|---|
| 135 | Implement $message_pack : just to create buffer
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | How about relaxing restriction from C that element types of
|
|---|
| 139 | arrays must be complete? Instead just generate error
|
|---|
| 140 | if you try to take sizeof such a thing.
|
|---|
| 141 | Instead of
|
|---|
| 142 | (double*)$malloc(&h, size)
|
|---|
| 143 | how about
|
|---|
| 144 | $alloc(&h, typeof(double), count);
|
|---|
| 145 |
|
|---|
| 146 | void* $alloc($heap *h, $type type, int count);
|
|---|
| 147 |
|
|---|
| 148 | Add to grammar: "$typeof(sizeable)" just like sizeof, but
|
|---|
| 149 | don't care about completeness.
|
|---|
| 150 | no sizeof required. Type of typeof is $dynamic. Why not "type".
|
|---|
| 151 | ---
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | Think about moving more stuff into model factory, like pointer value
|
|---|
| 155 | manipulation
|
|---|
| 156 |
|
|---|
| 157 | better printing of model
|
|---|
| 158 |
|
|---|
| 159 | better printing of states during execution
|
|---|