NAMD
Public Member Functions | Public Attributes | List of all members
MsmC1HermiteGridCutoff Class Reference
Inheritance diagram for MsmC1HermiteGridCutoff:
MsmGridCutoffKernel< C1Vector, C1Matrix >

Public Member Functions

 MsmC1HermiteGridCutoff ()
 
 MsmC1HermiteGridCutoff (CkMigrateMessage *m)
 
void init ()
 
void setup (MsmGridCutoffInitMsg *bmsg)
 
void setupSections (MsmC1HermiteGridCutoffSetupMsg *msg)
 
void compute (GridMsg *gmsg)
 
void compute_specialized (GridMsg *gmsg)
 
- Public Member Functions inherited from MsmGridCutoffKernel< C1Vector, C1Matrix >
 MsmGridCutoffKernel ()
 
void init ()
 
void setup (MsmGridCutoffInitMsg *bmsg)
 
void setupWeights (const msm::Grid< C1Matrix > *ptrgc, const msm::Grid< C1Matrix > *ptrgvc)
 
void compute (GridMsg *gmsg)
 

Public Attributes

CProxyElement_MsmC1HermiteBlock msmBlockElementProxy
 
CkSectionInfo cookie
 
msm::Grid< C1Vectorehfull
 
- Public Attributes inherited from MsmGridCutoffKernel< C1Vector, C1Matrix >
ComputeMsmMgrmgrLocal
 
msm::Mapmap
 
msm::BlockIndex qhblockIndex
 
msm::BlockSend ehblockSend
 
int eia
 
int eib
 
int eja
 
int ejb
 
int eka
 
int ekb
 
int eni
 
int enj
 
int enk
 
int isfold
 
msm::Grid< C1Vectorqh
 
msm::Grid< C1Vectoreh
 
msm::Grid< C1Vectorehfold
 
const msm::Grid< C1Matrix > * pgc
 
const msm::Grid< C1Matrix > * pgvc
 
int priority
 
int sequence
 

Detailed Description

Definition at line 2327 of file ComputeMsm.C.

Constructor & Destructor Documentation

◆ MsmC1HermiteGridCutoff() [1/2]

MsmC1HermiteGridCutoff::MsmC1HermiteGridCutoff ( )
inline

Definition at line 2338 of file ComputeMsm.C.

2338 { }

◆ MsmC1HermiteGridCutoff() [2/2]

MsmC1HermiteGridCutoff::MsmC1HermiteGridCutoff ( CkMigrateMessage *  m)
inline

Definition at line 2340 of file ComputeMsm.C.

2342  { }

Member Function Documentation

◆ compute()

void MsmC1HermiteGridCutoff::compute ( GridMsg gmsg)
inline

Definition at line 2407 of file ComputeMsm.C.

References msm::Array< T >::buffer(), MsmTimer::COMM, MsmGridCutoffKernel< Vtype, Mtype >::compute(), compute_specialized(), cookie, msm::Grid< T >::data(), MsmGridCutoffKernel< C1Vector, C1Matrix >::eh, MsmGridCutoffKernel< C1Vector, C1Matrix >::ehblockSend, ehfull, msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, msm::Array< T >::len(), msm::BlockIndex::level, MsmGridCutoffKernel< C1Vector, C1Matrix >::mgrLocal, msmBlockElementProxy, ComputeMsmMgr::msmC1HermiteBlock, msm::BlockIndex::n, msm::BlockSend::nblock_wrap, msm::IndexRange::nn(), MsmGridCutoffKernel< C1Vector, C1Matrix >::priority, GridMsg::put(), msm::Grid< T >::reset(), MsmGridCutoffKernel< C1Vector, C1Matrix >::sequence, and SET_PRIORITY.

