source: CIVL/mods/dev.civl.com/doc/tutorial/tutorial.tex@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

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

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