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

SCM Repository

[diderot] View of /branches/lamont/src/lib/common/kdtree.c
ViewVC logotype

View of /branches/lamont/src/lib/common/kdtree.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2416 - (download) (as text) (annotate)
Mon Aug 19 12:57:45 2013 UTC (6 years ago) by lamonts
File size: 1230 byte(s)
Adding KDTree code for c-tagert and parallel c-target
/*! \file dyn-seq.c
 *
 * \author Lamont Samuels
 *
 * An implementation of the KDtree. 
 */

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

#include "Diderot/diderot.h"

void Diderot_KDTree_Alloc(KDTree_t ** tree,  uint32_t * numOfStrands, uint32_t dim)
{
    KDTree_t * newKDTree = CheckedAlloc (sizeof(KDTree_t));

    newKDTree->dim = dim; 
    newKDTree->numOfStrands = numOfStrands; 
    newKDTree->root = 0; 

    newKDTree->treePool.poolSize = *(numOfStrands) + POOL_INCR_SIZE; 
    newKDTree->treePool.handle = 0; 
    newKDTree->treePool.pool = CheckedAlloc(sizeof(KDNode_t)*( *(numOfStrands) + POOL_INCR_SIZE)); 
    
    *tree = newKDTree; 
}
void Diderot_KDTree_PoolClear( KDTree_t * tree)
{ 
   tree->treePool.handle = 0; 
}
KDNode_t * Diderot_KDTree_GrabNode( KDTree_t * tree) 
{
    KDPool_t * poolInfo = &tree->treePool;

    if (poolInfo->handle == poolInfo->poolSize)  {
		uint32_t newSize = poolInfo->poolSize + POOL_INCR_SIZE;
		poolInfo->pool = (KDNode_t *)CheckedReAlloc(poolInfo->pool, newSize * sizeof(KDNode_t)); 
		poolInfo->poolSize = newSize; 
	} 
    uint32_t newIdx = poolInfo->handle++;  
    return &poolInfo->pool[newIdx]; 
}


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