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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2416 - (download) (annotate)
Mon Aug 19 12:57:45 2013 UTC (5 years, 10 months ago) by lamonts
File size: 2398 byte(s)
Adding KDTree code for c-tagert and parallel c-target
//! allocate the initial strands and initialize the rest of the world structure.
static bool AllocInitially (
    @PREFIX@World_t *wrld,      // world
    bool isArray,               // is the initialization an array or collection?
    uint32_t nAxes,             // depth of iteration nesting
    uint32_t *base,             // nAxes array of base indices
    uint32_t *size)             // nAxes array of iteration sizes
{
    wrld->isArray = isArray;
    wrld->nAxes = nAxes;
    wrld->base = NEWVEC(uint32_t, nAxes);
    wrld->size = NEWVEC(uint32_t, nAxes);
    size_t numStrands = 1;
    for (uint32_t i = 0;  i < wrld->nAxes;  i++) {
        numStrands *= size[i];
        wrld->base[i] = base[i];
        wrld->size[i] = size[i];
    }

    if (wrld->verboseFlg) {
        fprintf (stderr, "AllocInitially: %d", size[0]);
        for (uint32_t i = 1;  i < nAxes;  i++) fprintf(stderr, " x %d", size[i]);
        fprintf (stderr, "\n");
    }

  // allocate the strand state pointers
    wrld->numStrands = numStrands;
#ifdef DIDEROT_TARGET_PARALLEL
    wrld->sched->numActive = numStrands;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = numStrands;
#endif
    // initialize strand pool information 
    wrld->poolInfo.handle = numStrands; 
    wrld->poolInfo.size = numStrands + STRAND_POOL_INC_SIZE; 
    wrld->poolInfo.nNewStrand = 0; 

    wrld->status = NEWVEC(uint8_t,  wrld->poolInfo.size);
#ifdef DIDEROT_DUAL_STATE
    wrld->inState = NEWVEC(@STRANDTY@ *, wrld->poolInfo.size);
    wrld->outState = NEWVEC(@STRANDTY@ *,  wrld->poolInfo.size);
    if ((wrld->inState == 0) || (wrld->outState == 0) || (wrld->status == 0)) {
        biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
        return true;
    }
#else
    wrld->state = NEWVEC(@STRANDTY@, wrld->poolInfo.size);
    if ((wrld->state == 0) || (wrld->status == 0)) {
        biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
        return true;
    }
#endif

    @QUERY_POOL_ALLOCATION@

  // initialize strand state pointers etc.
    for (size_t i = 0;  i < wrld->poolInfo.size;  i++) {
#ifdef DIDEROT_DUAL_STATE
        wrld->inState[i] = NEW(@STRANDTY@);
        wrld->outState[i] = NEW(@STRANDTY@);
#endif
        wrld->status[i] = DIDEROT_ACTIVE;
    }

	// initialize KDtree for the spatial communication (if necessary)
	@CALL_ALLOC_TREE_FN@

    return false;

} // AllocInitially

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