source: CIVL/doc/tutorial/tutorial.tex@ 7d23067

1.23 2.0 main test-branch
Last change on this file since 7d23067 was c1a5aef, checked in by Stephen Siegel <siegel@…>, 12 years ago

Working on tutorial, minor corrections to manual.

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

  • Property mode set to 100644
File size: 31.2 KB
Line 
1\documentclass[t]{beamer}
2\input{preambular}
3\foot{CIVL Tutorial}
4\date{\today}
5\title{{\huge\bf CIVL}\\
6 Concurrency Intermediate Verification Language\\ \ \\
7 Tutorial}
8
9\begin{document}
10
11\begin{frame}[plain]
12 \titlepage
13\end{frame}
14
15
16\section{CIVL User Tutorial}
17
18\begin{frame}{What is CIVL?}
19 CIVL is \ldots
20 \begin{enumerate}
21 \item \ldots a programming language, \alert{CIVL-C}
22 \begin{itemize}
23 \item based on subset of C
24 \item extensions for concurrency, naming of scopes
25 \end{itemize}
26 \item \ldots a suite of tools for analyzing CIVL-C programs
27 \begin{itemize}
28 \item running + dynamic checking
29 \item model checking
30 \item static analyses (coming)
31 \end{itemize}
32 \item \ldots a set of translators from common programming
33 language/concurrency API combinations to CIVL-C
34 \begin{itemize}
35 \item coming
36 \end{itemize}
37 \end{enumerate}
38\end{frame}
39
40\begin{frame}{Some CIVL-C primitives}
41 \begin{tabular}{ll}
42 \cproc & the process type \\
43 \cself & the evaluating process (constant of type \cproc) \\
44 \cscope & the scope type \\
45 \cinput & type qualifier declaring variable to be a program input \\
46 \coutput & type qualifier declaring variable to be a program output \\
47 \cspawn & create a new process running procedure \\
48 \cwait & wait for a process to terminate \\
49 \cassert & check something holds \\
50 \ctrue & boolean value true, used in assertions \\
51 \cfalse & boolean value false, used in assertions \\
52 \cassume & assume something holds \\
53 \cwhen & guarded statement \\
54 \cchoose & nondeterministic choice statement \\
55 \cchooseint & nondeterministic choice of integer
56 \end{tabular}
57\end{frame}
58
59\begin{frame}{CIVL Command line tools}
60 \begin{itemize}
61 \item \code{civl run filename}
62 \begin{itemize}
63 \item run the CIVL program making nondeterministic choices randomly
64 \item \code{-seed=LONG} : use this random seed (reproducible)
65 \end{itemize}
66 \item \code{civl verify filename}
67 \begin{itemize}
68 \item explore reachable state space, checking properties at each state
69 \begin{itemize}
70 \item absence of deadlock, assertion violations, division by $0$,
71 invalid pointer dereference, out of bounds array access, \ldots
72 \end{itemize}
73 \item may specify bounds using \cinput{} variables and command line
74 \begin{itemize}
75 \item \code{-inputX=value}
76 \end{itemize}
77 \item \code{-errorBound=INT} specifies maximum number of errors that
78 will be logged before quitting
79 \end{itemize}
80 \item \code{civl replay}
81 \begin{itemize}
82 \item if a violation was found during \code{verify}, its trace
83 is saved to a file; this will run the trace
84 \item \code{-id=INT} can be used to specify the ID of the trace if more than one
85 \item \code{-trace=tracefile} can be used to specify the exact filename
86 containing trace
87 \end{itemize}
88 \end{itemize}
89\end{frame}
90
91\begin{frame}[containsverbatim]{Example: \code{adder.cvl}}
92
93 \begin{tabular}[t]{l|l}
94 \begin{minipage}[t]{.45\textwidth}\scriptsize
95\begin{verbatim}
96#include <civlc.h>
97
98$input int B;
99$input int N;
100$assume 0<=N && N<=B;
101$input double a[N];
102
103double adderSeq(double *p, int n) {
104 double s = 0.0;
105
106 for (int i = 0; i < n; i++)
107 s += p[i];
108 return s;
109}
110
111double adderPar(double *p, int n) {
112 double s = 0.0;
113 _Bool mutex = 0;
114 $proc workers[n];
115
116 void worker(int i) {
117 double t;
118\end{verbatim}
119 \end{minipage}
120 &
121 \begin{minipage}[t]{.45\textwidth}\scriptsize
122\begin{verbatim}
123 $when (mutex == 0) mutex = 1;
124 t = s;
125 t += p[i];
126 s = t;
127 mutex = 0;
128 }
129
130 for (int j = 0; j < n; j++)
131 workers[j] = $spawn worker(j);
132 for (int j = 0; j < n; j++)
133 $wait workers[j];
134 return s;
135}
136
137void main() {
138 double seq = adderSeq(&a[0], N);
139 double par = adderPar(&a[0], N);
140
141 $assert seq == par;
142}
143\end{verbatim}
144 \end{minipage}
145 \end{tabular}
146\end{frame}
147
148\begin{frame}[containsverbatim]{Verifying \code{adder.cvl}}
149
150 \begin{small}
151\begin{verbatim}
152concurrency$ civl verify -inputB=5 adder.cvl
153CIVL v0.8 of 2014-03-03 -- http://vsl.cis.udel.edu/civl
154
155=================== Stats ===================
156 validCalls : 2801
157 proverCalls : 27
158 memory (bytes) : 128974848
159 time (s) : 4.25
160 maxProcs : 6
161 statesInstantiated : 4103
162 statesSaved : 777
163 statesSeen : 767
164 statesMatched : 72
165 steps : 1090
166 transitions : 838
167
168The standard properties hold for all executions.
169\end{verbatim}
170 \end{small}
171\end{frame}
172
173\begin{frame}{Download and Installation}
174 \begin{enumerate}
175 \item Get a Java 7 VM.
176 \item Go to \url{http://vsl.cis.udel.edu/civl}
177 \item Navigate to downloads, \emph{latest stable release}.
178 \item Download version corresponding to your platform.
179 \begin{itemize}
180 \item for now, pre-compiled versions for OS X and linux (32- and 64-bit)
181 \item other platforms must build from source
182 \end{itemize}
183 \item Unpack and move resulting directory \texttt{CIVL-\textit{tag}}
184 under \texttt{/opt}.
185 \item Download the VSL dependencies archive.
186 \begin{itemize}
187 \item contains a number of pre-compiled open source libraries used by CIVL
188 \item \url{http://vsl.cis.udel.edu/tools/vsl\_depend}
189 \end{itemize}
190 \item Unpack and move resulting directory \texttt{vsl} under \texttt{/opt}.
191 \item Put \texttt{/opt/CIVL-\textit{tag}/bin/civl} in your path.
192 \begin{itemize}
193 \item however you want: move it, symlink, \ldots
194 \end{itemize}
195 \end{enumerate}
196
197 \alert{Note:} You can put \texttt{vsl} and \texttt{CIVL-\textit{tag}}
198 in any directories (not just \texttt{/opt}). Just edit script \texttt{civl}
199 to use the new paths.
200\end{frame}
201
202\begin{frame}[containsverbatim]{Test your installation}
203
204 From command line \ldots
205
206\begin{verbatim}
207concurrency$ civl
208CIVL v0.8 of 2014-03-03 -- http://vsl.cis.udel.edu/civl
209Missing command
210Type "civl help" for command line syntax.
211
212concurrency$ civl help
213...
214\end{verbatim}
215
216Copy \texttt{/opt/CIVL-\textit{tag}/examples/concurrency/adder.cvl}
217to your working directory and try
218
219\begin{verbatim}
220 civl verify -inputB=5 adder.cvl
221\end{verbatim}
222\end{frame}
223
224\begin{frame}{What features are inherited from C?}
225 \begin{itemize}
226 \item most syntax
227 \item types
228 \begin{itemize}
229 \item \texttt{{\U}Bool} $\ra$ $\{0,1\}$
230 \item \texttt{int}, \texttt{long}, \texttt{short}, \ldots $\ra$ $\Z$
231 \item \texttt{double}, \texttt{float}, \ldots $\ra$ $\R$
232 \item structure, array, pointer, and function types
233 \end{itemize}
234 \item expressions
235 \begin{itemize}
236 \item addition, multiplication, division, subtraction, unary minus (\code{+},
237 \code{*}, \code{/}, \code{-})
238 \item integer division (\code{/}) and modulus (\code{\%})
239 \item pointer dereference (\code{*}), address-of (\code{\&})
240 \item array subscript (\code{[...]})
241 \item structure navigation (\code{.})
242 \item logical and (\code{\&\&}), or (\code{||}), not (\code{!})
243 \item \code{==}, \code{!=}, \code{<}, \code{>}, \code{<=}, \code{>=}
244 \item pointer addition (\code{+}) and subtraction (\code{-})
245 \item \code{++}, \code{--}
246 \item \alert{no bit-wise operations} for now
247 \end{itemize}
248 \end{itemize}
249\end{frame}
250
251\begin{frame}{Inherited from C, cont.}
252 \begin{itemize}
253 \item statements
254 \begin{itemize}
255 \item no-op, labeled-statement, compound-statement
256 \item assignments (\code{=}, \code{+=}, \code{-=}, \ldots)
257 \item function call
258 \item \code{if}\ldots\code{else}
259 \item \code{goto}, \code{while}, \code{do}, \code{for},
260 \code{switch}, \code{break}
261 \end{itemize}
262 \item procedure (function) prototypes and definitions
263 \item \code{typedef}
264 \item preprocessing directives
265 \end{itemize}
266\end{frame}
267
268\begin{frame}{New features}
269 \begin{itemize}
270 \item functions can be declared in any scope
271 \item concurrency primitives
272 \begin{itemize}
273 \item spawning processes: \code{\cproc\ p = \cspawn\ f();}
274 \item waiting for a process to terminate: \code{\cwait\ p;}
275 \item guarded commands: \code{\cwhen (x>0) c=1;}
276 \end{itemize}
277 \item nondeterministic choice: \code{\cchoose ...}
278 \item first-class scope objects: \code{\cscope\ s;}
279 \item other primitives useful for verification
280 \begin{itemize}
281 \item input qualifier, assert, assume, procedure contracts
282 \end{itemize}
283 \item library-level constructs supporting message-passing, \ldots
284 \end{itemize}
285\end{frame}
286
287\begin{frame}[containsverbatim]{CIVL-C encoding of Dijkstra's Dining Philosophers}
288 \begin{scriptsize}
289\begin{verbatim}
290#include <civlc.h>
291
292$input int B; // upper bound on number of philosophers
293$input int n; // number of philosophers
294$assume 2<=n && n<=B;
295_Bool forks[n]; // Each fork will be on the table (0) or in a hand (1).
296
297void dine(int id) {
298 int left = id;
299 int right = (id + 1) % n;
300
301 while (1) {
302 $when (forks[left] == 0) forks[left] = 1;
303 $when (forks[right] == 0) forks[right] = 1;
304 forks[right] = 0;
305 forks[left] = 0;
306 }
307}
308
309void main() {
310 for (int i = 0; i < n; i++) forks[i] = 0;
311 for (int i = 0; i < n; i++) $spawn dine(i);
312}
313\end{verbatim}
314 \end{scriptsize}
315\end{frame}
316
317\begin{frame}{Example Illustrating Scopes and Processes}
318 \includegraphics[scale=1.1]{scopeCodeExample}
319\end{frame}
320
321\begin{frame}{Static scope tree and a state for example}
322 \includegraphics[scale=.85]{scopeStateExample}
323\end{frame}
324
325\begin{frame}{Scopes and processes: key points}
326\begin{itemize}
327\item In any state, there is a mapping from the dyscope tree to the
328 static scope tree which maps a dyscope to the static scope of which
329 it is an instance. This mapping is a \alert{tree homomorphism},
330 i.e., if dyscope $u$ is a child of dyscope $v$, then the static
331 scope corresponding to $u$ is a child of the static scope
332 corresponding to $v$.
333\item A static scope may have any number of instances, including 0.
334\item Dynamic scopes are created when control enters the corresponding
335 static scope; they disappear from the state when they become
336 unreachable. A dyscope $v$ is \alert{reachable} if some process has a
337 frame pointing to a dyscope $u$ and there is a path from $u$ up to
338 $v$ that follows the parent edges in the dyscope tree.
339\item Processes are created when functions are spawned; they disappear
340 from the state when their stack becomes empty (either because the
341 process terminates normally or invokes the \alert{\emph{exit}}
342 system function).
343\end{itemize}
344\end{frame}
345
346\begin{frame}{Bundles}
347 \begin{itemize}
348 \item there is a special \cbundle{} type
349 \item represents a ``chunk'' of data
350 \begin{itemize}
351 \item actually a sequence of elements of one type
352 \end{itemize}
353 \item can make one bundle from a sequence of ints, another from a
354 sequence of floats
355 \begin{itemize}
356 \item both bundles have the same type: \cbundle
357 \end{itemize}
358 \item if \texttt{b} has type \cbundle, \texttt{b} can hold either
359 bundle
360 \end{itemize}
361\end{frame}
362
363\begin{frame}[containsverbatim]{Bundle API}
364\begin{verbatim}
365/* Creates a bundle from the memory region specified
366 * by ptr and size, copying the data into the new
367 * bundle */
368$bundle $bundle_pack(void *ptr, int size);
369
370/* Returns the size (number of bytes) of the bundle */
371int $bundle_size($bundle b);
372
373/* Copies the data out of the bundle into the
374 * region specified */
375void $bundle_unpack($bundle bundle, void *ptr);
376\end{verbatim}
377\end{frame}
378
379\begin{frame}[containsverbatim]{The \cscope{} type}
380 \begin{itemize}
381 \item an object of type $\cscope$ is a reference to a dynamic scope
382 \item it may be thought of as a ``dynamic scope ID''
383 \begin{itemize}
384 \item but it is not an integer and cannot be converted to an
385 integer
386 \end{itemize}
387 \item operations
388 \begin{itemize}
389 \item \code{==}, \code{!=}
390 \item \code{s<t} : \code{s} is a proper sub-scope of \code{t}
391 \item \code{<=}, \code{>}, \code{>=}
392 \item \code{s+t}
393 \begin{itemize}
394 \item the lowest common ancestor (LCA) of \code{s} and \code{t}
395 in dyscope tree
396 \item the smallest dyscope containing both \code{s} and \code{t}
397 \end{itemize}
398 \item \code{scopeof(lhs)}
399 \begin{itemize}
400 \item the scope containing object specified by the
401 left-hand-side expression
402 \end{itemize}
403 \end{itemize}
404 \item constants
405 \begin{itemize}
406 \item \chere: this dynamic scope
407 \item \cscoperoot: the root dynamic scope
408 \end{itemize}
409 \item functions
410 \begin{itemize}
411 \item \verb!$scope $scope_parent($scope s);!
412 \end{itemize}
413 \end{itemize}
414\end{frame}
415
416\begin{frame}[containsverbatim]{\cscopeof{} example: all assertions hold}
417 \begin{small}
418\begin{verbatim}
419{
420 $scope s1 = $here;
421 int x;
422 double a[10];
423
424 {
425 $scope s2 = $here;
426 int *p = &x;
427 double *q = &a[4];
428
429 assert($scopeof(x)==s1);
430 assert($scopeof(p)==s2);
431 assert($scopeof(*p)==s1);
432 assert($scopeof(a)==s1);
433 assert($scopeof(a[5])==s1);
434 assert($scopeof(q)==s2);
435 assert($scopeof(*q)==s1);
436 }
437}
438\end{verbatim}
439 \end{small}
440\end{frame}
441
442\begin{frame}[containsverbatim]{Statements}
443 The usual C statements are supported:
444 \begin{itemize}
445 \item \emph{no-op} (\ct{;})
446 \item expression statements (\ct{e;})
447 \item labeled statements, including \ct{case} and \ct{default} labels
448 (\ct{l: s})
449 \item \emph{for} (\ct{for (init; cond; inc) s}), \emph{while}
450 (\ct{while (cond) s}) and \emph{do} (\ct{do s while (cond)})
451 loops
452 \item compound statements (\lb \ct{s1;s2;} \ldots \rb)
453 \item \texttt{if} and \verb!if! \ldots \verb!else!
454 \item \verb!goto!
455 \item \verb!switch!
456 \item \verb!break!
457 \item \verb!continue!
458 \item \verb!return!
459 \end{itemize}
460\end{frame}
461
462\begin{frame}[containsverbatim]{Guarded commands: \cwhen}
463 A guarded command is encoded using a \cwhen{} statement:
464\begin{verbatim}
465 $when (expr) stmt;
466\end{verbatim}
467 \begin{itemize}
468 \item all statements have a guard, either implicit or explicit
469 \item for most statements, the guard is \emph{true}
470 \item the \cwhen{} statement allows one to attach an explicit guard
471 to a statement
472 \item when \texttt{expr} is \emph{true}, the statement is
473 \alert{enabled}, otherwise it is \alert{disabled}
474 \item a disabled statement is \alert{blocked}---it will not
475 be scheduled for execution
476 \item when it is enabled, it may execute by
477 moving control to the \texttt{stmt} and executing the first atomic
478 action in the \texttt{stmt}.
479 \end{itemize}
480\end{frame}
481
482\begin{frame}{Guards, cont.}
483 \begin{itemize}
484 \item if \texttt{stmt} itself has a non-trivial guard:
485 \begin{itemize}
486 \item the guard of the \cwhen{} statement is the conjunction of
487 \texttt{expr} and the guard of \texttt{stmt}
488 \end{itemize}
489 \item the evaluation of \texttt{expr} and the first atomic action of
490 \texttt{stmt} occur as a single atomic action
491 \item there is no guarantee that execution of \texttt{stmt}
492 will continue atomically if it contains more than one atomic
493 action
494 \begin{itemize}
495 \item i.e., other processes may be scheduled
496 \end{itemize}
497 \end{itemize}
498\end{frame}
499
500\begin{frame}[containsverbatim]{Guard examples}
501\begin{verbatim}
502 $when (s>0) s--;
503\end{verbatim}
504 \begin{itemize}
505 \item blocks until \texttt{s} is positive then decrements \texttt{s}
506 \item execution of \texttt{s--} is guaranteed to take place
507 in an environment in which \texttt{s} is positive
508 \end{itemize}
509
510\begin{verbatim}
511 $when (s>0) {s--; t++}
512\end{verbatim}
513 \begin{itemize}
514 \item execution of \texttt{s--} must happen when \texttt{s>0}
515 \item between \texttt{s--} and \texttt{t++}, other processes may
516 execute
517 \end{itemize}
518
519\begin{verbatim}
520 $when (s>0) $when (t>0) x=y*t;
521\end{verbatim}
522 \begin{itemize}
523 \item blocks until both \texttt{x} and \texttt{t} are positive then
524 executes the assignment
525 \item equivalent to:
526\begin{verbatim}
527 $when (s>0 && t>0) x=y*t;
528\end{verbatim}
529 \end{itemize}
530\end{frame}
531
532\begin{frame}[containsverbatim]{Nondeterministic selection statement: \cchoose}
533\begin{verbatim}
534 $choose {
535 stmt1;
536 stmt2;
537 ...
538 default: stmt
539 }
540\end{verbatim}
541
542 \begin{itemize}
543 \item the \texttt{default} clause is optional
544 \item the guards of the statements are evaluated and among those that are
545 \emph{true}, one is chosen nondeterministically and executed
546 \item if none are \emph{true} and the \texttt{default} clause is
547 present, it is chosen
548 \item the \texttt{default} clause will only be selected if all
549 guards are \emph{false}
550 \item if no \texttt{default} clause and
551 all guards are \emph{false}, the statement blocks
552 \item implicit
553 guard of \cchoose{} statement without \texttt{default} clause is
554 the disjunction of the guards of its sub-statements
555 \item implicit guard of \cchoose{} statement with a default
556 clause is \emph{true}.
557 \end{itemize}
558\end{frame}
559
560\begin{frame}[containsverbatim]{Using \cchoose{} to encode a
561 transition system}
562\begin{verbatim}
563 l1: $choose {
564 $when (x>0) {x--; goto l2;}
565 $when (x==0) {y=1; goto l3;}
566 default: {z=1; goto l4;}
567 }
568 l2: $choose {
569 ...
570 }
571 l3: $choose {
572 ...
573 }
574\end{verbatim}
575\end{frame}
576
577
578\begin{frame}[containsverbatim]{Nondeterministic choice of integer: \cchooseint}
579 The system function \cchooseint{} has the following signature:
580
581\begin{verbatim}
582 int $choose_int(int n);
583\end{verbatim}
584
585 This function takes as input a positive integer \texttt{n} and
586 nondeterministicaly returns an integer in the range
587 $[0,\texttt{n}-1]$.
588\end{frame}
589
590\begin{frame}{The process type: \cproc}
591 \begin{itemize}
592 \item a primitive object type and functions like any other primitive
593 C type (e.g., \texttt{int})
594 \item an object of this type refers to a
595 process
596 \item it can be thought of as a process ID
597 \begin{itemize}
598 \item but it is not an integer and cannot be cast to one
599 \item it is analogous to the $\cscope$ type for dynamic scopes
600 \end{itemize}
601 \item certain expressions take an argument of \cproc{} type and some return
602 something of \cproc{} type
603 \end{itemize}
604\end{frame}
605
606\begin{frame}{Spawning a new process: \cspawn}
607 \begin{itemize}
608 \item a \emph{spawn} expression is an expression with side-effects
609 \item spawns a new process and returns a reference to the new
610 process
611 \begin{itemize}
612 \item an object of type \cproc
613 \end{itemize}
614 \item syntax is the same as a procedure invocation with the keyword
615 \cspawn{} inserted in front:
616 \begin{itemize}
617 \item \code{\cspawn\ f(expr1, ..., exprn)}
618 \end{itemize}
619 \item typically the returned value is assigned to a variable, e.g.:
620 \begin{itemize}
621 \item \code{\cproc\ p = \cspawn f(i);}
622 \end{itemize}
623 \item if \texttt{f} returns a value, that value is ignored
624 \end{itemize}
625\end{frame}
626
627\begin{frame}{Waiting for another process to terminate: \cwait}
628
629 The system function $\cwait$ has signature
630
631 \begin{center}
632 \code{void\ \cwait(\cproc\ p);}
633 \end{center}
634
635 \begin{itemize}
636 \item when invoked, this function will not return until the process
637 referenced by \ct{p} has terminated.
638 \item note that $p$ can be any
639 expression of type \cproc{}, not just a variable.
640 \end{itemize}
641\end{frame}
642
643\begin{frame}{Terminating a process immediately: \cexit}
644 \begin{itemize}
645 \item this function takes no arguments
646 \item it causes the calling process to terminate immediately,
647 regardless of the state of its call stack
648 \item \code{void\ \cexit(void);}
649 \end{itemize}
650\end{frame}
651
652
653
654\begin{frame}<0>{Scope-parameterized pointers}
655 \begin{itemize}
656 \item a declaration of the form \code{\cscope\ s;} assigns the name
657 \code{s} to the containing scope
658 \begin{itemize}
659 \item what you can do with \code{s} is very limited
660 \item cannot be assigned, passed as parameter
661 \end{itemize}
662 \item \code{int *<s> p;}
663 \begin{itemize}
664 \item declares \code{p} to have type ``pointer-to-\code{int}-in-\code{s}''
665 \item \code{p} can only hold a pointer to an object in scope \code{s}
666 \end{itemize}
667 \item $s_1\leq s_2$ $\implies$
668 \textit{pointer-to-$T$-in-$s_1$} \alert{is a subtype of}
669 \textit{pointer-to-$T$-in-$s_2$}
670 \item the type \textit{pointer-to-$T$} (\code{T*}) is shorthand for
671 \textit{pointer-to-$T$-in-$s_0$} (\code{T*<\(s_0\)>}), where $s_0$
672 is the \alert{root scope}
673 \item \code{\&x} returns a pointer to the declaration scope of \code{x}
674 \begin{itemize}
675 \item scope of \code{\&a[i]} is the scope of \code{\&a}
676 \item scope of \code{\&r.f} is the scope of \code{\&r}
677 \end{itemize}
678 \end{itemize}
679\end{frame}
680
681\begin{frame}<0>[containsverbatim]{Pointer safety}
682 \begin{itemize}
683 \item for a CIVL-C program to be \alert{statically type-safe},
684 for all assignments, the type of the right-hand side must be a subtype
685 of that of the left-hand side
686 \item static type-safety can be checked statically
687 \end{itemize}
688
689 Example:
690
691 \begin{mycbox}{7cm}
692\begin{verbatim}
693 {
694 $scope s1;
695 double x;
696 {
697 $scope s2;
698 double a[N];
699 double *<s1> p = &x; // OK
700 double *<s2> q = &a[0]; // OK
701
702 p = &a[1]; // OK
703 q = &x; // static type error
704 }
705 }
706\end{verbatim}
707 \end{mycbox}
708\end{frame}
709
710\begin{frame}<0>[containsverbatim]{Scope-parameterized functions}
711
712 A function declaration or definition may be parameterized by any number
713 of \alert{formal scope parameters}. Example:
714
715 \begin{mycbox}{7cm}
716\begin{verbatim}
717 <s> int *<s> f(int *<s> p);
718\end{verbatim}
719 \end{mycbox}
720
721 declares $f$ to be a function which, for any scope $s$, takes a
722 \emph{pointer-to-\texttt{int}-in-$s$} and returns a
723 \emph{pointer-to-\texttt{int}-in-$s$}.
724
725\end{frame}
726
727\begin{frame}<0>{Further ideas}
728 \begin{itemize}
729 \item scope-parameterized \alert{typedefs} and \alert{structs}
730 \item \alert{heap} type (can have ``a heap in every scope'')
731 \begin{itemize}
732 \item \texttt{malloc} and \texttt{free} adjusted to take reference to heap
733 \end{itemize}
734 \item a \alert{bundle type}
735 \begin{itemize}
736 \item wrap up any contiguous region of memory into an object of bundle type
737 \item functions to \alert{pack} and \alert{unpack} bundles
738 \item useful for many abstractions, e.g., messages
739 \end{itemize}
740 \item set of functions and types supporting \alert{message-passing}
741 \item see Trac Wiki and \code{civlc.h}
742 \end{itemize}
743\end{frame}
744
745\begin{frame}[containsverbatim]{Message Passing example: \code{ring.cvl}}
746
747\begin{verbatim}
748/* Create nprocs processes. Have them exchange data
749 * in a cycle. Commandline example:
750 * civl verify -inputNPROCS=3 ring.cvl -simplify=false
751 */
752#include<civlc.h>
753#include "mp_root.cvh"
754
755void MPI_Process (int rank) {
756#include "mp_proc.cvh"
757
758 double x=rank, y;
759
760 send(&x, 1, (rank+1)%NPROCS, 0);
761 recv(&y, 1, (rank+NPROCS-1)%NPROCS, 0);
762 $assert y==(rank+NPROCS-1)%NPROCS;
763}
764\end{verbatim}
765\end{frame}
766
767\begin{frame}[containsverbatim]{File \code{mp{\U}root.cvh}}
768 \scriptsize
769\begin{verbatim}
770$input int NPROCS;
771$proc __procs[NPROCS];
772_Bool __start = 0;
773$comm MPI_COMM_WORLD;
774
775void MPI_Process (int rank);
776
777void init() {
778 for (int i=0; i<NPROCS; i++)
779 __procs[i] = $spawn MPI_Process(i);
780 MPI_COMM_WORLD = $comm_create(NPROCS, __procs);
781 __start=1;
782}
783
784void finalize() {
785 for (int i=0; i<NPROCS; i++)
786 $wait __procs[i];
787}
788
789void main() {
790 init();
791 finalize();
792}
793\end{verbatim}
794\end{frame}
795
796\begin{frame}[containsverbatim]{File \code{mp{\U}proc.cvh}}
797 \scriptsize
798\begin{verbatim}
799 void send(void *buf, int count, int dest, int tag) {
800 $message out = $message_pack(rank, dest, tag, buf, count*sizeof(double));
801 $comm_enqueue(&MPI_COMM_WORLD, out);
802 }
803
804 void recv(void *buf, int count, int source, int tag) {
805 $message in = $comm_dequeue(&MPI_COMM_WORLD, source, rank, tag);
806 $message_unpack(in, buf, count*sizeof(double));
807 }
808
809 $when (__start);
810\end{verbatim}
811\end{frame}
812
813\section{CIVL Developer Tutorial}
814
815\begin{frame}{VSL Projects: Uses Relation}
816
817 \includegraphics{vsl_projects}
818
819 \begin{itemize}
820 \item reusable components
821 \begin{itemize}
822 \item ABC: A Better C compiler? ANTLR-Based C compiler?
823 \item SARL: Symbolic Algebra \& Reasoning Library
824 \item GMC: Generic Model Checking utilities
825 \begin{itemize}
826 \item DFS, command line interface, trace saving/replay, error
827 logging, random simulation
828 \end{itemize}
829 \end{itemize}
830 \item model checking applications
831 \begin{itemize}
832 \item CIVL: Concurrency Intermediate Verification Language
833 \item TASS: Toolkit for Accurate Scientific Software (C+MPI)
834 \item CVT: Chapel Verification Tool
835 \end{itemize}
836 \end{itemize}
837
838\end{frame}
839
840\begin{frame}{Engineering}
841
842 \begin{itemize}
843 \item all of the VSL software is in Java
844 \item try to maintain coding standards
845 \item clear module boundaries with interfaces
846 \end{itemize}
847
848
849 \begin{center}
850 \begin{tabular}{|ll|}
851 \hline
852 Web page & \url{http://vsl.cis.udel.edu/civl}\\
853 Subversion & \url{svn://vsl.cis.udel.edu/civl}\\
854 Trac repository & \url{https://vsl.cis.udel.edu/trac/civl}\\
855 Automated build/test & \url{http://vsl.cis.udel.edu/civl/test}\\
856 \hline
857 \end{tabular}
858 \end{center}
859
860 \begin{itemize}
861 \item replace \texttt{civl} with \texttt{sarl}, \texttt{abc}, \texttt{gmc}, or
862 \texttt{tass}
863 \end{itemize}
864
865 \includegraphics[scale=.3]{civl-trac.pdf}
866
867\end{frame}
868
869\begin{frame}{Civl Test Directory}
870 \includegraphics[scale=.35]{civlTestDir}
871
872 \includegraphics[scale=.35]{civlTestTrunkDir}
873\end{frame}
874
875\begin{frame}{CIVL Test Directory: Latest (unstable) Release}
876 \includegraphics[scale=.35]{civlTestTrunkLatest}
877\end{frame}
878
879
880\begin{frame}{Automated Build \& Test Script}
881
882 \begin{center}
883 \includegraphics[scale=.3]{sarl-junit.pdf}
884 \end{center}
885
886 For each project \ldots
887 \begin{itemize}
888 \item script is run after each commit
889 \item one directory for each \alert{branch} and \alert{trunk}
890 \begin{itemize}
891 \item one subdirectory for each revision, up to some bounded history
892 \end{itemize}
893 \item compiles all code and displays results
894 \item runs JUnit test suite and displays results
895 \item runs Jacoco coverage anaysis and displays results
896 \item generates javadocs
897 \end{itemize}
898\end{frame}
899
900\begin{frame}{Coverage Analysis Results}
901 \includegraphics[scale=.4]{civlCoverage}
902\end{frame}
903
904\begin{frame}{Developer Eclipse Set-up}
905 \begin{enumerate}
906 \item Download vsl dependencies archive from
907 \url{http://vsl.cis.udel.edu/tools/vsl_depend}
908 \item Download and install Eclipse IDE for Java EE Developers
909 \begin{itemize}
910 \item version Kepler or later
911 \end{itemize}
912 \item Install Apache Ant if you don't have it
913 \item Install an Eclipse SVN plugin (such as Subversive)
914 \item Create class path variable \texttt{VSL}:
915 \begin{itemize}
916 \item Preferences$\ra$Java$\ra$Build Path$\ra$ClassPath Variables
917 \item select ``New'' and create a classpath variable \texttt{VSL}
918 \item specify its value to be \texttt{/opt/vsl}
919 \end{itemize}
920 \item Create string variable \texttt{vsl{\U}lib}:
921 \begin{itemize}
922 \item Preferences$\ra$Run/Debug$\ra$String Substitution$\ra$New
923 \item define an entry \texttt{vsl{\U}lib}
924 \item set its value to be \texttt{/opt/vsl/lib}
925 \end{itemize}
926 \end{enumerate}
927\end{frame}
928
929\begin{frame}{Check out and install ABC}
930 \begin{enumerate}
931 \item Check out ABC Eclipse project
932 \begin{itemize}
933 \item ``New Project\ldots from SVN''
934 \item SVN repository: \url{svn://vsl.cis.udel.edu/abc}
935 \item Navigate and select \texttt{trunk} from within archive
936 \item Check out project using all default options
937 \end{itemize}
938 \item Build using Ant
939 \begin{itemize}
940 \item right-click on \texttt{build.xml}
941 \item Choose ``Run as Ant build''
942 \item Clean project
943 \end{itemize}
944 \item test the build
945 \begin{itemize}
946 \item select Run$\ra$Run Configurations\ldots
947 \item ceate a new JUnit 4 configuration called ``ABC Tests''
948 \item select ``Run all tests in the selected project\ldots''
949 \item navigate and select the \texttt{test} folder in the ABC project
950 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
951 \item click ``Run'' to run the tests
952 \end{itemize}
953 \end{enumerate}
954\end{frame}
955
956\begin{frame}{Check out and install GMC}
957 \begin{enumerate}
958 \item Check out GMC Eclipse project
959 \begin{itemize}
960 \item ``New Project\ldots from SVN''
961 \item SVN repository: \url{svn://vsl.cis.udel.edu/gmc}
962 \item Navigate and select \texttt{trunk} from within archive
963 \item Check out project using all default options
964 \end{itemize}
965 \item test the build
966 \begin{itemize}
967 \item select Run$\ra$Run Configurations\ldots
968 \item ceate a new JUnit 4 configuration called ``GMC Tests''
969 \item select ``Run all tests in the selected project\ldots''
970 \item navigate and select the \texttt{test} folder in the GMC project
971 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
972 \item click ``Run'' to run the tests
973 \end{itemize}
974 \end{enumerate}
975\end{frame}
976
977\begin{frame}{Check out and install SARL}
978 \begin{enumerate}
979 \item Check out SARL Eclipse project
980 \begin{itemize}
981 \item ``New Project\ldots from SVN''
982 \item SVN repository: \url{svn://vsl.cis.udel.edu/sarl}
983 \item Navigate and select \texttt{trunk} from within archive
984 \item Check out project using all default options
985 \end{itemize}
986 \item test the build
987 \begin{itemize}
988 \item select Run$\ra$Run Configurations\ldots
989 \item ceate a new JUnit 4 configuration called ``SARL Tests''
990 \item select ``Run all tests in the selected project\ldots''
991 \item navigate and select the \texttt{test} folder in the SARL project
992 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
993 \item under Environment tab, create an entry
994 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
995 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
996 clicking Variables, choose \texttt{vsl{\U}lib} from the list
997 \item click ``Run'' to run the tests
998 \end{itemize}
999 \end{enumerate}
1000\end{frame}
1001
1002\begin{frame}{Check out and install CIVL}
1003 \begin{enumerate}
1004 \item Check out CIVL Eclipse project
1005 \begin{itemize}
1006 \item ``New Project\ldots from SVN''
1007 \item SVN repository: \url{svn://vsl.cis.udel.edu/civl}
1008 \item Navigate and select \texttt{trunk} from within archive
1009 \item Check out project using all default options
1010 \end{itemize}
1011 \item test the build
1012 \begin{itemize}
1013 \item select Run$\ra$Run Configurations\ldots
1014 \item ceate a new JUnit 4 configuration called ``CIVL Tests''
1015 \item select ``Run all tests in the selected project\ldots''
1016 \item navigate and select the \texttt{test} folder in the CIVL project
1017 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
1018 \item under Environment tab, create an entry
1019 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
1020 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
1021 clicking Variables, choose \texttt{vsl{\U}lib} from the list
1022 \item click ``Run'' to run the tests
1023 \end{itemize}
1024 \item \alert{optional:} configure to build and run with \texttt{ant}
1025 \begin{itemize}
1026 \item create file \texttt{build.properties} in root CIVL directory
1027 \item base on examples in \texttt{properties} directory
1028 \item from command line, type \texttt{ant test}
1029 \end{itemize}
1030 \end{enumerate}
1031\end{frame}
1032
1033\begin{frame}{CIVL modules}
1034 \begin{tabular}{@{}ll@{}}
1035 \includegraphics[scale=0.55]{civlModules}
1036 &
1037 \includegraphics[scale=.3]{civlEclipseModules}
1038 \end{tabular}
1039\end{frame}
1040
1041\end{document}
Note: See TracBrowser for help on using the repository browser.