source: CIVL/doc/tutorial/tutorial.tex@ f65dbd0

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

Improving some comments, fixing old examples, deleted file
in tutorial that was wrongly committed.

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

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