msm.h File Reference

Go to the source code of this file.

Typedefs

typedef NL_Msm_t NL_Msm

Enumerations

enum  {
  NL_MSM_PERIODIC_NONE = 0x000, NL_MSM_PERIODIC_VEC1 = 0x001, NL_MSM_PERIODIC_VEC2 = 0x002, NL_MSM_PERIODIC_VEC3 = 0x004,
  NL_MSM_PERIODIC_ALL = 0x007, NL_MSM_COMPUTE_SHORT_RANGE = 0x008, NL_MSM_COMPUTE_LONG_RANGE = 0x010, NL_MSM_COMPUTE_ALL = 0x018,
  NL_MSM_COMPUTE_SPREC = 0x020, NL_MSM_COMPUTE_1AWAY = 0x040, NL_MSM_COMPUTE_NONFACTORED = 0x080, NL_MSM_REPORT_TIMINGS = 0x100,
  NL_MSM_COMPUTE_CUDA_FALL_BACK = 0x200, NL_MSM_COMPUTE_CUDA_GRID_CUTOFF = 0x400, NL_MSM_COMPUTE_CUDA_SHORT_RANGE = 0x800, NL_MSM_COMPUTE_CUDA = 0xE00,
  NL_MSM_ALL_FLAGS = 0xFFF
}
enum  {
  NL_MSM_SUCCESS = 0, NL_MSM_ERROR_MALLOC, NL_MSM_ERROR_PARAM, NL_MSM_ERROR_RANGE,
  NL_MSM_ERROR_SUPPORT, NL_MSM_ERROR_CUDA, NL_MSM_ERROR_END
}
enum  {
  NL_MSM_APPROX_CUBIC = 0, NL_MSM_APPROX_QUINTIC, NL_MSM_APPROX_QUINTIC2, NL_MSM_APPROX_SEPTIC,
  NL_MSM_APPROX_SEPTIC3, NL_MSM_APPROX_NONIC, NL_MSM_APPROX_NONIC4, NL_MSM_APPROX_BSPLINE,
  NL_MSM_APPROX_END
}
enum  {
  NL_MSM_SPLIT_TAYLOR2 = 0, NL_MSM_SPLIT_TAYLOR3, NL_MSM_SPLIT_TAYLOR4, NL_MSM_SPLIT_TAYLOR5,
  NL_MSM_SPLIT_TAYLOR6, NL_MSM_SPLIT_TAYLOR7, NL_MSM_SPLIT_TAYLOR8, NL_MSM_SPLIT_TAYLOR1,
  NL_MSM_SPLIT_SIGMA2_3, NL_MSM_SPLIT_SIGMA3_5, NL_MSM_SPLIT_SIGMA4_6, NL_MSM_SPLIT_SIGMA4_7,
  NL_MSM_SPLIT_SIGMA5_8, NL_MSM_SPLIT_SIGMA5_9, NL_MSM_SPLIT_SIGMA6_9, NL_MSM_SPLIT_SIGMA6_10,
  NL_MSM_SPLIT_SIGMA6_11, NL_MSM_SPLIT_SIGMA7_11, NL_MSM_SPLIT_SIGMA7_12, NL_MSM_SPLIT_SIGMA7_13,
  NL_MSM_SPLIT_SIGMA8_12, NL_MSM_SPLIT_SIGMA8_13, NL_MSM_SPLIT_SIGMA8_14, NL_MSM_SPLIT_SIGMA8_15,
  NL_MSM_SPLIT_SIGMA2_6, NL_MSM_SPLIT_SWITCH1_2, NL_MSM_SPLIT_SWITCH3_4, NL_MSM_SPLIT_SWITCH7_8,
  NL_MSM_SPLIT_END
}

Functions

NL_MsmNL_msm_create (void)
void NL_msm_destroy (NL_Msm *)
int NL_msm_setup (NL_Msm *msm, double cutoff, double cellvec1[3], double cellvec2[3], double cellvec3[3], double cellcenter[3], int msmflags)
int NL_msm_configure (NL_Msm *msm, double gridspacing, int approx, int split, int nlevels)
int NL_msm_compute_force (NL_Msm *msm, double *felec, double *uelec, const double *atom, int natoms)
int NL_msm_compute_force_sprec (NL_Msm *msm, float *felec, float *uelec, const float *atom, int natoms)
int NL_msm_approx (const char *name)
int NL_msm_split (const char *name)
const char * NL_msm_approx_name (int approx)
const char * NL_msm_split_name (int split)


