source: CIVL/notes/notes.txt@ 97cfc53

1.23 2.0 main test-branch
Last change on this file since 97cfc53 was 888ec66, checked in by Stephen Siegel <siegel@…>, 13 years ago

Implemented bundles and bundle_pack. Still need unpack.

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

  • Property mode set to 100644
File size: 4.3 KB
Line 
1
2
3Canonicalization: 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)
6Perform substitution on the state
7
8
9Fundamentals:
10
11expression: $length(array)
12expression: $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 */
17typedef 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 */
25void $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 */
33void $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
40Action 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:
49a. is ptr to a variable, or an array element pointer, etc.
50create 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
57Consider CIVL-C dropping C's awful pointer-array pun.
58No automatic conversions. (Just drop them if language is CIVL-C).
59
60f(double[] a) : really takes an array of double, not pointer.
61double[] f(...) : returns an array of double
62
63To get the C behavior:
64
65f(double *p) {...}
66
67to call f: f(&a[0]);
68
69
70
71
72
73
74How hard would it be to add a new type: $sequence<T>
75to the language? Like vector or variable length array.
76Then define functions like $append, $add, $remove,
77$subseq, blah blah: but these are all generic.
78Need concept of generic functions. Could make them
79operations.
80
81$buffer $buffer_create(void *ptr, $type element_type, int count);
82
83$buffer $buffer_pack(void *ptr, int size);
84
85Problem: what if type of ptr is just void*. Won't know statically
86all the types to form the union type. Without some sort of flow
87analysis, will have to assume every type is possible.
88
89flow analysis: look at occurrences of $buffer_pack
90if type of expression ptr is void*, look at what goes into that
91expression. pointer arithmetic: ptr argument, trace back
92through assignments, function calls. forget it.
93
94need union of all types.
95
96**** collect all types used in model **** easy
97
98
99
100do essentially the same thing, but take different args.
101If the element type is complete (and hence can use sizeof)
102the first can be defined as
103 $buffer_pack(ptr, count*sizeof(t))
104
105
106
107Messages:
108
109$message_pack has to produce a message, but how?
110Use union type.
111Union over all types which can occur in message_pack.
112Inject.
113Need to extract value from slice of array.
114Wish I had symbolic operators for that.
115Could be single variable, entire array, slice of array
116slice of array: copy elements if concrete bounds, else
117need array - lambda (not yet implemented)
118
119stick in union type.
120
121tyedef struct __buffer__ __buffer__;
122typedef struct __message__ {
123 int source;
124 int dest;
125 int tag;
126 __buffer__ data;
127 int size;
128}
129
130Translate __buffer__ to CIVLBufferType.
131Symbolic type: symbolicBufferType:
132Union-of-array-of-t_i, where t_i ranges over all types
133occuring in message pack calls.
134
135Implement $message_pack : just to create buffer
136
137
138How about relaxing restriction from C that element types of
139arrays must be complete? Instead just generate error
140if you try to take sizeof such a thing.
141Instead of
142(double*)$malloc(&h, size)
143 how about
144$alloc(&h, typeof(double), count);
145
146void* $alloc($heap *h, $type type, int count);
147
148Add to grammar: "$typeof(sizeable)" just like sizeof, but
149don't care about completeness.
150no sizeof required. Type of typeof is $dynamic. Why not "type".
151---
152
153
154Think about moving more stuff into model factory, like pointer value
155manipulation
156
157better printing of model
158
159better printing of states during execution
Note: See TracBrowser for help on using the repository browser.