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 2191 - (download) (annotate)
Sun Feb 24 06:12:43 2013 UTC (6 years, 5 months ago) by lamonts
File size: 1787 byte(s)
Major update to spatial data structure. Fully working now
//! 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
    wrld->inState = NEWVEC(@STRANDTY@ *, numStrands);
    wrld->outState = NEWVEC(@STRANDTY@ *, numStrands);
    wrld->status = NEWVEC(uint8_t, numStrands);
    if ((wrld->inState == 0) || (wrld->outState == 0) || (wrld->status == 0)) {
        biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
        return true;
    }

    @QUERY_POOL_ALLOCATION@

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

    return false;

} // AllocInitially

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