Typedef Documentation

typedef struct NL_Msm_t NL_Msm

Definition at line 13 of file msm.h.


Enumeration Type Documentation

anonymous enum

Use in setup for msmflags, bitwise OR the options.

Enumerator:
NL_MSM_PERIODIC_NONE  aperiodic cell
NL_MSM_PERIODIC_VEC1  periodic along basis vector 1
NL_MSM_PERIODIC_VEC2  periodic along basis vector 2
NL_MSM_PERIODIC_VEC3  periodic along basis vector 3
NL_MSM_PERIODIC_ALL  periodic along all basis vectors
NL_MSM_COMPUTE_SHORT_RANGE  compute the short-range part
NL_MSM_COMPUTE_LONG_RANGE  compute the long-range part
NL_MSM_COMPUTE_ALL  compute both parts
NL_MSM_COMPUTE_SPREC  use single precision (faster)
NL_MSM_COMPUTE_1AWAY  1-away neighborhood (slower)
NL_MSM_COMPUTE_NONFACTORED  use non-factored restriction and prolongation procedures (slower)
NL_MSM_REPORT_TIMINGS  report timings
NL_MSM_COMPUTE_CUDA_FALL_BACK  fall back on CPU if configuration unsupported by CUDA
NL_MSM_COMPUTE_CUDA_GRID_CUTOFF  use CUDA for grid cutoff
NL_MSM_COMPUTE_CUDA_SHORT_RANGE  use CUDA for short range
NL_MSM_COMPUTE_CUDA  all CUDA flags set on
NL_MSM_ALL_FLAGS  all flags set on

Definition at line 43 of file msm.h.

00043        {
00044     NL_MSM_PERIODIC_NONE     = 0x000,  
00045     NL_MSM_PERIODIC_VEC1     = 0x001,  
00046     NL_MSM_PERIODIC_VEC2     = 0x002,  
00047     NL_MSM_PERIODIC_VEC3     = 0x004,  
00048     NL_MSM_PERIODIC_ALL      = 0x007,  
00050     NL_MSM_COMPUTE_SHORT_RANGE
00051                              = 0x008,  
00052     NL_MSM_COMPUTE_LONG_RANGE
00053                              = 0x010,  
00054     NL_MSM_COMPUTE_ALL       = 0x018,  
00056     NL_MSM_COMPUTE_SPREC     = 0x020,  
00057     NL_MSM_COMPUTE_1AWAY     = 0x040,  
00058     NL_MSM_COMPUTE_NONFACTORED
00059                              = 0x080,  
00062     NL_MSM_REPORT_TIMINGS    = 0x100,  
00064     NL_MSM_COMPUTE_CUDA_FALL_BACK
00065                              = 0x200,  
00067     NL_MSM_COMPUTE_CUDA_GRID_CUTOFF
00068                              = 0x400,  
00069     NL_MSM_COMPUTE_CUDA_SHORT_RANGE
00070                              = 0x800,  
00071     NL_MSM_COMPUTE_CUDA      = 0xE00,  
00073     NL_MSM_ALL_FLAGS         = 0xFFF   
00074   };

anonymous enum

Return codes.

Enumerator:
NL_MSM_SUCCESS  success
NL_MSM_ERROR_MALLOC  can't allocate memory
NL_MSM_ERROR_PARAM  incorrect parameters
NL_MSM_ERROR_RANGE  atom is outside of cell
NL_MSM_ERROR_SUPPORT  unsupported feature
NL_MSM_ERROR_CUDA  CUDA failure
NL_MSM_ERROR_END  (for internal use)

Definition at line 77 of file msm.h.

anonymous enum

MSM approximation/interpolation methods. (Default is CUBIC.)

