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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/c-target/fragments/par-hdr.in
ViewVC logotype

View of /branches/vis12/src/compiler/c-target/fragments/par-hdr.in

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1826 - (download) (annotate)
Thu Apr 12 14:04:38 2012 UTC (9 years, 3 months ago) by jhr
File size: 1493 byte(s)
  Working on support for parallel target
/*! \file @CFILE@
 * Generated from @SRCFILE@.

 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

#include "@HDRFILE@"
#include "Diderot/diderot.h"
#include <pthread.h>

static char *ProgramName = "@SRCFILE@";

typedef struct @PREFIX@struct_@STRAND@ Strand_@STRAND@_t;

// The number of strands a worker will take for processing at one time
#define BLOCK_SIZE 4096

// cache-line alignment (Xeon has 64-byte lines)
#define CACHE_ALIGN     __attribute__((aligned(64)))

// argument struct for worker threads
typedef struct {
    uint32_t		id;		// worker's index into worker array
    uint32_t		maxNSteps	// maximum number of steps to take; 0 == infinity
    @PREFIX@World_t     *wrld;		// pointer to world structure
} WorkerArg_t CACHE_ALIGN;

// Scheduler state
typedef struct {
    uint32_t		numWorkers;	// number of worker threads to use
    uint32_t            nextStrand CACHE_ALIGN; // index of next strand to update
    uint32_t            numActive CACHE_ALIGN;  // # active strands
    uint32_t            numAvail CACHE_ALIGN;   // # unevaluated strands
    uint32_t            numIdle CACHE_ALIGN;    // # idle workers
    pthread_mutex_t     lock;           // big lock to protect wrld from multiple accesses
    pthread_cond_t      barrier;        // workers wait on this when they have no work
    pthread_cond_t      runWait;	// used to signal @PREFIX@Run that the workers have finished
} Diderot_Sched_t;

ViewVC Help
Powered by ViewVC 1.0.0