Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/lib/parallel-target/main.c
ViewVC logotype

Diff of /branches/pure-cfg/src/lib/parallel-target/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1275, Mon Jun 6 11:31:47 2011 UTC revision 1276, Mon Jun 6 12:07:05 2011 UTC
# Line 58  Line 58 
58    
59  // 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
60  static bool     VerboseFlg = false;  static bool     VerboseFlg = false;
61    static bool     TimingFlg = false;
62    
63  /* Function which processes active strands. */  /* Function which processes active strands. */
64  static void *Worker (void *arg)  static void *Worker (void *arg)
# Line 187  Line 188 
188      Diderot_Options_t *opts = Diderot_OptNew ();      Diderot_Options_t *opts = Diderot_OptNew ();
189    
190      Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &VerboseFlg);      Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &VerboseFlg);
191        Diderot_OptAddFlag (opts, "timing", "enable execution timing", &TimingFlg);
192      Diderot_OptAddInt (opts, "np", "specify number of threads", &np, true);      Diderot_OptAddInt (opts, "np", "specify number of threads", &np, true);
193      Diderot_RegisterGlobalOpts (opts);      Diderot_RegisterGlobalOpts (opts);
194      Diderot_OptProcess (opts, argc, argv);      Diderot_OptProcess (opts, argc, argv);
195      Diderot_OptFree (opts);      Diderot_OptFree (opts);
196    
197      if (VerboseFlg) fprintf (stderr, "initializing globals ...\n");      if (VerboseFlg) fprintf (stderr, "initializing globals ...\n");
198      Diderot_InitGlobals (argc, argv);      Diderot_InitGlobals ();
199    
200      if (VerboseFlg) fprintf (stderr, "initializing strands ...\n");      if (VerboseFlg) fprintf (stderr, "initializing strands ...\n");
201      Diderot_World_t *wrld = Diderot_Initially ();      Diderot_World_t *wrld = Diderot_Initially ();
# Line 206  Line 208 
208      int nWorkers = np;      int nWorkers = np;
209      WorkerArg_t *args = (WorkerArg_t *) malloc (nWorkers * sizeof(WorkerArg_t));      WorkerArg_t *args = (WorkerArg_t *) malloc (nWorkers * sizeof(WorkerArg_t));
210      if (VerboseFlg) printf ("initializing %d workers ...\n", nWorkers);      if (VerboseFlg) printf ("initializing %d workers ...\n", nWorkers);
211        double t0 = GetTime();
212      wrld->numWorkers = nWorkers;      wrld->numWorkers = nWorkers;
213      wrld->numIdle = 0;      wrld->numIdle = 0;
214      for (int i = 0; i < nWorkers; i++) {      for (int i = 0; i < nWorkers; i++) {
# Line 224  Line 227 
227          pthread_cond_wait (&wrld->mainWait, &wrld->lock);          pthread_cond_wait (&wrld->mainWait, &wrld->lock);
228      pthread_mutex_unlock (&wrld->lock);      pthread_mutex_unlock (&wrld->lock);
229    
230  if (VerboseFlg) fprintf (stderr, "done: %d steps\n", wrld->nSteps);      double totalTime = GetTime() - t0;
231    
232        if (VerboseFlg)
233            fprintf (stderr, "done: %d steps, in %f seconds\n", wrld->nSteps, totalTime);
234        else if (TimingFlg)
235            printf ("np=%d usr=%f\n", nWorkers, totalTime);
236    
237    // 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
238      FILE *outS = fopen("mip.txt", "w");      FILE *outS = fopen("mip.txt", "w");
239      if (outS == NULL) {      if (outS == NULL) {
# Line 277  Line 286 
286      }      }
287    
288  if (VerboseFlg) {  if (VerboseFlg) {
289      printf("AllocInitially: %d", size[0]);          fprintf(stderr, "AllocInitially: %d", size[0]);
290      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]);
291      printf("\n");          fprintf(stderr, "\n");
292  }  }
293    
294    // allocate the strand state pointers    // allocate the strand state pointers

Legend:
Removed from v.1275  
changed lines
  Added in v.1276

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0