Enumerator:
NL_MSM_APPROX_CUBIC  C1 degree 3 poly (numerical Hermite)
NL_MSM_APPROX_QUINTIC  C1 degree 5 poly (linear blend of degree 4)
NL_MSM_APPROX_QUINTIC2  C2 degree 5 poly
NL_MSM_APPROX_SEPTIC  C1 degree 7 poly (linear blend of degree 6)
NL_MSM_APPROX_SEPTIC3  C3 degree 7 poly
NL_MSM_APPROX_NONIC  C1 degree 9 poly (linear blend of degree 8)
NL_MSM_APPROX_NONIC4  C4 degree 9 poly
NL_MSM_APPROX_BSPLINE  C2 degree 3 B-spline
NL_MSM_APPROX_END  (for internal use)

Definition at line 153 of file msm.h.

anonymous enum

MSM splitting functions to smooth the 1/r potential. (Default is TAYLOR2.)

The Taylor splittings are the family of C^k Taylor polynomials of s^(-1/2) about s=1. Discussed in section 5.1 of the thesis. TAYLOR1 is listed last so that reasonable default parameters (CUBIC approximation with TAYLOR2 splitting) are automatically selected from zeroing the values.

The sigma(k,d) splittings generalize the Taylor splittings above for C^k continuity at r=1 and degree d polynomial in r. (The Taylor splittings are sigma(d/2,d).) The ones here are uniquely determined. Discussed in section 5.2 of the thesis.

The special sigma(2,6) splitting is from section 5.3 of the thesis. This is a proof-of-concept where the polynomial in even powers of r has an extra degree of freedom chosen to minimize the error bound.

Elimiate the self-force artifact through the use of a switching function between 1/r and a polynomial reproduced exactly by CUBIC interpolation. Discussed in section 5.4 of thesis.

Enumerator:
NL_MSM_SPLIT_TAYLOR2  C2 Taylor
NL_MSM_SPLIT_TAYLOR3  C3 Taylor
NL_MSM_SPLIT_TAYLOR4  C4 Taylor
NL_MSM_SPLIT_TAYLOR5  C5 Taylor
NL_MSM_SPLIT_TAYLOR6  C6 Taylor
NL_MSM_SPLIT_TAYLOR7  C7 Taylor
NL_MSM_SPLIT_TAYLOR8  C8 Taylor
NL_MSM_SPLIT_TAYLOR1  C1 Taylor
NL_MSM_SPLIT_SIGMA2_3  C2, degree 3 (the "perfect" smoothing)
NL_MSM_SPLIT_SIGMA3_5  C3, degree 5
NL_MSM_SPLIT_SIGMA4_6  C4, degree 6
NL_MSM_SPLIT_SIGMA4_7  C4, degree 7
NL_MSM_SPLIT_SIGMA5_8  C5, degree 8
NL_MSM_SPLIT_SIGMA5_9  C5, degree 9
NL_MSM_SPLIT_SIGMA6_9  C6, degree 9
NL_MSM_SPLIT_SIGMA6_10  C6, degree 10
NL_MSM_SPLIT_SIGMA6_11  C6, degree 11
NL_MSM_SPLIT_SIGMA7_11  C7, degree 11
NL_MSM_SPLIT_SIGMA7_12  C7, degree 12
NL_MSM_SPLIT_SIGMA7_13  C7, degree 13
NL_MSM_SPLIT_SIGMA8_12  C8, degree 12
NL_MSM_SPLIT_SIGMA8_13  C8, degree 13
NL_MSM_SPLIT_SIGMA8_14  C8, degree 14
NL_MSM_SPLIT_SIGMA8_15  C8, degree 15
NL_MSM_SPLIT_SIGMA2_6  C2, degree 6, even powers of r, chosen to minimize error bound
NL_MSM_SPLIT_SWITCH1_2  C2, switching at r/a=1/2
NL_MSM_SPLIT_SWITCH3_4  C2, switching at r/a=3/4
NL_MSM_SPLIT_SWITCH7_8  C2, switching at r/a=7/8
NL_MSM_SPLIT_END  (for internal use)

Definition at line 187 of file msm.h.


Function Documentation

int NL_msm_approx ( const char *  name  ) 

Helper function to determine APPROX enum constant from string name.

Definition at line 160 of file msm.c.

References ApproxName, and NELEMS.

