direct.c
/* Initialize the direct-interaction cache structure. */
Initialize the direct-interaction cache structure.
Initialize the direct - interaction cache structure .
int mkdircache () {
	cplx *rhsptr;
	int nbs, *bslist, i, *idx, *boxidx, rank;
	MPI_Comm_rank (MPI_COMM_WORLD, &rank);
	ScaleME_getLocallyReqBasis (&nbs, &bslist);
	boxidx = malloc (3 * nbs * sizeof(int));
	for (i = 0, idx = boxidx; i < nbs; ++i, idx += 3)
		GRID (idx, bslist[i], fmaconf.nx, fmaconf.ny);
	free (bslist);
	qsort (boxidx, nbs, 3 * sizeof(int), idxcomp);
	for (nebox = i = 1, idx = boxidx + 3; i < nbs; ++i, idx += 3) {
		if (!idxcomp (idx, idx - 3)) continue;
		++nebox;
	}
	boxlist = calloc (nebox, sizeof(boxdesc));
	rhsptr = rhsbuf = FFTW_MALLOC (nebox * nfftprod * sizeof(cplx));
	fprintf (stderr, "Rank %d: Expanded FFT buffer size size: %ld bytes\n",
			rank, nebox * nfftprod * sizeof(cplx));
	memcpy (boxlist[0].index, boxidx, 3 * sizeof(int));
	omp_init_lock (&(boxlist[0].lock));
	boxlist[0].rhs = rhsptr;
	rhsptr += nfftprod;
	for (nebox = i = 1, idx = boxidx + 3; i < nbs; ++i, idx += 3) {
		if (!idxcomp (idx, idx - 3)) continue;
		memcpy (boxlist[nebox].index, idx, 3 * sizeof(int));
		omp_init_lock (&(boxlist[nebox].lock));
		boxlist[nebox].rhs = rhsptr;
		rhsptr += nfftprod;
		++nebox;
	}
	qsort (boxlist, nebox, sizeof(boxdesc), boxcomp);
	free (boxidx);
	return nebox;
}
int mkdircache ( ) { cplx * rhsptr ; int nbs , * bslist , i , * idx , * boxidx , rank ; MPI_Comm_rank ( MPI_COMM_WORLD , & rank ) ; ScaleME_getLocallyReqBasis ( & nbs , & bslist ) ; boxidx = malloc ( 3 * nbs * sizeof ( int ) ) ; for ( i = 0 , idx = boxidx ; i < nbs ; ++ i , idx += 3 ) GRID ( idx , bslist [ i ] , fmaconf . nx , fmaconf . ny ) ; free ( bslist ) ; qsort ( boxidx , nbs , 3 * sizeof ( int ) , idxcomp ) ; for ( nebox = i = 1 , idx = boxidx + 3 ; i < nbs ; ++ i , idx += 3 ) { if ( ! idxcomp ( idx , idx - 3 ) ) continue ; ++ nebox ; } boxlist = calloc ( nebox , sizeof ( boxdesc ) ) ; rhsptr = rhsbuf = FFTW_MALLOC ( nebox * nfftprod * sizeof ( cplx ) ) ; fprintf ( stderr , " \n " , rank , nebox * nfftprod * sizeof ( cplx ) ) ; memcpy ( boxlist [ 0 ] . index , boxidx , 3 * sizeof ( int ) ) ; omp_init_lock ( & ( boxlist [ 0 ] . lock ) ) ; boxlist [ 0 ] . rhs = rhsptr ; rhsptr += nfftprod ; for ( nebox = i = 1 , idx = boxidx + 3 ; i < nbs ; ++ i , idx += 3 ) { if ( ! idxcomp ( idx , idx - 3 ) ) continue ; memcpy ( boxlist [ nebox ] . index , idx , 3 * sizeof ( int ) ) ; omp_init_lock ( & ( boxlist [ nebox ] . lock ) ) ; boxlist [ nebox ] . rhs = rhsptr ; rhsptr += nfftprod ; ++ nebox ; } qsort ( boxlist , nebox , sizeof ( boxdesc ) , boxcomp ) ; free ( boxidx ) ; return nebox ; }
Initialize the direct-interaction cache structure.
Initialize the direct - interaction cache structure .
/* Get the complete list of locally required basis functions. */ /* Allocate the box index array. */ /* Build the array of box indices. */ /* The basis list is no longer necessary. */ /* Sort the basis list according to parent boxes. */ /* Count the number of non-empty boxes. */ /* Skip the current box if it was already counted. */ /* Allocate the list of boxes. */ /* Allocate the backend array. */ /* Set up the first box structure. */ /* Now loop through all bases and set up the box cache pointers. */ /* Skip a previously-counted box. */ /* Set up the next box structure. */ /* Count this box. */ /* Sort the box descriptors. */ /* The box list is no longer necessary. */