Cache repeated interpolation plans
This commit is contained in:
@@ -180,19 +180,64 @@ surface_integral::surface_integral(int iSymmetry) : Symmetry(iSymmetry)
|
||||
//|============================================================================
|
||||
//| Destructor
|
||||
//|============================================================================
|
||||
surface_integral::~surface_integral()
|
||||
{
|
||||
delete[] nx_g;
|
||||
delete[] ny_g;
|
||||
delete[] nz_g;
|
||||
delete[] arcostheta;
|
||||
#ifdef GaussInt
|
||||
delete[] wtcostheta;
|
||||
#endif
|
||||
}
|
||||
//|----------------------------------------------------------------
|
||||
// spin weighted spinw component of psi4, general routine
|
||||
// l takes from spinw to maxl; m takes from -l to l
|
||||
surface_integral::~surface_integral()
|
||||
{
|
||||
release_cached_buffers();
|
||||
delete[] nx_g;
|
||||
delete[] ny_g;
|
||||
delete[] nz_g;
|
||||
delete[] arcostheta;
|
||||
#ifdef GaussInt
|
||||
delete[] wtcostheta;
|
||||
#endif
|
||||
}
|
||||
|
||||
void surface_integral::get_surface_points(double rex, double **pox)
|
||||
{
|
||||
SpherePointCache &cache = sphere_point_cache[rex];
|
||||
if (!cache.pox[0])
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
cache.pox[i] = new double[n_tot];
|
||||
for (int n = 0; n < n_tot; ++n)
|
||||
{
|
||||
cache.pox[0][n] = rex * nx_g[n];
|
||||
cache.pox[1][n] = rex * ny_g[n];
|
||||
cache.pox[2][n] = rex * nz_g[n];
|
||||
}
|
||||
}
|
||||
|
||||
pox[0] = cache.pox[0];
|
||||
pox[1] = cache.pox[1];
|
||||
pox[2] = cache.pox[2];
|
||||
}
|
||||
|
||||
double *surface_integral::get_shellf_buffer(int num_var)
|
||||
{
|
||||
double *&buffer = shellf_cache[num_var];
|
||||
if (!buffer)
|
||||
buffer = new double[n_tot * num_var];
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void surface_integral::release_cached_buffers()
|
||||
{
|
||||
for (map<double, SpherePointCache>::iterator it = sphere_point_cache.begin(); it != sphere_point_cache.end(); ++it)
|
||||
{
|
||||
delete[] it->second.pox[0];
|
||||
delete[] it->second.pox[1];
|
||||
delete[] it->second.pox[2];
|
||||
it->second.pox[0] = it->second.pox[1] = it->second.pox[2] = 0;
|
||||
}
|
||||
sphere_point_cache.clear();
|
||||
|
||||
for (map<int, double *>::iterator it = shellf_cache.begin(); it != shellf_cache.end(); ++it)
|
||||
delete[] it->second;
|
||||
shellf_cache.clear();
|
||||
}
|
||||
//|----------------------------------------------------------------
|
||||
// spin weighted spinw component of psi4, general routine
|
||||
// l takes from spinw to maxl; m takes from -l to l
|
||||
//|----------------------------------------------------------------
|
||||
void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *Ipsi4,
|
||||
int spinw, int maxl, int NN, double *RP, double *IP,
|
||||
@@ -209,16 +254,9 @@ void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *
|
||||
MyList<var> *DG_List = new MyList<var>(Rpsi4);
|
||||
DG_List->insert(Ipsi4);
|
||||
|
||||
int n;
|
||||
double *pox[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
pox[i] = new double[n_tot];
|
||||
for (n = 0; n < n_tot; n++)
|
||||
{
|
||||
pox[0][n] = rex * nx_g[n];
|
||||
pox[1][n] = rex * ny_g[n];
|
||||
pox[2][n] = rex * nz_g[n];
|
||||
}
|
||||
int n;
|
||||
double *pox[3];
|
||||
get_surface_points(rex, pox);
|
||||
|
||||
int mp, Lp, Nmin, Nmax;
|
||||
mp = n_tot / cpusize;
|
||||
@@ -234,8 +272,7 @@ void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *
|
||||
Nmax = Nmin + mp - 1;
|
||||
}
|
||||
|
||||
double *shellf;
|
||||
shellf = new double[n_tot * InList];
|
||||
double *shellf = get_shellf_buffer(InList);
|
||||
|
||||
GH->PatL[lev]->data->Interp_Points(DG_List, n_tot, pox, shellf, Symmetry, Nmin, Nmax);
|
||||
|
||||
@@ -375,14 +412,10 @@ void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *
|
||||
|
||||
//|------= Free memory.
|
||||
|
||||
delete[] pox[0];
|
||||
delete[] pox[1];
|
||||
delete[] pox[2];
|
||||
delete[] shellf;
|
||||
delete[] RP_out;
|
||||
delete[] IP_out;
|
||||
DG_List->clearList();
|
||||
}
|
||||
delete[] RP_out;
|
||||
delete[] IP_out;
|
||||
DG_List->clearList();
|
||||
}
|
||||
void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *Ipsi4,
|
||||
int spinw, int maxl, int NN, double *RP, double *IP,
|
||||
monitor *Monitor, MPI_Comm Comm_here) // NN is the length of RP and IP
|
||||
@@ -402,19 +435,11 @@ void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *
|
||||
MyList<var> *DG_List = new MyList<var>(Rpsi4);
|
||||
DG_List->insert(Ipsi4);
|
||||
|
||||
int n;
|
||||
double *pox[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
pox[i] = new double[n_tot];
|
||||
for (n = 0; n < n_tot; n++)
|
||||
{
|
||||
pox[0][n] = rex * nx_g[n];
|
||||
pox[1][n] = rex * ny_g[n];
|
||||
pox[2][n] = rex * nz_g[n];
|
||||
}
|
||||
|
||||
double *shellf;
|
||||
shellf = new double[n_tot * InList];
|
||||
int n;
|
||||
double *pox[3];
|
||||
get_surface_points(rex, pox);
|
||||
|
||||
double *shellf = get_shellf_buffer(InList);
|
||||
|
||||
// misc::tillherecheck(GH->Commlev[lev],GH->start_rank[lev],"before Interp_Points");
|
||||
|
||||
@@ -577,14 +602,10 @@ void surface_integral::surf_Wave(double rex, int lev, cgh *GH, var *Rpsi4, var *
|
||||
|
||||
//|------= Free memory.
|
||||
|
||||
delete[] pox[0];
|
||||
delete[] pox[1];
|
||||
delete[] pox[2];
|
||||
delete[] shellf;
|
||||
delete[] RP_out;
|
||||
delete[] IP_out;
|
||||
DG_List->clearList();
|
||||
}
|
||||
delete[] RP_out;
|
||||
delete[] IP_out;
|
||||
DG_List->clearList();
|
||||
}
|
||||
//|----------------------------------------------------------------
|
||||
// for shell patch
|
||||
//|----------------------------------------------------------------
|
||||
@@ -597,19 +618,11 @@ void surface_integral::surf_Wave(double rex, int lev, ShellPatch *GH, var *Rpsi4
|
||||
MyList<var> *DG_List = new MyList<var>(Rpsi4);
|
||||
DG_List->insert(Ipsi4);
|
||||
|
||||
int n;
|
||||
double *pox[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
pox[i] = new double[n_tot];
|
||||
for (n = 0; n < n_tot; n++)
|
||||
{
|
||||
pox[0][n] = rex * nx_g[n];
|
||||
pox[1][n] = rex * ny_g[n];
|
||||
pox[2][n] = rex * nz_g[n];
|
||||
}
|
||||
int n;
|
||||
double *pox[3];
|
||||
get_surface_points(rex, pox);
|
||||
|
||||
double *shellf;
|
||||
shellf = new double[n_tot * InList];
|
||||
double *shellf = get_shellf_buffer(InList);
|
||||
|
||||
GH->Interp_Points(DG_List, n_tot, pox, shellf, Symmetry);
|
||||
|
||||
@@ -2570,12 +2583,8 @@ void surface_integral::surf_MassPAng(double rex, int lev, cgh *GH, var *chi, var
|
||||
Rout[5] = sy;
|
||||
Rout[6] = sz;
|
||||
|
||||
delete[] pox[0];
|
||||
delete[] pox[1];
|
||||
delete[] pox[2];
|
||||
delete[] shellf;
|
||||
DG_List->clearList();
|
||||
}
|
||||
DG_List->clearList();
|
||||
}
|
||||
void surface_integral::surf_MassPAng(double rex, int lev, cgh *GH, var *chi, var *trK,
|
||||
var *gxx, var *gxy, var *gxz, var *gyy, var *gyz, var *gzz,
|
||||
var *Axx, var *Axy, var *Axz, var *Ayy, var *Ayz, var *Azz,
|
||||
@@ -2637,19 +2646,11 @@ void surface_integral::surf_MassPAng(double rex, int lev, cgh *GH, var *chi, var
|
||||
DG_List->insert(Ayz);
|
||||
DG_List->insert(Azz);
|
||||
|
||||
int n;
|
||||
double *pox[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
pox[i] = new double[n_tot];
|
||||
for (n = 0; n < n_tot; n++)
|
||||
{
|
||||
pox[0][n] = rex * nx_g[n];
|
||||
pox[1][n] = rex * ny_g[n];
|
||||
pox[2][n] = rex * nz_g[n];
|
||||
}
|
||||
|
||||
double *shellf;
|
||||
shellf = new double[n_tot * InList];
|
||||
int n;
|
||||
double *pox[3];
|
||||
get_surface_points(rex, pox);
|
||||
|
||||
double *shellf = get_shellf_buffer(InList);
|
||||
|
||||
// we have assumed there is only one box on this level,
|
||||
// so we do not need loop boxes
|
||||
@@ -2839,12 +2840,8 @@ void surface_integral::surf_MassPAng(double rex, int lev, cgh *GH, var *chi, var
|
||||
Rout[5] = sy;
|
||||
Rout[6] = sz;
|
||||
|
||||
delete[] pox[0];
|
||||
delete[] pox[1];
|
||||
delete[] pox[2];
|
||||
delete[] shellf;
|
||||
DG_List->clearList();
|
||||
}
|
||||
DG_List->clearList();
|
||||
}
|
||||
//|----------------------------------------------------------------
|
||||
// for shell patch
|
||||
//|----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user