00160                                     {
00161   int i;
00162   if (name) {
00163     for (i = 0;  i < NELEMS(ApproxName);  i++) {
00164       if (strcasecmp(name, ApproxName[i]) == 0) return i;
00165     }
00166   }
00167   return -1;
00168 }

const char* NL_msm_approx_name ( int  approx  ) 

Helper function returning string name for APPROX enum constant.

Definition at line 170 of file msm.c.

References ApproxName, and NELEMS.

Referenced by print_status().

00170                                            {
00171   if (approx >= 0 && approx < NELEMS(ApproxName)) {
00172     return ApproxName[approx];
00173   }
00174   else return NULL;
00175 }

int NL_msm_compute_force ( NL_Msm msm,
double *  felec,
double *  uelec,
const double *  atom,
int  natoms 
)

Compute the electrostatic forces and potential energy for the array of atoms. The felec array and the location pointed to by uelec is expected to be initialized before the call. As stated, the atoms must be within the defined cell.

Parameters:
msm  the MSM solver object
felec  electrostatic forces x/y/z for each atom
uelec  electrostatic potential energy
atom  positions and charge x/y/z/q for each atom
natoms  number of atoms

Definition at line 56 of file msm.c.

References NL_Msm_t::atom, NL_Msm_t::felec, NL_Msm_t::msmflags, NL_msm_compute_long_range(), NL_MSM_COMPUTE_LONG_RANGE, NL_msm_compute_short_range(), NL_MSM_COMPUTE_SHORT_RANGE, NL_MSM_COMPUTE_SPREC, NL_MSM_ERROR_PARAM, NL_Msm_t::numatoms, NL_Msm_t::report_timings, NL_Msm_t::timer, NL_Msm_t::uelec, wkf_timer_start(), wkf_timer_stop(), and wkf_timer_time().

Referenced by ComputeMsmSerialMgr::recvCoord().

00062       {
00063   int rc;
00064   double time_delta;
00065 
00066   if (pm->msmflags & NL_MSM_COMPUTE_SPREC) {
00067     return NL_MSM_ERROR_PARAM;
00068   }
00069 
00070   /* store buffer pointers from caller */
00071   pm->felec = felec;
00072   pm->atom = atom;
00073   pm->numatoms = natoms;
00074   pm->uelec = 0;
00075 
00076   if (pm->msmflags & NL_MSM_COMPUTE_SHORT_RANGE) {
00077     wkf_timer_start(pm->timer);
00078     rc = NL_msm_compute_short_range(pm);
00079     if (rc) return rc;
00080     wkf_timer_stop(pm->timer);
00081     time_delta = wkf_timer_time(pm->timer);
00082     if (pm->report_timings) {
00083       printf("MSM short-range part:  %6.3f sec\n", time_delta);
00084     }
00085   }
00086   if (pm->msmflags & NL_MSM_COMPUTE_LONG_RANGE) {
00087     wkf_timer_start(pm->timer);
00088     rc = NL_msm_compute_long_range(pm);
00089     if (rc) return rc;
00090     wkf_timer_stop(pm->timer);
00091     time_delta = wkf_timer_time(pm->timer);
00092     if (pm->report_timings) {
00093       printf("MSM long-range part:   %6.3f sec\n", time_delta);
00094     }
00095   }
00096   *uelec += pm->uelec;  /* add to caller's potential */
00097 
00098   return 0;
00099 }

int NL_msm_compute_force_sprec ( NL_Msm msm,
float *  felec,
float *  uelec,
const float *  atom,
int  natoms 
)

Same as NL_msm_compute_force() except for single precision calculation. Call this only if NL_MSM_COMPUTE_SPREC flag was selected.

Parameters:
msm  the MSM solver object
felec  electrostatic forces x/y/z for each atom
uelec  electrostatic potential energy
atom  positions and charge x/y/z/q for each atom
natoms  number of atoms

Definition at line 102 of file msm.c.

References NL_Msm_t::atom_f, NL_Msm_t::felec_f, NL_Msm_t::msmflags, NL_MSM_COMPUTE_LONG_RANGE, NL_msm_compute_long_range_sprec(), NL_MSM_COMPUTE_SHORT_RANGE, NL_msm_compute_short_range_sprec(), NL_MSM_COMPUTE_SPREC, NL_MSM_ERROR_PARAM, NL_Msm_t::numatoms, NL_Msm_t::report_timings, NL_Msm_t::timer, NL_Msm_t::uelec, wkf_timer_start(), wkf_timer_stop(), and wkf_timer_time().

