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 1828 - (download) (annotate)
Thu Apr 12 22:46:32 2012 UTC (8 years, 9 months ago) by jhr
File size: 1550 byte(s)
  Adding support for parallel target in library mode
/*! \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
    uint32_t		numSteps CACHE_ALIGN;	// # of steps taken
    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