1.23
2.0
main
test-branch
|
Last change
on this file since 844ebd8 was 844ebd8, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago |
|
Lots of outstanding changes. New examples, improved side effect remover, model builder additions and fixes, support for assert and assume statements. Support for storing code contracts in the model.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@32 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
568 bytes
|
| Rev | Line | |
|---|
| [844ebd8] | 1 | \input double a[3];
|
|---|
| 2 |
|
|---|
| 3 | double adderSeq(int n) {
|
|---|
| 4 | double s = 0.0;
|
|---|
| 5 |
|
|---|
| 6 | for (int i = 0; i < n; i++) {
|
|---|
| 7 | s += a[i];
|
|---|
| 8 | }
|
|---|
| 9 | return s;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | double adderPar(int m) {
|
|---|
| 13 | double s = 0.0;
|
|---|
| 14 | int mutex = 0;
|
|---|
| 15 | \proc workers[m];
|
|---|
| 16 |
|
|---|
| 17 | void worker(int i) {
|
|---|
| 18 | \when (mutex == 0) mutex = 1;
|
|---|
| 19 | s += a[i];
|
|---|
| 20 | mutex = 0;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | for (int i = 0; i < m; i++) {
|
|---|
| 24 | workers[i] = \spawn worker(i);
|
|---|
| 25 | }
|
|---|
| 26 | for (int j = 0; j < m; j++) {
|
|---|
| 27 | \wait workers[j];
|
|---|
| 28 | }
|
|---|
| 29 | return s;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | void main() {
|
|---|
| 33 | double seq;
|
|---|
| 34 | double par;
|
|---|
| 35 |
|
|---|
| 36 | seq = adderSeq(3);
|
|---|
| 37 | par = adderPar(3);
|
|---|
| 38 | \assert seq == par;
|
|---|
| 39 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.