00108       {
00109   int rc;
00110   double time_delta;
00111 
00112   if ((pm->msmflags & NL_MSM_COMPUTE_SPREC) == 0) {
00113     return NL_MSM_ERROR_PARAM;
00114   }
00115 
00116   /* store buffer pointers from caller */
00117   pm->felec_f = felec_f;
00118   pm->atom_f = atom_f;
00119   pm->numatoms = natoms;
00120   pm->uelec = 0;
00121 
00122   if (pm->msmflags & NL_MSM_COMPUTE_SHORT_RANGE) {
00123     wkf_timer_start(pm->timer);
00124     rc = NL_msm_compute_short_range_sprec(pm);
00125     if (rc) return rc;
00126     wkf_timer_stop(pm->timer);
00127     time_delta = wkf_timer_time(pm->timer);
00128     if (pm->report_timings) {
00129       printf("MSM short-range part:  %6.3f sec\n", time_delta);
00130     }
00131   }
00132   if (pm->msmflags & NL_MSM_COMPUTE_LONG_RANGE) {
00133     wkf_timer_start(pm->timer);
00134     rc = NL_msm_compute_long_range_sprec(pm);
00135     if (rc) return rc;
00136     wkf_timer_stop(pm->timer);
00137     time_delta = wkf_timer_time(pm->timer);
00138     if (pm->report_timings) {
00139       printf("MSM long-range part:   %6.3f sec\n", time_delta);
00140     }
00141   }
00142   *uelec_f += (float) pm->uelec;  /* add to caller's potential */
00143 
00144   return 0;
00145 }

int NL_msm_configure ( NL_Msm msm,
double  gridspacing,
int  approx,
int  split,
int  nlevels 
)

Advanced configuration of MSM. The ratio of cutoff / gridspacing is generally kept between about 2.5 and 6. For atomic lengths in Angstroms, good results are demonstrated for a cutoff distance between 8 and 12 A and the default grid spacing of 2.5 A.

The optimal pairings of approx and split have been demonstrated to be:

Use QUINTIC2, SEPTIC3, NONIC4 paired with the same splitting functions above if greater continuity is desired.

Set "nlevels" to 0 (the default) to fully adapt the number of grid levels to the system cell size.

Parameters:
msm  the MSM solver object
gridspacing  grid spacing for first grid level
approx  which approximation method
split  which splitting
nlevels  number of grid levels to use

Definition at line 36 of file msm.c.

References NL_Msm_t::approx, NL_Msm_t::gridspacing, NL_MSM_APPROX_END, NL_MSM_ERROR_PARAM, NL_MSM_SPLIT_END, NL_MSM_SUCCESS, NL_Msm_t::nlevels, and NL_Msm_t::split.

Referenced by ComputeMsmSerialMgr::recvCoord().

00042       {
00043   if (gridspacing > 0) pm->gridspacing = gridspacing;
00044   else if (gridspacing < 0) return NL_MSM_ERROR_PARAM;
00045   if (approx >= 0 && approx < NL_MSM_APPROX_END) pm->approx = approx;
00046   else return NL_MSM_ERROR_PARAM;
00047   if (split >= 0 && split < NL_MSM_SPLIT_END) pm->split = split;
00048   else return NL_MSM_ERROR_PARAM;
00049   if (nlevels >= 0) pm->nlevels = nlevels;
00050   else return NL_MSM_ERROR_PARAM;
00051 
00052   return NL_MSM_SUCCESS;
00053 }

NL_Msm* NL_msm_create ( void   ) 

Allocate MSM solver.

Definition at line 6 of file msm.c.

References NL_Msm_t::approx, NL_Msm_t::binfill, DEFAULT_APPROX, DEFAULT_BINFILL, DEFAULT_DENSITY, DEFAULT_GRIDSPACING, DEFAULT_NBINSLOTS, DEFAULT_NLEVELS, DEFAULT_SPLIT, NL_Msm_t::density, NL_Msm_t::gridspacing, NL_Msm_t::nbinslots, NL_Msm_t::nlevels, NL_Msm_t::split, NL_Msm_t::timer, NL_Msm_t::timer_longrng, and wkf_timer_create().

