ls1-MarDyn
ls1-MarDyn molecular dynamics code
PositionCellProcessorRMM.h
1/*
2 * PositionCellProcessorRMM.h
3 *
4 * Created on: 5 Oct 2017
5 * Author: tchipevn
6 */
7
8#ifndef SRC_INTEGRATORS_POSITIONCELLPROCESSORRMM_H_
9#define SRC_INTEGRATORS_POSITIONCELLPROCESSORRMM_H_
10
11#include "particleContainer/ParticleCell.h"
12#include "particleContainer/adapter/CellProcessor.h"
13
14// explicit Leapfrog position update rule in a vectorized fashion for the RMM
15
17public:
18 PositionCellProcessorRMM(double timeStep) : CellProcessor(0.0, 0.0), _timeStep(static_cast<vcp_real_calc>(timeStep)) {}
19 void initTraversal() {}
20
22
23 void processCellPair(ParticleCell& cell1, ParticleCell& cell2, bool sumAll = false) {} // does this need bool?
24
25 double processSingleMolecule(Molecule* m1, ParticleCell& cell2) { return 0.0; }
26
28
29 void endTraversal() {}
30
32 ParticleCellRMM & c = downcastCellReferenceRMM(cell);
33 CellDataSoARMM & soa = c.getCellDataSoA();
34 const size_t end_i = vcp_floor_to_vec_size(soa.getMolNum());
35
36 vcp_real_calc * const soa_r_x = soa.r_xBegin();
37 vcp_real_calc * const soa_r_y = soa.r_yBegin();
38 vcp_real_calc * const soa_r_z = soa.r_zBegin();
39 const vcp_real_accum * const soa_v_x = soa.v_xBegin();
40 const vcp_real_accum * const soa_v_y = soa.v_yBegin();
41 const vcp_real_accum * const soa_v_z = soa.v_zBegin();
42
43 const RealCalcVec dt = RealCalcVec::set1(_timeStep);
44
45 size_t i = 0;
46 for (; i < end_i; i += VCP_VEC_SIZE) {
47 RealCalcVec r_x = RealCalcVec::aligned_load(soa_r_x + i);
48 RealCalcVec r_y = RealCalcVec::aligned_load(soa_r_y + i);
49 RealCalcVec r_z = RealCalcVec::aligned_load(soa_r_z + i);
50
51 const RealAccumVec v_x = RealAccumVec::aligned_load(soa_v_x + i);
52 const RealAccumVec v_y = RealAccumVec::aligned_load(soa_v_y + i);
53 const RealAccumVec v_z = RealAccumVec::aligned_load(soa_v_z + i);
54
55 const RealCalcVec c_v_x = RealAccumVec::convertAccumToCalc(v_x);
56 const RealCalcVec c_v_y = RealAccumVec::convertAccumToCalc(v_y);
57 const RealCalcVec c_v_z = RealAccumVec::convertAccumToCalc(v_z);
58
59 r_x = RealCalcVec::fmadd(dt, c_v_x, r_x);
60 r_y = RealCalcVec::fmadd(dt, c_v_y, r_y);
61 r_z = RealCalcVec::fmadd(dt, c_v_z, r_z);
62
63 r_x.aligned_store(soa_r_x + i);
64 r_y.aligned_store(soa_r_y + i);
65 r_z.aligned_store(soa_r_z + i);
66
67 }
68 const MaskCalcVec remainderMask = vcp_simd_getRemainderMask(soa.getMolNum());
69 if (remainderMask.movemask()) {
70 RealCalcVec r_x = RealCalcVec::aligned_load_mask(soa_r_x + i, remainderMask);
71 RealCalcVec r_y = RealCalcVec::aligned_load_mask(soa_r_y + i, remainderMask);
72 RealCalcVec r_z = RealCalcVec::aligned_load_mask(soa_r_z + i, remainderMask);
73
74 const RealAccumVec v_x = RealAccumVec::aligned_load_mask(soa_v_x + i, remainderMask);
75 const RealAccumVec v_y = RealAccumVec::aligned_load_mask(soa_v_y + i, remainderMask);
76 const RealAccumVec v_z = RealAccumVec::aligned_load_mask(soa_v_z + i, remainderMask);
77
78 const RealCalcVec c_v_x = RealAccumVec::convertAccumToCalc(v_x);
79 const RealCalcVec c_v_y = RealAccumVec::convertAccumToCalc(v_y);
80 const RealCalcVec c_v_z = RealAccumVec::convertAccumToCalc(v_z);
81
82 r_x = RealCalcVec::fmadd(dt, c_v_x, r_x);
83 r_y = RealCalcVec::fmadd(dt, c_v_y, r_y);
84 r_z = RealCalcVec::fmadd(dt, c_v_z, r_z);
85
86 // TODO: handle aligned masked store properly in intrinsics.
87 // For now just store, not caring about mask. Due to internal padding, this will work without problems and will not overwrite stuff.
88 r_x.aligned_store(soa_r_x + i);
89 r_y.aligned_store(soa_r_y + i);
90 r_z.aligned_store(soa_r_z + i);
91 }
92 }
93
94private:
95 vcp_real_calc _timeStep;
96};
97
98#endif /* SRC_INTEGRATORS_POSITIONCELLPROCESSORRMM_H_ */
Structure of Arrays for single-center lennard-Jones molecules for the RMM run.
Definition: CellDataSoARMM.h:16
Definition: CellProcessor.h:29
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
FullParticleCell data structure. Renamed from ParticleCell.
Definition: FullParticleCell.h:49
Definition: ParticleCellRMM.h:8
Definition: PositionCellProcessorRMM.h:16
void endTraversal()
Definition: PositionCellProcessorRMM.h:29
void initTraversal()
Definition: PositionCellProcessorRMM.h:19
void preprocessCell(ParticleCell &cell)
Definition: PositionCellProcessorRMM.h:21
void postprocessCell(ParticleCell &cell)
Definition: PositionCellProcessorRMM.h:27
void processCell(ParticleCell &cell)
Definition: PositionCellProcessorRMM.h:31
void processCellPair(ParticleCell &cell1, ParticleCell &cell2, bool sumAll=false)
Definition: PositionCellProcessorRMM.h:23
Definition: MaskVec.h:16
Definition: RealVec.h:22