15 |
|
|
16 |
// NOTE: we probably should put this in a file that supports runtime printing |
// NOTE: we probably should put this in a file that supports runtime printing |
17 |
static bool VerboseFlg = false; |
static bool VerboseFlg = false; |
18 |
|
static bool TimingFlg = false; |
19 |
|
|
20 |
struct struct_world { |
struct struct_world { |
21 |
bool isArray; // is the initialization an array or collection? |
bool isArray; // is the initialization an array or collection? |
35 |
Diderot_Options_t *opts = Diderot_OptNew (); |
Diderot_Options_t *opts = Diderot_OptNew (); |
36 |
|
|
37 |
Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &VerboseFlg); |
Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &VerboseFlg); |
38 |
|
Diderot_OptAddFlag (opts, "timing", "enable execution timing", &TimingFlg); |
39 |
Diderot_RegisterGlobalOpts (opts); |
Diderot_RegisterGlobalOpts (opts); |
40 |
Diderot_OptProcess (opts, argc, argv); |
Diderot_OptProcess (opts, argc, argv); |
41 |
Diderot_OptFree (opts); |
Diderot_OptFree (opts); |
42 |
|
|
43 |
// run the generated global initialization code |
// run the generated global initialization code |
44 |
if (VerboseFlg) printf("initializing globals ...\n"); |
if (VerboseFlg) fprintf (stderr, "initializing globals ...\n"); |
45 |
Diderot_InitGlobals (); |
Diderot_InitGlobals (); |
46 |
|
|
47 |
// FIXME: we need to figure out how initialization should be handled. |
// FIXME: we need to figure out how initialization should be handled. |
48 |
if (VerboseFlg) printf("initializing strands ...\n"); |
if (VerboseFlg) fprintf (stderr, "initializing strands ...\n"); |
49 |
Diderot_World_t *wrld = Diderot_Initially (); |
Diderot_World_t *wrld = Diderot_Initially (); |
50 |
for (int i = 0; i < wrld->numStrands; i++) { |
for (int i = 0; i < wrld->numStrands; i++) { |
51 |
// hack to make the invariant part of the state the same in both copies |
// hack to make the invariant part of the state the same in both copies |
53 |
} |
} |
54 |
|
|
55 |
// iterate until all strands are stable |
// iterate until all strands are stable |
56 |
if (VerboseFlg) printf("run with %d strands ...\n", wrld->numStrands); |
if (VerboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands); |
57 |
|
double t0 = GetTime(); |
58 |
int nSteps = 0, nUpdates = 0; |
int nSteps = 0, nUpdates = 0; |
59 |
int nActive = wrld->numStrands; |
int nActive = wrld->numStrands; |
60 |
while (nActive > 0) { |
while (nActive > 0) { |
95 |
wrld->inState = wrld->outState; |
wrld->inState = wrld->outState; |
96 |
wrld->outState = tmp; |
wrld->outState = tmp; |
97 |
} |
} |
98 |
|
double totalTime = GetTime() - t0; |
99 |
|
|
100 |
|
if (VerboseFlg) |
101 |
|
fprintf (stderr, "done: %d updates, %d steps, in %f seconds\n", nUpdates, nSteps, totalTime); |
102 |
|
else if (TimingFlg) |
103 |
|
printf ("usr=%f\n", totalTime); |
104 |
|
|
|
if (VerboseFlg) printf("done: %d updates, %d steps\n", nUpdates, nSteps); |
|
105 |
// here we have the final state of all of the strands in the "in" buffer |
// here we have the final state of all of the strands in the "in" buffer |
106 |
FILE *outS = fopen("mip.txt", "w"); |
FILE *outS = fopen("mip.txt", "w"); |
107 |
if (outS == NULL) { |
if (outS == NULL) { |
154 |
} |
} |
155 |
|
|
156 |
if (VerboseFlg) { |
if (VerboseFlg) { |
157 |
printf("AllocInitially: %d", size[0]); |
fprintf(stderr, "AllocInitially: %d", size[0]); |
158 |
for (int i = 1; i < nDims; i++) printf(" x %d", size[i]); |
for (int i = 1; i < nDims; i++) fprintf(stderr, " x %d", size[i]); |
159 |
printf("\n"); |
fprintf(stderr, "\n"); |
160 |
} |
} |
161 |
|
|
162 |
// allocate the strand state pointers |
// allocate the strand state pointers |