Referenced by ComputeMsmSerialMgr::recvCoord().

00006                             {
00007   NL_Msm *pm = (NL_Msm *) calloc(1, sizeof(NL_Msm));
00008   if (NULL == pm) return NULL;
00009 
00010   pm->timer = wkf_timer_create();
00011   if (NULL == pm->timer) return NULL;
00012   pm->timer_longrng = wkf_timer_create();
00013   if (NULL == pm->timer) return NULL;
00014 
00015   /* method parameters are modified with msm_configure() */
00016   pm->gridspacing = DEFAULT_GRIDSPACING;
00017   pm->approx = DEFAULT_APPROX;
00018   pm->split = DEFAULT_SPLIT;
00019   pm->nlevels = DEFAULT_NLEVELS;
00020 
00021   pm->density = DEFAULT_DENSITY;
00022   pm->binfill = DEFAULT_BINFILL;
00023   pm->nbinslots = DEFAULT_NBINSLOTS;
00024   return pm;
00025 }

void NL_msm_destroy ( NL_Msm  ) 

Free MSM solver.

Definition at line 28 of file msm.c.

References NL_msm_cleanup(), NL_Msm_t::timer, NL_Msm_t::timer_longrng, and wkf_timer_destroy().

Referenced by ComputeMsmSerialMgr::~ComputeMsmSerialMgr().

00028                                 {
00029   NL_msm_cleanup(pm);
00030   wkf_timer_destroy(pm->timer);
00031   wkf_timer_destroy(pm->timer_longrng);
00032   free(pm);
00033 }

int NL_msm_setup ( NL_Msm msm,
double  cutoff,
double  cellvec1[3],
double  cellvec2[3],
double  cellvec3[3],
double  cellcenter[3],
int  msmflags 
)

Setup the MSM solver for the molecular system. These parameters come directly from the simulation. Here the cutoff provides some control over the accuracy. The region of space containing the atoms is defined as a parallelepiped, and the "isperiodic" flag determines whether or not each individual cell dimension has periodic boundary conditions. The defined cell is expected to contain the atoms regardless of the choice of boundary conditions. The cell volume must contain the cutoff-sphere.

XXX For now, the MSM solver permits only cell vectors that align with the x-, y-, and z-axis, respectively.

Parameters:
msm  the MSM solver object
cutoff  cutoff distance for short-range part
cellvec1  cell basis vector 1
cellvec2  cell basis vector 2
cellvec3  cell basis vector 3
cellcenter  center of cell
msmflags  flags for periodicity and calculation

Definition at line 62 of file msm_setup.c.

References NL_Msm_t::a, NL_Msm_t::a_f, NL_Msm_t::cellcenter, NL_Msm_t::cellcenter_f, NL_Msm_t::cellvec1, NL_Msm_t::cellvec1_f, NL_Msm_t::cellvec2, NL_Msm_t::cellvec2_f, NL_Msm_t::cellvec3, NL_Msm_t::cellvec3_f, NL_Msm_t::gx, NL_Msm_t::gx_f, NL_Msm_t::gy, NL_Msm_t::gy_f, NL_Msm_t::gz, NL_Msm_t::gz_f, NL_Msm_t::hx, NL_Msm_t::hx_f, NL_Msm_t::hy, NL_Msm_t::hy_f, NL_Msm_t::hz, NL_Msm_t::hz_f, NL_Msm_t::msmflags, NL_MSM_ALL_FLAGS, NL_MSM_COMPUTE_1AWAY, NL_MSM_COMPUTE_ALL, NL_MSM_COMPUTE_CUDA_FALL_BACK, NL_MSM_COMPUTE_CUDA_GRID_CUTOFF, NL_MSM_COMPUTE_LONG_RANGE, NL_MSM_COMPUTE_SHORT_RANGE, NL_MSM_COMPUTE_SPREC, NL_MSM_ERROR_PARAM, NL_MSM_ERROR_SUPPORT, NL_MSM_PERIODIC_VEC1, NL_MSM_PERIODIC_VEC2, NL_MSM_PERIODIC_VEC3, NL_MSM_REPORT_TIMINGS, NL_MSM_SUCCESS, print_status(), NL_Msm_t::recipvec1, NL_Msm_t::recipvec1_f, NL_Msm_t::recipvec2, NL_Msm_t::recipvec2_f, NL_Msm_t::recipvec3, NL_Msm_t::recipvec3_f, NL_Msm_t::report_timings, setup_bins_1away(), setup_bins_k_away(), setup_cell_vectors(), and setup_grids().

