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/c-hdr-spatial-extra.in
ViewVC logotype

View of /branches/lamont/src/compiler/c-target/fragments/c-hdr-spatial-extra.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2562 - (download) (annotate)
Mon Mar 10 04:10:03 2014 UTC (5 years, 4 months ago) by lamonts
File size: 5486 byte(s)
Fixed bug with queryPool not allocating correctly and fixed deadlock of spatail data structure
#define DIDEROT_SPATIAL_COM
STATIC_INLINE Diderot_DynSeq_t * spherical_query(@STRANDTY@ ** strands,
                                 @STRANDTY@ * qStrand,
                                 KDTree_t * tree,
                                 QueryPool_t * queryPool, 
                                 Diderot_real_t radius); 
#ifdef DIDEROT_TARGET_PARALLEL
typedef struct spatialworkerArgs SpatialWorkerArgs_t;
typedef struct spatialscheduler SpatialScheduler_t;

typedef enum {
    MERGESORT_WORKER,                   // Worker is performing a merge sort task 
    MERGE_WORKER,                       // Worker is performing a merge task 
    TREE_WORKER,                        // Worker is performing a tree node constructin task 
}ParSpatialWorkerType;

struct spatialscheduler{
	pthread_mutex_t lock;               // lock for the spatial scheduler 
 	bool buildIsDone;                   // represents if the tree is fully built. 
 	SpatialWorkerArgs_t *workerData;    // the argument data for all the spatial workers 
    uint32_t seqThreshold;              // the threshold used to determin if a task should be done sequentially 
    uint32_t numRunning;                // the number of running workers. 
    uint32_t numWorkers;                // the number of actual workers. 
 	uint32_t nextWorker;                // the next worker to schedule. 
    uint32_t leaderId;                  // the leader of the workers 
};
struct spatialworkerArgs{ 
	@PREFIX@World_t *wrld;              // a pointer to the world 
	void * data;                        // the arguments for task to the perform 
	bool isIdle;                        // represents if the worker is idle 
	bool * isDone;                        // represents if the worker completed its task
    uint32_t id;                        // the identifier for the worker 
	ParSpatialWorkerType workerType;    // the type of task the worker is performing 
	pthread_cond_t  runWait;            // a condition to make a worker wait before being assigned a task
	pthread_cond_t  done;               // a condition used to signal another work that the work completed its task
	pthread_mutex_t lock;               // a lock for the worker 
    	SpatialScheduler_t * sched;         // a pointer to the scheduler 
}; 

typedef struct{
    int low;                            // the start parameter for the sort 
    int high;                           // the end parameter for the sort 
    uint32_t * tmpIndices;              // a duplicate indice array for axes (malloced as a single array) 
    uint32_t * indices;                 // the indice array for all the axes (malloced as a single array) 
    int depth;                          // the depth of the sorting recursion. 
    uint32_t dim;                       // the dim for the sort. 
}MergetSortNode_t;

typedef struct {
    int lowL;                           // the lower bound start parameter 
    int highL;                          // the lower bound end parameter 
    int lowR;                           // the upper bound start parameter
    int highR;                          // the upper bound end parameter 
    int low;                            // the start parameter 
    int depth;                          // the depth of the sorting recursion. 
    uint32_t * tmpIndices;              // a duplicate indice array for axes (malloced as a single array) 
    uint32_t * indices;                 // the indice array for all the axes (malloced as a single array) 
    uint32_t dim;                       // the dim for the sort. 
}MergeNode_t;

typedef struct {
    uint32_t len;                      // the len of the array 
    uint32_t axis;                     // the axis of the node 
    uint32_t start;                    // the starting parameter 
    KDNode_t * parent;                 // a pointer to the parameter for this node. 
}TreeNode_t;

/* sequential version of the merge sort for the spatial indices */  
void Diderot_Spatial_SeqMergeSort(@PREFIX@World_t *wrld, uint32_t * indices, uint32_t * tmpIndices, int low, int high, uint32_t dim); 

/* sequential version of the merge operation for the spatial indices */ 
/* Note: Sub-arrays are adjacent to each other in the 
   the sequential version but not necessarily for the parallel version;
   therefore, sub-arrays boundaries must be specified
   explicitly.*/ 
void Diderot_Spatial_SeqMerge(@PREFIX@World_t *wrld, uint32_t * indices, uint32_t * tmpIndices, int lowL, int highL, int lowR, int highR, int low, uint32_t dim); 

/* Swaps the values at two addresses */ 
void Diderot_KDTree_SwapValues(int * a, int *b);

/* Finds the median strand in an array of strands based on the given axis*/  
@STRANDTY@ * find_median(@PREFIX@World_t *wrld, SpatialScheduler_t * sched, int start, int end, int idx, int * mid); 
/* A recursive tree building function */ 
KDNode_t * Diderot_KDTree_BuildHelper(@PREFIX@World_t *wrld, SpatialScheduler_t * sched,int start, int len, int axis); 
/* parallel version of the merge operation for the spatial indices */ 
void Diderot_Spatial_ParMerge(@PREFIX@World_t *wrld,SpatialScheduler_t * sched,uint32_t * indices, uint32_t * tmpIndices, int lowL, int highL, int lowR, int highR, int low, int depth, int dim); 
/* parallel version of the merge sort for the spatial indices */  
void Diderot_Spatial_ParMergeSort(@PREFIX@World_t *wrld,SpatialScheduler_t * sched,uint32_t * indices, uint32_t * tmpIndices, int low, int high, int depth, uint32_t  dim); 
#endif 

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