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

SCM Repository

[diderot] Annotation of /branches/lamont/src/compiler/c-target/fragments/alloc.in
ViewVC logotype

Annotation of /branches/lamont/src/compiler/c-target/fragments/alloc.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2562 - (view) (download)

1 : jhr 1722 //! allocate the initial strands and initialize the rest of the world structure.
2 :     static bool AllocInitially (
3 : jhr 2298 @PREFIX@World_t *wrld, // world
4 : jhr 1722 bool isArray, // is the initialization an array or collection?
5 :     uint32_t nAxes, // depth of iteration nesting
6 : jhr 2298 uint32_t *base, // nAxes array of base indices
7 : jhr 1722 uint32_t *size) // nAxes array of iteration sizes
8 :     {
9 :     wrld->isArray = isArray;
10 :     wrld->nAxes = nAxes;
11 :     wrld->base = NEWVEC(uint32_t, nAxes);
12 :     wrld->size = NEWVEC(uint32_t, nAxes);
13 : lamonts 2526
14 :    
15 : jhr 1722 size_t numStrands = 1;
16 :     for (uint32_t i = 0; i < wrld->nAxes; i++) {
17 :     numStrands *= size[i];
18 :     wrld->base[i] = base[i];
19 :     wrld->size[i] = size[i];
20 :     }
21 :    
22 :     if (wrld->verboseFlg) {
23 :     fprintf (stderr, "AllocInitially: %d", size[0]);
24 :     for (uint32_t i = 1; i < nAxes; i++) fprintf(stderr, " x %d", size[i]);
25 :     fprintf (stderr, "\n");
26 :     }
27 :    
28 : lamonts 2526
29 :    
30 : jhr 1722 // allocate the strand state pointers
31 :     wrld->numStrands = numStrands;
32 : lamonts 2526
33 :     #ifdef DIDEROT_PARALLEL_REDUCTION
34 : lamonts 2559 wrld->globSched->numberOfStrands = &wrld->numStrands;
35 : lamonts 2526 #endif
36 :    
37 : jhr 1917 #ifdef DIDEROT_TARGET_PARALLEL
38 :     wrld->sched->numActive = numStrands;
39 : lamonts 2467 wrld->sched->numStable = 0;
40 : jhr 1917 #else /* DIDEROT_TARGET_C */
41 :     wrld->numActive = numStrands;
42 : lamonts 2467 wrld->numStable=0;
43 : jhr 1917 #endif
44 : lamonts 2210 // initialize strand pool information
45 :     wrld->poolInfo.handle = numStrands;
46 :     wrld->poolInfo.size = numStrands + STRAND_POOL_INC_SIZE;
47 :     wrld->poolInfo.nNewStrand = 0;
48 : jhr 2298 wrld->status = NEWVEC(uint8_t, wrld->poolInfo.size);
49 :     #ifdef DIDEROT_DUAL_STATE
50 : lamonts 2210 wrld->inState = NEWVEC(@STRANDTY@ *, wrld->poolInfo.size);
51 :     wrld->outState = NEWVEC(@STRANDTY@ *, wrld->poolInfo.size);
52 : jhr 1722 if ((wrld->inState == 0) || (wrld->outState == 0) || (wrld->status == 0)) {
53 : jhr 1862 biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
54 : jhr 1722 return true;
55 :     }
56 : jhr 2298 #else
57 :     wrld->state = NEWVEC(@STRANDTY@, wrld->poolInfo.size);
58 :     if ((wrld->state == 0) || (wrld->status == 0)) {
59 :     biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
60 :     return true;
61 :     }
62 :     #endif
63 : jhr 1722
64 :     // initialize strand state pointers etc.
65 : lamonts 2246 for (size_t i = 0; i < wrld->poolInfo.size; i++) {
66 : jhr 2298 #ifdef DIDEROT_DUAL_STATE
67 : jhr 1722 wrld->inState[i] = NEW(@STRANDTY@);
68 :     wrld->outState[i] = NEW(@STRANDTY@);
69 : jhr 2298 #endif
70 : jhr 1722 wrld->status[i] = DIDEROT_ACTIVE;
71 :     }
72 :    
73 : lamonts 2416 // initialize KDtree for the spatial communication (if necessary)
74 :     @CALL_ALLOC_TREE_FN@
75 :    
76 : jhr 1722 return false;
77 :    
78 :     } // AllocInitially

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