direct.c
/* Check the cache for the given RHS. If it exists, return the pre-cached copy.
 * Otherwise, cache the provided copy and take the DFT before returning a pointer
 * to the cache bin. */
Check the cache for the given RHS. If it exists, return the pre-cached copy.
Otherwise, cache the provided copy and take the DFT before returning a pointer
to the cache bin.
Check the cache for the given RHS . If it exists return the pre - cached copy . Otherwise cache the provided copy and take the DFT before returning a pointer to the cache bin .
cplx *cacheboxrhs (int bsl, int boxkey) {
	int l, i;
	boxdesc key, *lbox;
	cplx *bptr, *rhs;
	GRID (key.index, bsl, fmaconf.nx, fmaconf.ny);
	lbox = bsearch (&key, boxlist, nebox, sizeof(boxdesc), boxcomp);
	if (!lbox) return NULL;
	bptr = lbox->rhs;
	omp_set_lock (&(lbox->lock));
	if (!(lbox->fill)) {
		memset (bptr, 0, nfftprod * sizeof(cplx));
		rhs = (cplx *)ScaleME_getInputVec (boxkey);
		for (i = 0; i < fmaconf.bspboxvol; ++i) {
			GRID(key.index, i, fmaconf.bspbox, fmaconf.bspbox);
			l = IDX(nfft,key.index[0],key.index[1],key.index[2]);
			bptr[l] = rhs[i];
		}
		FFTW_EXECUTE_DFT (fplan, bptr, bptr);
		lbox->fill = 1;
	}
	omp_unset_lock (&(lbox->lock));
	return bptr;
}
cplx * cacheboxrhs ( int bsl , int boxkey ) { int l , i ; boxdesc key , * lbox ; cplx * bptr , * rhs ; GRID ( key . index , bsl , fmaconf . nx , fmaconf . ny ) ; lbox = bsearch ( & key , boxlist , nebox , sizeof ( boxdesc ) , boxcomp ) ; if ( ! lbox ) return NULL ; bptr = lbox -> rhs ; omp_set_lock ( & ( lbox -> lock ) ) ; if ( ! ( lbox -> fill ) ) { memset ( bptr , 0 , nfftprod * sizeof ( cplx ) ) ; rhs = ( cplx * ) ScaleME_getInputVec ( boxkey ) ; for ( i = 0 ; i < fmaconf . bspboxvol ; ++ i ) { GRID ( key . index , i , fmaconf . bspbox , fmaconf . bspbox ) ; l = IDX ( nfft , key . index [ 0 ] , key . index [ 1 ] , key . index [ 2 ] ) ; bptr [ l ] = rhs [ i ] ; } FFTW_EXECUTE_DFT ( fplan , bptr , bptr ) ; lbox -> fill = 1 ; } omp_unset_lock ( & ( lbox -> lock ) ) ; return bptr ; }
Check the cache for the given RHS.
Check the cache for the given RHS .
/* Get the index for the first basis in the box. */ /* Search for the box index. */ /* The search failed for some reason. */ /* Point to the RHS storage. */ /* The cache check and fill operation must be thread safe. */ /* Cache miss. Fill the box. */ /* Clear the cache storage. */ /* Grab the local input vector for caching. */ /* Populate the local grid. */ /* Find the position in the local box. */ /* The index into the RHS array. */ /* Fill the expanded FFT grid. */ /* Transform the cached RHS. */ /* Mark the cache spot as full. */ /* Free the lock to allow other threads to access the cache block. */ /* Return the RHS. */