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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/c-target/fragments/init.in
ViewVC logotype

Diff of /branches/vis12/src/compiler/c-target/fragments/init.in

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

revision 2707, Sat Sep 20 15:11:18 2014 UTC revision 2708, Sat Sep 20 18:46:49 2014 UTC
# Line 1  Line 1 
1  //! Create and allocate the program's world  // Allocate the program's world
2  @PREFIX@World_t *@PREFIX@Init ()  //
3    @PREFIX@World_t *@PREFIX@New ()
4  {  {
5      @PREFIX@World_t *wrld = NEW(@PREFIX@World_t);      @PREFIX@World_t *wrld = NEW(@PREFIX@World_t);
6      if (wrld == 0)      if (wrld == 0)
# Line 26  Line 27 
27    
28  #ifdef DIDEROT_TARGET_PARALLEL  #ifdef DIDEROT_TARGET_PARALLEL
29      wrld->sched         = NEW(Diderot_Sched_t);      wrld->sched         = NEW(Diderot_Sched_t);
30        if (wrld->sched == 0) {
     if ((wrld->sched == 0)  
     ||  Diderot_GetNumCPUs(&(wrld->sched->cpuInfo))  
     ||  (pthread_mutex_init (&(wrld->sched->lock), 0) != 0)  
     ||  (pthread_cond_init (&(wrld->sched->barrier), 0) != 0)  
     ||  (pthread_cond_init (&(wrld->sched->runWait), 0) != 0)) {  
31          biffMsgNix (wrld->errors);          biffMsgNix (wrld->errors);
32          FREE (wrld->globals);          FREE (wrld->globals);
         FREE (wrld->sched);  
33          FREE (wrld);          FREE (wrld);
34          return 0;          return 0;
35      }      }
36    #endif
37    
38        return wrld;
39    
40    }
41    
42    // Initialize the program's world
43    //
44    bool @PREFIX@Init (@PREFIX@World_t *wrld)
45    {
46    #ifdef DIDEROT_TARGET_PARALLEL
47        if (Diderot_GetNumCPUs(&(wrld->sched->cpuInfo))
48        || (pthread_mutex_init (&(wrld->sched->lock), 0) != 0)
49        || (pthread_cond_init (&(wrld->sched->barrier), 0) != 0)
50        || (pthread_cond_init (&(wrld->sched->runWait), 0) != 0)) {
51            biffMsgAdd (wrld->errors, "unable to initialize scheduler structures");
52            return true;
53        }
54      wrld->sched->numWorkers = wrld->sched->cpuInfo.numHWCores;      wrld->sched->numWorkers = wrld->sched->cpuInfo.numHWCores;
55      wrld->sched->numActive = 0;      wrld->sched->numActive = 0;
56  #else /* DIDEROT_TARGET_C */  #else /* DIDEROT_TARGET_C */
# Line 49  Line 62 
62      @PREFIX@InitDefined (wrld);      @PREFIX@InitDefined (wrld);
63  #endif  #endif
64    
65      return wrld;      return false;
66    
67  }  }

Legend:
Removed from v.2707  
changed lines
  Added in v.2708

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