Referenced by ComputeMsmSerialMgr::recvCoord().

00070       {
00071 
00072   int rc = 0;
00073 
00074   /* check sanity of msmflags */
00075   if ((~NL_MSM_ALL_FLAGS & msmflags) != 0 ||
00076       (NL_MSM_COMPUTE_ALL & msmflags) == 0) {
00077     return NL_MSM_ERROR_PARAM;
00078   }
00079 
00080   /* report timings? */
00081   pm->report_timings = ((msmflags & NL_MSM_REPORT_TIMINGS) != 0);
00082 
00083   /* for now, permit only orthogonal cell aligned with coordinate axes */
00084   if (cellvec1[1] != 0 || cellvec1[2] != 0 ||
00085       cellvec2[0] != 0 || cellvec2[2] != 0 ||
00086       cellvec3[0] != 0 || cellvec3[1] != 0 ||
00087       cellvec1[0] <= 0 || cellvec2[1] <= 0 || cellvec3[2] <= 0) {
00088     return NL_MSM_ERROR_SUPPORT;
00089   }
00090 
00091   /* check sanity of cutoff wrt expected cell;
00092    * XXX cell widths must be at least the cutoff distance length */
00093   if (cutoff <= 0 ||
00094       (cutoff > cellvec1[0] && (msmflags & NL_MSM_PERIODIC_VEC1)) ||
00095       (cutoff > cellvec2[1] && (msmflags & NL_MSM_PERIODIC_VEC2)) ||
00096       (cutoff > cellvec3[2] && (msmflags & NL_MSM_PERIODIC_VEC3))) {
00097     return NL_MSM_ERROR_PARAM;
00098   }
00099 
00100   pm->msmflags = msmflags;
00101   pm->cellvec1[0] = cellvec1[0];
00102   pm->cellvec1[1] = cellvec1[1];
00103   pm->cellvec1[2] = cellvec1[2];
00104   pm->cellvec2[0] = cellvec2[0];
00105   pm->cellvec2[1] = cellvec2[1];
00106   pm->cellvec2[2] = cellvec2[2];
00107   pm->cellvec3[0] = cellvec3[0];
00108   pm->cellvec3[1] = cellvec3[1];
00109   pm->cellvec3[2] = cellvec3[2];
00110   pm->cellcenter[0] = cellcenter[0];
00111   pm->cellcenter[1] = cellcenter[1];
00112   pm->cellcenter[2] = cellcenter[2];
00113 
00114   pm->a = cutoff;
00115 
00116   rc = setup_cell_vectors(pm);
00117   if (rc) return rc;
00118 
00119   if (msmflags & NL_MSM_COMPUTE_SHORT_RANGE) {
00120     /* set up bins for short-range part */
00121     if (msmflags & NL_MSM_COMPUTE_1AWAY) {
00122       rc = setup_bins_1away(pm);
00123     }
00124     else {
00125       rc = setup_bins_k_away(pm);
00126     }
00127     if (rc) return rc;
00128   }
00129 
00130   if (msmflags & NL_MSM_COMPUTE_LONG_RANGE) {
00131     /* set up grid hierarchy for long-range part */
00132     rc = setup_grids(pm);
00133     if (rc) return rc;
00134   }
00135 
00136   if (msmflags & NL_MSM_COMPUTE_SPREC) {
00137     /* fill out single precision data if needed */
00138     pm->cellvec1_f[0] = (float) pm->cellvec1[0];
00139     pm->cellvec1_f[1] = (float) pm->cellvec1[1];
00140     pm->cellvec1_f[2] = (float) pm->cellvec1[2];
00141     pm->cellvec2_f[0] = (float) pm->cellvec2[0];
00142     pm->cellvec2_f[1] = (float) pm->cellvec2[1];
00143     pm->cellvec2_f[2] = (float) pm->cellvec2[2];
00144     pm->cellvec3_f[0] = (float) pm->cellvec3[0];
00145     pm->cellvec3_f[1] = (float) pm->cellvec3[1];
00146     pm->cellvec3_f[2] = (float) pm->cellvec3[2];
00147     pm->cellcenter_f[0] = (float) pm->cellcenter[0];
00148     pm->cellcenter_f[1] = (float) pm->cellcenter[1];
00149     pm->cellcenter_f[2] = (float) pm->cellcenter[2];
00150     pm->recipvec1_f[0] = (float) pm->recipvec1[0];
00151     pm->recipvec1_f[1] = (float) pm->recipvec1[1];
00152     pm->recipvec1_f[2] = (float) pm->recipvec1[2];
00153     pm->recipvec2_f[0] = (float) pm->recipvec2[0];
00154     pm->recipvec2_f[1] = (float) pm->recipvec2[1];
00155     pm->recipvec2_f[2] = (float) pm->recipvec2[2];
00156     pm->recipvec3_f[0] = (float) pm->recipvec3[0];
00157     pm->recipvec3_f[1] = (float) pm->recipvec3[1];
00158     pm->recipvec3_f[2] = (float) pm->recipvec3[2];
00159     pm->hx_f = pm->hx;
00160     pm->hy_f = pm->hy;
00161     pm->hz_f = pm->hz;
00162     pm->a_f = pm->a;
00163     pm->gx_f = pm->gx;
00164     pm->gy_f = pm->gy;
00165     pm->gz_f = pm->gz;
00166   }
00167 
00168   print_status(pm);
00169 
00170 #ifdef NL_USE_CUDA
00171   if (msmflags & NL_MSM_COMPUTE_CUDA_GRID_CUTOFF) {
00172     rc = NL_msm_cuda_setup_gridcutoff(pm);
00173     if (rc == NL_MSM_SUCCESS) {
00174       printf("Using CUDA for grid cutoff computation\n");
00175     }
00176     else {
00177       printf("Unable to set up CUDA for grid cutoff computation\n");
00178       if (msmflags & NL_MSM_COMPUTE_CUDA_FALL_BACK) {
00179         NL_msm_cuda_cleanup_gridcutoff(pm);
00180         printf("Falling back on CPU\n");
00181         pm->msmflags &= ~NL_MSM_COMPUTE_CUDA_GRID_CUTOFF;
00182       }
00183       else return rc;
00184     }
00185   }
00186 #else
00187   if (msmflags & NL_MSM_COMPUTE_CUDA_GRID_CUTOFF) {
00188     if (msmflags & NL_MSM_COMPUTE_CUDA_FALL_BACK) {
00189       printf("Falling back on CPU\n");
00190       pm->msmflags &= ~NL_MSM_COMPUTE_CUDA_GRID_CUTOFF;
00191     }
00192     else return NL_MSM_ERROR_SUPPORT;
00193   }
00194 #endif /* NL_USE_CUDA */
00195 
00196   return NL_MSM_SUCCESS;
00197 }

int NL_msm_split ( const char *  name  ) 

Helper function to determine SPLIT enum constant from string name.

Definition at line 210 of file msm.c.

References NELEMS, and SplitName.

00210                                    {
00211   int i;
00212   if (name) {
00213     for (i = 0;  i < NELEMS(SplitName);  i++) {
00214       if (strcasecmp(name, SplitName[i]) == 0) return i;
00215     }
00216   }
00217   return -1;
00218 }

const char* NL_msm_split_name ( int  split  ) 

Helper function returning string name for SPLIT enum constant.

Definition at line 220 of file msm.c.

References NELEMS, and SplitName.

Referenced by print_status().

00220                                          {
00221   if (split >= 0 && split < NELEMS(SplitName)) {
00222     return SplitName[split];
00223   }
00224   else return NULL;
00225 }


Generated on Sat Nov 18 01:17:17 2017 for NAMD by  doxygen 1.4.7