2407  {
2408 #ifdef DEBUG_MSM_GRID
2409  printf("MsmC1HermiteGridCutoff %d: compute()\n", thisIndex);
2410 #endif
2411 #if 0
2412  // base class consumes this grid message
2414 #else
2415  compute_specialized(gmsg);
2416 #endif
2417 
2418 #ifdef MSM_TIMING
2419  double startTime, stopTime;
2420  startTime = CkWallTimer();
2421 #endif
2422 #ifdef MSM_REDUCE_GRID
2423 
2424  // perform section reduction over potential grids
2425  CProxy_CkMulticastMgr mcastProxy =
2426  CkpvAccess(BOCclass_group).multicastMgr;
2427  CkMulticastMgr *mcastPtr =
2428  CProxy_CkMulticastMgr(mcastProxy).ckLocalBranch();
2429  CkCallback cb(CkIndex_MsmC1HermiteBlock::sumReducedPotential(NULL),
2431  // sum into "full" sized buffer needed for contribute
2432  ehfull.reset(0);
2433  ehfull += eh;
2434  mcastPtr->contribute(
2435  ehfull.nn() * sizeof(C1Vector), ehfull.data().buffer(),
2436  CkReduction::sum_float, cookie, cb);
2437 
2438 #else
2439  // place eh into message
2440  const msm::BlockIndex& bindex = ehblockSend.nblock_wrap;
2441  int msgsz = eh.data().len() * sizeof(C1Vector);
2442  GridMsg *gm = new(msgsz, sizeof(int)) GridMsg;
2444  gm->put(eh, bindex.level, sequence);
2445  // lookup in ComputeMsmMgr proxy array by level
2446  mgrLocal->msmC1HermiteBlock[bindex.level](
2447  bindex.n.i, bindex.n.j, bindex.n.k).addPotential(gm);
2448 
2449 #endif // MSM_REDUCE_GRID
2450 
2451 #ifdef MSM_TIMING
2452  stopTime = CkWallTimer();
2453  mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
2454  mgrLocal->doneTiming();
2455 #endif
2456  } // compute()
msm::Grid< C1Vector > ehfull
Definition: ComputeMsm.C:2335
void reset(const T &t)
Definition: MsmMap.h:670
BlockIndex nblock_wrap
Definition: MsmMap.h:869
int k
Definition: MsmMap.h:411
void compute_specialized(GridMsg *gmsg)
Definition: ComputeMsm.C:2463
int i
Definition: MsmMap.h:411
void compute(GridMsg *gmsg)
Definition: ComputeMsm.C:1904
CProxyElement_MsmC1HermiteBlock msmBlockElementProxy
Definition: ComputeMsm.C:2332
int j
Definition: MsmMap.h:411
const T * buffer() const
Definition: MsmMap.h:259
int nn() const
Definition: MsmMap.h:443
void put(const msm::Grid< T > &g, int id, int seq)
Definition: ComputeMsm.C:126
const Array< T > & data() const
Definition: MsmMap.h:666
int len() const
Definition: MsmMap.h:218
msm::Array< CProxy_MsmC1HermiteBlock > msmC1HermiteBlock
Definition: ComputeMsm.C:465
CkSectionInfo cookie
Definition: ComputeMsm.C:2333
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18

◆ compute_specialized()

void MsmC1HermiteGridCutoff::compute_specialized ( GridMsg gmsg)

Definition at line 2463 of file ComputeMsm.C.

References msm::Array< T >::buffer(), C1_VECTOR_SIZE, MsmTimer::COMM, msm::Grid< T >::data(), MsmGridCutoffKernel< C1Vector, C1Matrix >::eh, MsmGridCutoffKernel< C1Vector, C1Matrix >::ehblockSend, MsmGridCutoffKernel< C1Vector, C1Matrix >::ehfold, MsmGridCutoffKernel< C1Vector, C1Matrix >::eia, MsmGridCutoffKernel< C1Vector, C1Matrix >::eib, MsmGridCutoffKernel< C1Vector, C1Matrix >::eja, MsmGridCutoffKernel< C1Vector, C1Matrix >::ejb, MsmGridCutoffKernel< C1Vector, C1Matrix >::eka, MsmGridCutoffKernel< C1Vector, C1Matrix >::ekb, MsmGridCutoffKernel< C1Vector, C1Matrix >::eni, MsmGridCutoffKernel< C1Vector, C1Matrix >::enj, MsmGridCutoffKernel< C1Vector, C1Matrix >::enk, GridMsg::get(), MsmTimer::GRIDCUTOFF, msm::Ivec::i, msm::IndexRange::ia(), msm::IndexRange::ib(), msm::Grid< T >::init(), MsmGridCutoffKernel< C1Vector, C1Matrix >::isfold, msm::Ivec::j, msm::IndexRange::ja(), msm::IndexRange::jb(), msm::Ivec::k, msm::IndexRange::ka(), msm::IndexRange::kb(), msm::BlockIndex::level, msm::IndexRange::lower(), MsmGridCutoffKernel< C1Vector, C1Matrix >::mgrLocal, msm::IndexRange::ni(), msm::IndexRange::nj(), msm::IndexRange::nk(), msm::BlockSend::nrange, msm::BlockSend::nrange_wrap, MsmGridCutoffKernel< C1Vector, C1Matrix >::pgc, MsmGridCutoffKernel< C1Vector, C1Matrix >::qh, MsmGridCutoffKernel< C1Vector, C1Matrix >::qhblockIndex, msm::Grid< T >::reset(), MsmGridCutoffKernel< C1Vector, C1Matrix >::sequence, msm::Grid< T >::set(), msm::Grid< T >::updateLower(), and C1Vector::velem.

Referenced by compute().

2463  {
2464 #ifdef MSM_TIMING
2465  double startTime, stopTime;
2466  startTime = CkWallTimer();
2467 #endif
2468  //
2469  // receive block of charges
2470  //
2471  int pid;
2472  // qh is resized only the first time, memory allocation persists
2473  gmsg->get(qh, pid, sequence);
2474  delete gmsg;
2475 #ifdef MSM_TIMING
2476  stopTime = CkWallTimer();
2477  mgrLocal->msmTiming[MsmTimer::COMM] += stopTime - startTime;
2478 #endif
2479 
2480  //
2481  // grid cutoff calculation
2482  // this charge block -> this potential block
2483  //
2484 
2485 #ifdef MSM_TIMING
2486  startTime = stopTime;
2487 #endif
2488  // resets indexing on block
2489  eh.init(ehblockSend.nrange); // (always have to re-init nrange for eh)
2490  eh.reset(0);
2491  // index range of weights
2492  int gia = pgc->ia();
2493  int gib = pgc->ib();
2494  int gja = pgc->ja();
2495  int gjb = pgc->jb();
2496  int gka = pgc->ka();
2497  int gkb = pgc->kb();
2498  int gni = pgc->ni();
2499  int gnj = pgc->nj();
2500  // index range of charge grid
2501  int qia = qh.ia();
2502  int qib = qh.ib();
2503  int qja = qh.ja();
2504  int qjb = qh.jb();
2505  int qka = qh.ka();
2506  int qkb = qh.kb();
2507  int qni = qh.ni();
2508  int qnj = qh.nj();
2509  // index range of potentials
2510  int ia = eh.ia();
2511  int ib = eh.ib();
2512  int ja = eh.ja();
2513  int jb = eh.jb();
2514  int ka = eh.ka();
2515  int kb = eh.kb();
2516 
2517  int index = 0;
2518 
2519  // access buffers directly
2520  const C1Matrix *gcbuffer = pgc->data().buffer();
2521  const C1Vector *qhbuffer = qh.data().buffer();
2522  C1Vector *ehbuffer = eh.data().buffer();
2523 #ifdef DEBUG_MEMORY_ALIGNMENT
2524  printf("gcbuffer mem: addr=%p div32=%lu mod32=%lu\n",
2525  gcbuffer,
2526  (unsigned long)(gcbuffer)/32,
2527  (unsigned long)(gcbuffer)%32);
2528  printf("qhbuffer mem: addr=%p div32=%lu mod32=%lu\n",
2529  qhbuffer,
2530  (unsigned long)(qhbuffer)/32,
2531  (unsigned long)(qhbuffer)%32);
2532  printf("ehbuffer mem: addr=%p div32=%lu mod32=%lu\n",
2533  ehbuffer,
2534  (unsigned long)(ehbuffer)/32,
2535  (unsigned long)(ehbuffer)%32);
2536 #endif
2537 
2538 #ifndef MSM_COMM_ONLY
2539  // loop over potentials
2540  for (int k = ka; k <= kb; k++) {
2541  // clip charges to weights along k
2542  int mka = ( qka >= gka + k ? qka : gka + k );
2543  int mkb = ( qkb <= gkb + k ? qkb : gkb + k );
2544 
2545  for (int j = ja; j <= jb; j++) {
2546  // clip charges to weights along j
2547  int mja = ( qja >= gja + j ? qja : gja + j );
2548  int mjb = ( qjb <= gjb + j ? qjb : gjb + j );
2549 
2550  for (int i = ia; i <= ib; i++) {
2551  // clip charges to weights along i
2552  int mia = ( qia >= gia + i ? qia : gia + i );
2553  int mib = ( qib <= gib + i ? qib : gib + i );
2554 
2555  // accumulate sum to this eh point
2556  C1Vector ehsum = 0;
2557 
2558  // loop over charge grid
2559  int nn = mib - mia + 1;
2560 
2561  {
2562  int qnji = qnj * qni;
2563  int qkoff = -qka*qnji - qja*qni - qia + mia;
2564  int gnji = gnj * gni;
2565  int gkoff = (-k-gka)*gnji + (-j-gja)*gni - i - gia + mia;
2566 
2567  for (int qk = mka; qk <= mkb; qk++) {
2568  int qjkoff = qkoff + qk*qnji;
2569  int gjkoff = gkoff + qk*gnji;
2570 
2571  for (int qj = mja; qj <= mjb; qj++) {
2572  const C1Vector *qbuf = qhbuffer + (qjkoff + qj*qni);
2573  const C1Matrix *gbuf = gcbuffer + (gjkoff + qj*gni);
2574 #ifdef MSM_PROFILING
2575  mgrLocal->xLoopCnt[nn]++;
2576 #endif
2577 // help the vectorizer make reasonable decisions
2578 #if defined(__INTEL_COMPILER)
2579 #pragma vector always
2580 #endif
2581  for (int ii = 0; ii < nn; ii++) {
2582 
2583 #if 0
2584  ehsum += gbuf[ii] * qbuf[ii];
2585 #else
2586  // skip matvec when matrix is 0
2587  // first matrix element tells us if this is the case
2588  if ( *((int *)(gbuf)) != 0) {
2589 
2590  // expand matrix-vector multiply
2591 #if defined(__INTEL_COMPILER)
2592 #pragma vector always
2593 #endif
2594  for (int km=0, jm=0; jm < C1_VECTOR_SIZE; jm++) {
2595  for (int im=0; im < C1_VECTOR_SIZE; im++, km++) {
2596  ehsum.velem[jm] += gbuf->melem[km] * qbuf->velem[im];
2597  }
2598  }
2599  } // if
2600  gbuf++;
2601  qbuf++;
2602 #endif
2603  }
2604  }
2605  } // end loop over charge grid
2606 
2607  }
2608 
2609  ehbuffer[index] = ehsum;
2610  index++;
2611  }
2612  }
2613  } // end loop over potentials
2614 #endif // !MSM_COMM_ONLY
2615 
2616 #ifdef MSM_PROFILING
2617  mgrLocal->doneProfiling();
2618 #endif
2619 
2620  //
2621  // send block of potentials
2622  //
2623 
2624 #ifdef MSM_FOLD_FACTOR
2625  // if "fold factor" is active for this level,
2626  // need to sum unfolded potential grid back into periodic grid
2627  if (isfold) {
2628  // copy unfolded grid
2629  ehfold = eh;
2630  // reset eh indexing to correctly folded size
2631  eh.set(eia, eni, eja, enj, eka, enk);
2632  eh.reset(0);
2633 #ifdef DEBUG_MSM_GRID
2634  printf("level=%d ehfold: [%d..%d] x [%d..%d] x [%d..%d] "
2635  "(%d x %d x %d)\n"
2636  " eh: [%d..%d] x [%d..%d] x [%d..%d] "
2637  "(%d x %d x %d)\n"
2638  " eh lower: %d %d %d\n",
2640  ehfold.ia(), ehfold.ib(),
2641  ehfold.ja(), ehfold.jb(),
2642  ehfold.ka(), ehfold.kb(),
2643  ehfold.ni(), ehfold.nj(), ehfold.nk(),
2644  eh.ia(), eh.ib(),
2645  eh.ja(), eh.jb(),
2646  eh.ka(), eh.kb(),
2647  eh.ni(), eh.nj(), eh.nk(),
2651  );
2652 #endif
2653  const C1Vector *ehfoldbuf = ehfold.data().buffer();
2654  C1Vector *ehbuf = eh.data().buffer();
2655  // now we "fold" eh by calculating the
2656  // wrap around sum of ehfold into correctly sized eh
2657  int index = 0;
2658  for (int k = ka; k <= kb; k++) {
2659  int kk = k;
2660  if (kk < eka) do { kk += enk; } while (kk < eka);
2661  else if (kk > ekb) do { kk -= enk; } while (kk > ekb);
2662  int koff = (kk - eka) * enj;
2663  for (int j = ja; j <= jb; j++) {
2664  int jj = j;
2665  if (jj < eja) do { jj += enj; } while (jj < eja);
2666  else if (jj > ejb) do { jj -= enj; } while (jj > ejb);
2667  int jkoff = (koff + (jj - eja)) * eni;
2668  for (int i = ia; i <= ib; i++, index++) {
2669  int ii = i;
2670  if (ii < eia) do { ii += eni; } while (ii < eia);
2671  else if (ii > eib) do { ii -= eni; } while (ii > eib);
2672  int ijkoff = jkoff + (ii - eia);
2673  ehbuf[ijkoff] += ehfoldbuf[index];
2674  }
2675  }
2676  }
2677  }
2678  else {
2679  // shift grid index range to its true (wrapped) values
2681  }
2682 #else // !MSM_FOLD_FACTOR
2683  // shift grid index range to its true (wrapped) values
2685 #endif // MSM_FOLD_FACTOR
2686 
2687 #ifdef MSM_TIMING
2688  stopTime = CkWallTimer();
2689  mgrLocal->msmTiming[MsmTimer::GRIDCUTOFF] += stopTime - startTime;
2690 #endif
2691 } // MsmC1HermiteGridCutoff::compute_specialized()
void reset(const T &t)
Definition: MsmMap.h:670
int k
Definition: MsmMap.h:411
int ja() const
Definition: MsmMap.h:436
int i
Definition: MsmMap.h:411
int kb() const
Definition: MsmMap.h:439
Ivec lower() const
Definition: MsmMap.h:444
void set(int pia, int pni, int pja, int pnj, int pka, int pnk)
Definition: MsmMap.h:608
int ib() const
Definition: MsmMap.h:435
int j
Definition: MsmMap.h:411
void init(const IndexRange &n)
Definition: MsmMap.h:603
const T * buffer() const
Definition: MsmMap.h:259
const msm::Grid< C1Matrix > * pgc
Definition: ComputeMsm.C:1801
IndexRange nrange
Definition: MsmMap.h:868
int ka() const
Definition: MsmMap.h:438
int ia() const
Definition: MsmMap.h:434
const Array< T > & data() const
Definition: MsmMap.h:666
int jb() const
Definition: MsmMap.h:437
void updateLower(const Ivec &n)
Definition: MsmMap.h:677
int nk() const
Definition: MsmMap.h:442
int nj() const
Definition: MsmMap.h:441
int ni() const
Definition: MsmMap.h:440
IndexRange nrange_wrap
Definition: MsmMap.h:870
void get(msm::Grid< T > &g, int &id, int &seq)
Definition: ComputeMsm.C:141
Float velem[C1_VECTOR_SIZE]
Definition: MsmMap.h:87

◆ init()

void MsmC1HermiteGridCutoff::init ( )
inline

◆ setup()

void MsmC1HermiteGridCutoff::setup ( MsmGridCutoffInitMsg bmsg)
inline

Definition at line 2371 of file ComputeMsm.C.

References msm::Map::blockLevel, MsmGridCutoffKernel< C1Vector, C1Matrix >::ehblockSend, ehfull, msm::Map::gc_c1hermite, msm::Ivec::i, msm::Grid< T >::init(), msm::Ivec::j, msm::Ivec::k, msm::BlockIndex::level, MsmGridCutoffKernel< C1Vector, C1Matrix >::map, msm::BlockIndex::n, msm::BlockSend::nblock_wrap, MsmGridCutoffKernel< Vtype, Mtype >::setup(), and MsmGridCutoffKernel< Vtype, Mtype >::setupWeights().

2371  {
2372  // base class consumes this init proxy message
2374  // access type dependent constants from map
2377  NULL
2378  );
2379 #ifdef DEBUG_MSM_GRID
2380  printf("MsmC1HermiteGridCutoff[%d]: setup()"
2381  " send to level=%d block=(%d,%d,%d)\n",
2382  thisIndex, ehblockSend.nblock_wrap.level,
2386 #endif
2387 #ifdef MSM_REDUCE_GRID
2388  // allocate full buffer space needed for section reduction
2389  int level = ehblockSend.nblock_wrap.level;
2390  int i = ehblockSend.nblock_wrap.n.i;
2391  int j = ehblockSend.nblock_wrap.n.j;
2392  int k = ehblockSend.nblock_wrap.n.k;
2393  ehfull.init( map->blockLevel[level](i,j,k).nrange );
2394 #endif // MSM_REDUCE_GRID
2395  }
msm::Grid< C1Vector > ehfull
Definition: ComputeMsm.C:2335
BlockIndex nblock_wrap
Definition: MsmMap.h:869
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
Array< Grid< BlockDiagram > > blockLevel
Definition: MsmMap.h:956
int j
Definition: MsmMap.h:411
void init(const IndexRange &n)
Definition: MsmMap.h:603
void setupWeights(const msm::Grid< Mtype > *ptrgc, const msm::Grid< Mtype > *ptrgvc)
Definition: ComputeMsm.C:1895
void setup(MsmGridCutoffInitMsg *bmsg)
Definition: ComputeMsm.C:1838
Array< Grid< C1Matrix > > gc_c1hermite
Definition: MsmMap.h:949

◆ setupSections()

void MsmC1HermiteGridCutoff::setupSections ( MsmC1HermiteGridCutoffSetupMsg msg)
inline

Definition at line 2397 of file ComputeMsm.C.

References cookie, MsmC1HermiteGridCutoffSetupMsg::get(), and msmBlockElementProxy.

2397  {
2398 #ifdef DEBUG_MSM_GRID
2399  CkPrintf("MSM C1 HERMITE GRID CUTOFF %d setup section on PE %d\n",
2400  thisIndex, CkMyPe());
2401 #endif
2402  CkGetSectionInfo(cookie, msg); // init the cookie
2403  msg->get(&msmBlockElementProxy); // get proxy to MsmC1HermiteBlock
2404  delete msg;
2405  }
CProxyElement_MsmC1HermiteBlock msmBlockElementProxy
Definition: ComputeMsm.C:2332
void get(CProxyElement_MsmC1HermiteBlock *q)
Definition: ComputeMsm.C:282
CkSectionInfo cookie
Definition: ComputeMsm.C:2333

Member Data Documentation

◆ cookie

CkSectionInfo MsmC1HermiteGridCutoff::cookie

Definition at line 2333 of file ComputeMsm.C.

Referenced by compute(), and setupSections().

◆ ehfull

msm::Grid<C1Vector> MsmC1HermiteGridCutoff::ehfull

Definition at line 2335 of file ComputeMsm.C.

Referenced by compute(), and setup().

◆ msmBlockElementProxy

CProxyElement_MsmC1HermiteBlock MsmC1HermiteGridCutoff::msmBlockElementProxy

Definition at line 2332 of file ComputeMsm.C.

Referenced by compute(), and setupSections().


The documentation for this class was generated from the following file: