STORMM Source Documentation
Loading...
Searching...
No Matches
cellgrid.h
1// -*-c++-*-
2#ifndef STORMM_CELLGRID_H
3#define STORMM_CELLGRID_H
4
5#include "copyright.h"
6#include "Accelerator/core_kernel_manager.h"
7#include "Accelerator/gpu_details.h"
8#include "Accelerator/hybrid.h"
9#include "Constants/behavior.h"
10#include "Constants/fixed_precision.h"
11#include "Constants/hpc_bounds.h"
12#include "DataTypes/common_types.h"
13#include "Math/formulas.h"
14#include "Math/math_enumerators.h"
15#include "Math/matrix_ops.h"
16#include "Math/rounding.h"
17#include "Math/series_ops.h"
18#include "Math/vector_ops.h"
19#include "Numerics/split_fixed_precision.h"
20#include "Parsing/parsing_enumerators.h"
21#include "Parsing/parse.h"
22#include "Potential/energy_enumerators.h"
23#include "Structure/local_arrangement.h"
24#include "Structure/structure_enumerators.h"
25#include "Synthesis/atomgraph_synthesis.h"
26#include "Synthesis/phasespace_synthesis.h"
27#include "Synthesis/synthesis_abstracts.h"
28#include "Topology/atomgraph.h"
29#include "Topology/atomgraph_abstracts.h"
30#include "Topology/atomgraph_enumerators.h"
31#include "Topology/lennard_jones_analysis.h"
32#include "Topology/topology_util.h"
33#include "Trajectory/coordinate_copy.h"
34#include "Trajectory/coordinateframe.h"
35#include "Trajectory/trajectory_enumerators.h"
36
37namespace stormm {
38namespace energy {
39
40using card::CoreKlManager;
41using card::GpuDetails;
42using card::Hybrid;
43using card::HybridKind;
44using card::HybridTargetLevel;
45using constants::CartesianDimension;
46using constants::ExceptionResponse;
47using constants::PrecisionModel;
48using constants::UnitCellAxis;
49using data_types::getStormmScalarTypeName;
50using data_types::getStormmHpcVectorTypeName;
51using data_types::isFloatingPointScalarType;
52using numerics::force_scale_nonoverflow_bits;
53using numerics::globalpos_scale_nonoverflow_bits;
54using numerics::hostInt63ToLongLong;
55using numerics::hostSplitFPMult;
56using numerics::hostSplitFPSubtract;
57using parse::NumberFormat;
58using parse::realToString;
59using stmath::hessianNormalWidths;
60using stmath::indexingArray;
61using stmath::ipowl;
62using stmath::LimitApproach;
63using stmath::matrixMultiply;
64using stmath::minValue;
65using stmath::maxValue;
66using stmath::mean;
67using stmath::nearestFactor;
68using stmath::prefixSumInPlace;
69using stmath::PrefixSumType;
70using stmath::roundUp;
71using structure::imageCoordinates;
72using structure::ImagingMethod;
73using synthesis::AtomGraphSynthesis;
74using synthesis::PhaseSpaceSynthesis;
75using synthesis::PsSynthesisBorders;
76using synthesis::PsSynthesisReader;
77using synthesis::PsSynthesisWriter;
78using synthesis::SyNonbondedKit;
79using topology::AtomGraph;
80using topology::hasVdwProperties;
81using topology::inferCombiningRule;
82using topology::NonbondedKit;
83using topology::UnitCellType;
84using trajectory::coordCopy;
85using trajectory::CoordinateCycle;
86using trajectory::CoordinateFrame;
87using trajectory::CoordinateFrameWriter;
88using trajectory::TrajectoryKind;
89
92constexpr size_t default_cellgrid_base_capacity = 8;
93constexpr size_t cellgrid_tp_excl_allotment = 12;
94constexpr size_t cellgrid_total_excl_allotment = 15;
95constexpr int default_mesh_ticks = 4;
96constexpr int maximum_cellgrid_cell_count = 268435456;
97constexpr int maximum_xl_cell_count = 64;
98constexpr double minimum_cell_width = 2.5;
99constexpr double maximum_cell_width = 12.0;
100constexpr int maximum_cellgrid_systems = 65536;
101static const int maximum_cellgrid_span = 1023;
102static const int maximum_wandering_atoms = 256;
103static const int sp_charge_index_bits = 23;
104static const int dp_charge_index_bits = 32;
105static const int sp_charge_index_mask = 0x7ffff;
106static const llint dp_charge_index_mask = 0xffffffffLL;
108
121static const ullint required_ring_mask = 0x1018041408242028LLU;
122static const uint required_cntr_mask = 0x3f;
123static const ullint prohibited_ring_mask = 0x8c80b080b0808c80LLU;
124static const uint prohibited_cntr_mask = 0xbc;
126
131static const int std_max_migration_notes = 1920;
132static const int ext_max_migration_notes = 4608;
134
137template <typename T, typename Tacc, typename Tcalc, typename T4> struct CellGridWriter {
138
141 CellGridWriter(NonbondedTheme theme_in, int system_count_in, int total_cell_count_in,
142 int total_chain_count_in, int mesh_ticks_in, uint cell_base_capacity_in,
143 float lpos_scale_in, float inv_lpos_scale_in, float frc_scale_in,
144 const ullint* system_cell_grids_in, Tcalc* system_cell_umat_in,
145 T* system_cell_invu_in, T* system_pmig_invu, uint2* cell_limits_in,
146 uint2* cell_limits_alt_in, const uint* chain_limits_in,
147 const int* system_chain_bounds_in, const int* chain_system_owner_in, T4* image_in,
148 T4* image_alt_in, uchar* migration_keys_in, int* wander_count_in,
149 int* wander_count_alt_in, uint2* wanderers_in, int* nonimg_atom_idx_in,
150 int* nonimg_atom_idx_alt_in, uint* img_atom_idx_in, uint* img_atom_idx_alt_in,
151 ushort* img_atom_chn_cell_in, ushort* img_atom_chn_cell_alt_in,
152 const int* nt_groups_in, ushort* relevance_in, Tacc* xfrc_in, Tacc* yfrc_in,
153 Tacc* zfrc_in, int* xfrc_ovrf_in, int* yfrc_ovrf_in, int* zfrc_ovrf_in);
154
158 CellGridWriter(const CellGridWriter &original) = default;
159 CellGridWriter(CellGridWriter &&original) = default;
161
162 const NonbondedTheme theme;
164 const int system_count;
170 const int mesh_ticks;
177 const float lpos_scale;
181 const float inv_lpos_scale;
183 const float frc_scale;
185 const ullint* system_cell_grids;
210 const uint* chain_limits;
226 T4* image;
273 const int* nt_groups;
278 ushort* relevance;
282 Tacc* xfrc;
283 Tacc* yfrc;
284 Tacc* zfrc;
288};
289
296template <typename T, typename Tacc, typename Tcalc, typename T4> struct CellGridReader {
297
301 CellGridReader(NonbondedTheme theme_in, int system_count_in, int total_cell_count_in,
302 int total_chain_count_in, int mesh_ticks_in, uint cell_base_capacity_in,
303 float lpos_scale_in, float inv_lpos_scale_in, float inv_frc_scale_in,
304 const ullint* system_cell_grids_in, const Tcalc* system_cell_umat_in,
305 const T* system_cell_invu_in, const T* system_pmig_invu_in,
306 const uint2* cell_limits_in, const uint* chain_limits_in,
307 const int* system_chain_bounds_in, const int* chain_system_owner_in,
308 const T4* image_in, const int* nonimg_atom_idx_in, const uint* img_atom_idx_in,
309 const ushort* img_atom_chn_cell_in, const int* nt_groups_in,
310 const ushort* relevance_in, const Tacc* xfrc_in, const Tacc* yfrc_in,
311 const Tacc* zfrc_in, const int* xfrc_ovrf_in, const int* yfrc_ovrf_in,
312 const int* zfrc_ovrf_in);
313
315
318
322 CellGridReader(const CellGridReader &original) = default;
323 CellGridReader(CellGridReader &&original) = default;
325
326 const NonbondedTheme theme;
328 const int system_count;
334 const int mesh_ticks;
341 const float lpos_scale;
345 const float inv_lpos_scale;
347 const float inv_frc_scale;
349 const ullint* system_cell_grids;
351 const Tcalc* system_cell_umat;
371 const uint* chain_limits;
387 const T4* image;
388 const int* nonimg_atom_idx;
395 const uint* img_atom_idx;
400 const ushort* img_atom_chn_cell;
403 const int* nt_groups;
408 const ushort* relevance;
412 const Tacc* xfrc;
413 const Tacc* yfrc;
414 const Tacc* zfrc;
415 const int* xfrc_ovrf;
416 const int* yfrc_ovrf;
417 const int* zfrc_ovrf;
418};
419
422public:
423
426 CellOriginsWriter(int stride_in, llint* ax_in, int* ax_ovrf_in, llint* bx_in, int* bx_ovrf_in,
427 llint* by_in, int* by_ovrf_in, llint* cx_in, int* cx_ovrf_in, llint* cy_in,
428 int* cy_ovrf_in, llint* cz_in, int* cz_ovrf_in);
429
437 CellOriginsWriter(const CellOriginsWriter &original) = default;
438 CellOriginsWriter(CellOriginsWriter &&original) = default;
440
441 const int stride;
442 llint* ax;
445 llint* bx;
446 llint* by;
447 llint* cx;
448 llint* cy;
449 llint* cz;
450 int* ax_ovrf;
451 int* bx_ovrf;
452 int* by_ovrf;
453 int* cx_ovrf;
454 int* cy_ovrf;
455 int* cz_ovrf;
456};
457
460public:
461
465 CellOriginsReader(int stride_in, const llint* ax_in, const int* ax_ovrf_in, const llint* bx_in,
466 const int* bx_ovrf_in, const llint* by_in, const int* by_ovrf_in,
467 const llint* cx_in, const int* cx_ovrf_in, const llint* cy_in,
468 const int* cy_ovrf_in, const llint* cz_in, const int* cz_ovrf_in);
469
471
474
482 CellOriginsReader(const CellOriginsReader &original) = default;
483 CellOriginsReader(CellOriginsReader &&original) = default;
485
486 const int stride;
487 const llint* ax;
490 const llint* bx;
491 const llint* by;
492 const llint* cx;
493 const llint* cy;
494 const llint* cz;
495 const int* ax_ovrf;
496 const int* bx_ovrf;
497 const int* by_ovrf;
498 const int* cx_ovrf;
499 const int* cy_ovrf;
500 const int* cz_ovrf;
501};
502
562template <typename T, typename Tacc, typename Tcalc, typename T4> class CellGrid {
563public:
564
586 CellGrid(const PhaseSpaceSynthesis *poly_ps_ptr_in, const AtomGraphSynthesis *poly_ag_ptr_in,
587 double cutoff_in, double padding_in, int mesh_subdivisions_in, NonbondedTheme theme_in,
588 uint cell_base_capacity_in = default_cellgrid_base_capacity,
589 ExceptionResponse policy_in = ExceptionResponse::WARN);
590
591 CellGrid(const PhaseSpaceSynthesis *poly_ps_ptr_in, const AtomGraphSynthesis &poly_ag_ptr_in,
592 double cutoff_in, double padding_in, int mesh_subdivisions_in, NonbondedTheme theme_in,
593 uint cell_base_capacity_in = default_cellgrid_base_capacity,
594 ExceptionResponse policy_in = ExceptionResponse::WARN);
595
596 CellGrid(const PhaseSpaceSynthesis &poly_ps_ptr_in, const AtomGraphSynthesis &poly_ag_ptr_in,
597 double cutoff_in, double padding_in, int mesh_subdivisions_in, NonbondedTheme theme_in,
598 uint cell_base_capacity_in = default_cellgrid_base_capacity,
599 ExceptionResponse policy_in = ExceptionResponse::WARN);
601
609 CellGrid(const CellGrid &original);
610 CellGrid(CellGrid &&original);
611 CellGrid& operator=(const CellGrid &original);
612 CellGrid& operator=(CellGrid &&original);
614
616 int getSystemCount() const;
617
619 int getTotalCellCount() const;
620
630 int getCellCount(int index) const;
631 int getCellCount(int index, UnitCellAxis axis) const;
632 int getCellCount(int index, CartesianDimension axis) const;
634
638
640 double getCutoff() const;
641
643 double getPadding() const;
644
646 double getEffectiveCutoff() const;
647
650 NonbondedTheme getTheme() const;
651
653 TinyBoxPresence getTinyBoxPresence() const;
654
656 CoordinateCycle getCyclePosition() const;
657
660
664
675 uint getImageIndex(int system_index, int atom_index, CoordinateCycle orientation) const;
676 uint getImageIndex(int system_index, int atom_index) const;
678
688 int4 getCellLocation(int system_index, int atom_index, CoordinateCycle orientation) const;
689 int4 getCellLocation(int system_index, int atom_index) const;
691
697 int2 getChainLocation(int system_index, int atom_index, CoordinateCycle orientation) const;
698 int2 getChainLocation(int system_index, int atom_index) const;
700
717 getUnitCellTransforms(CoordinateCycle orientation,
718 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
719
721 getUnitCellTransforms(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
723
726
729
742 CellGridWriter<T, Tacc, Tcalc, T4> data(CoordinateCycle orientation,
743 HybridTargetLevel tier = HybridTargetLevel::HOST);
744
745 CellGridWriter<T, Tacc, Tcalc, T4> data(HybridTargetLevel tier = HybridTargetLevel::HOST);
746
748 data(CoordinateCycle orientation, HybridTargetLevel tier = HybridTargetLevel::HOST) const;
749
751 data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
753
758 templateFreeData(CoordinateCycle orientation, HybridTargetLevel tier = HybridTargetLevel::HOST);
759
761 templateFreeData(HybridTargetLevel tier = HybridTargetLevel::HOST);
762
764 templateFreeData(CoordinateCycle orientation,
765 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
766
768 templateFreeData(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
770
785 const CellOriginsReader getRulers(CoordinateCycle orientation,
786 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
787
788 const CellOriginsReader getRulers(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
789
790 CellOriginsWriter getRulers(CoordinateCycle orientation,
791 HybridTargetLevel tier = HybridTargetLevel::HOST);
792
793 CellOriginsWriter getRulers(HybridTargetLevel tier = HybridTargetLevel::HOST);
795
799
800#ifdef STORMM_USE_HPC
802 void upload();
803
805 void download();
806#endif
807
819 void initializeForces(HybridTargetLevel tier = HybridTargetLevel::HOST,
820 const GpuDetails &gpu = null_gpu);
821
850 void markImageRelevance(HybridTargetLevel tier = HybridTargetLevel::HOST,
851 const GpuDetails &gpu = null_gpu);
852
864 void contributeForces(PhaseSpaceSynthesis *dest, HybridTargetLevel tier,
865 const GpuDetails &gpu) const;
866
867 void contributeForces(HybridTargetLevel tier = HybridTargetLevel::HOST,
868 const GpuDetails &gpu = null_gpu) const;
870
875 void updatePositions(PhaseSpaceSynthesis *dest, HybridTargetLevel tier,
876 const GpuDetails &gpu);
877
878 void updatePositions(HybridTargetLevel tier = HybridTargetLevel::HOST,
879 const GpuDetails &gpu = null_gpu);
881
894 void updateCyclePosition(CoordinateCycle time_point);
896
897private:
898 int system_count;
899 int total_cell_count;
900 int total_chain_count;
903 uint cell_base_capacity;
904 double cutoff;
905 double padding;
906 double effective_cutoff;
909 int mesh_subdivisions;
912 ExceptionResponse policy;
914 NonbondedTheme theme;
916 TinyBoxPresence has_tiny_box;
922
925 CoordinateCycle cycle_position;
926
927 // The local coordinate systems for each cell are tailored to maximize the amount of information
928 // that can be encoded in the fixed-precision representation with the data type implied by the
929 // precision member variable (PrecisionModel::SINGLE implies 32-bit ints, PrecisionModel::DOUBLE
930 // implies 64-bit long long ints). The number of fixed precision bits is designed to accommodate
931 // stacking up to two cells against the home cell along any of the simulation box axes and still
932 // have any coordinates within those boxes be represented by the fixed-precision format without
933 // overflow. Furthermore, the format is designed to accommodate moderate stretching of the
934 // simulation box (up to 5% in any direction). If the simulation expands significantly, this
935 // will trigger the cell grid to be rebuilt.
936 int localpos_scale_bits;
938 double localpos_scale;
940 double localpos_inverse_scale;
941
947 Hybrid<ullint> system_cell_grids;
948
953 Hybrid<Tcalc> system_cell_umat;
954 Hybrid<Tcalc> system_cell_umat_alt;
955
961 Hybrid<T> system_cell_invu;
962 Hybrid<T> system_cell_invu_alt;
964
970 Hybrid<T> system_pmig_invu;
971 Hybrid<T> system_pmig_invu_alt;
973
978 Hybrid<T> particle_mesh_grid_invu;
979 Hybrid<T> particle_mesh_grid_invu_alt;
980
988 Hybrid<uint2> image_cell_limits;
989 Hybrid<uint2> image_cell_limits_alt;
991
995 Hybrid<uint> image_chain_limits;
996
1001 Hybrid<int> system_chain_bounds;
1002
1007 Hybrid<int> chain_system_membership;
1008
1036 Hybrid<T4> image;
1037 Hybrid<T4> image_alt;
1039
1043 Hybrid<int> nonimaged_atom_indices;
1044 Hybrid<int> nonimaged_atom_indices_alt;
1046
1054 Hybrid<uint> image_array_indices;
1055 Hybrid<uint> image_array_indices_alt;
1057
1063 Hybrid<ushort> image_chain_cell_indices;
1064 Hybrid<ushort> image_chain_cell_indices_alt;
1066
1078 Hybrid<uchar> cell_migrations;
1079
1086 Hybrid<int> wandering_atom_count;
1087 Hybrid<int> wandering_atom_count_alt;
1089
1094 Hybrid<uint2> wanderers;
1095
1098 Hybrid<int> nt_work_groups;
1099
1116 Hybrid<ushort> image_relevance;
1117
1118 // Force accumulation arrays track the total number of atoms in the atoms or sp_atoms list.
1119 // These accumulators are split, with the primary accummulators being llint for double-precision
1120 // and int for single-precision. The overflow accumulators are used in both cases, even if
1121 // accesses to them are rare.
1122 Hybrid<Tacc> x_force;
1123 Hybrid<Tacc> y_force;
1124 Hybrid<Tacc> z_force;
1125 Hybrid<int> x_force_overflow;
1126 Hybrid<int> y_force_overflow;
1127 Hybrid<int> z_force_overflow;
1128
1129 // A series of rulers encodes the origins of each system's neighbor list cells. Pointers to
1130 // these member variable arrays are made avialable by a second abstract of the CellGrid class,
1131 // the CellOriginsReader and CellOriginsWriter. The coordinates in these rules follow the global
1132 // positioning fixed-precision system of the accompanying PhaseSpaceSynthesis.
1133 int origin_offset_stride;
1145 Hybrid<llint> cell_origins_ax;
1149 Hybrid<llint> cell_origins_bx;
1153 Hybrid<llint> cell_origins_by;
1155 Hybrid<llint> cell_origins_cx;
1157 Hybrid<llint> cell_origins_cy;
1159 Hybrid<llint> cell_origins_cz;
1161 Hybrid<int> cell_origins_ax_overflow;
1164 Hybrid<int> cell_origins_bx_overflow;
1167 Hybrid<int> cell_origins_by_overflow;
1170 Hybrid<int> cell_origins_cx_overflow;
1173 Hybrid<int> cell_origins_cy_overflow;
1176 Hybrid<int> cell_origins_cz_overflow;
1179 Hybrid<llint> alt_cell_origins_ax;
1181 Hybrid<llint> alt_cell_origins_bx;
1183 Hybrid<llint> alt_cell_origins_by;
1185 Hybrid<llint> alt_cell_origins_cx;
1187 Hybrid<llint> alt_cell_origins_cy;
1189 Hybrid<llint> alt_cell_origins_cz;
1191 Hybrid<int> alt_cell_origins_ax_overflow;
1193 Hybrid<int> alt_cell_origins_bx_overflow;
1195 Hybrid<int> alt_cell_origins_by_overflow;
1197 Hybrid<int> alt_cell_origins_cx_overflow;
1199 Hybrid<int> alt_cell_origins_cy_overflow;
1201 Hybrid<int> alt_cell_origins_cz_overflow;
1203 Hybrid<llint> origin_llint_data;
1206 Hybrid<int> origin_int_data;
1209
1211 PhaseSpaceSynthesis *poly_ps_ptr;
1212
1219 AtomGraphSynthesis *poly_ag_ptr;
1220
1224 void validateCoordinateSynthesis() const;
1225
1231 double validateEffectiveCutoff(double eff_cut_in, ExceptionResponse policy_in) const;
1232
1240 void validateAtomIndex(int system_index, int atom_index, const char* caller) const;
1241
1247 void computeFixedPrecisionModel(const std::vector<double> &invu_samples);
1248
1258 void tallyCellPopulations(std::vector<int> *cell_populations, int system_index, int na, int nb,
1259 int nc);
1260
1266 void populateImage(CoordinateCycle cyc);
1267
1270 void rebaseRulers();
1271
1273 void allocateRulers();
1274
1276 void drawNeighborListRulers();
1277
1299 void prepareWorkGroups();
1300};
1301
1302template <typename T, typename Tacc, typename Tcalc, typename T4>
1303void migrate(CellGridWriter<T, Tacc, Tcalc, T4> *cgw, const PsSynthesisReader &destr,
1304 const HybridTargetLevel tier = HybridTargetLevel::HOST,
1305 const GpuDetails &gpu = null_gpu);
1306
1325template <typename Tsrc, typename Tcalc, typename Tcalc2>
1326Tcalc sourceMagnitude(NonbondedTheme requested_property, NonbondedTheme cg_content, Tsrc q,
1327 bool q_is_real, int sysid, const SyNonbondedKit<Tcalc, Tcalc2> &synbk);
1328
1333template <typename Tsrc>
1334int sourceIndex(NonbondedTheme requested_property, NonbondedTheme cg_content, Tsrc q,
1335 bool q_is_real);
1336
1342template <typename T, typename Tacc, typename Tcalc, typename T4>
1344
1345template <typename T, typename Tacc, typename Tcalc, typename T4>
1347
1348template <typename T, typename Tacc, typename Tcalc, typename T4>
1350restoreType(const CellGridReader<void, void, void, void> *rasa);
1351
1352template <typename T, typename Tacc, typename Tcalc, typename T4>
1354restoreType(const CellGridReader<void, void, void, void> &rasa);
1356
1372template <typename T, typename Tacc, typename Tcalc, typename T4>
1373void contributeCellGridForces(PsSynthesisWriter *destw,
1375
1376void contributeCellGridForces(PsSynthesisWriter *destw,
1377 const CellGridReader<void, void, void, void> &cgr_v, size_t tc_mat,
1378 size_t tc_acc,
1379 const HybridTargetLevel tier = HybridTargetLevel::HOST,
1380 const GpuDetails &gpu = null_gpu);
1382
1412template <typename T>
1413int3 locateDecompositionCell(T *x, T *y, T *z, const double* umat, const double* invu,
1414 double cell_na, double cell_nb, double cell_nc,
1415 UnitCellType unit_cell = UnitCellType::TRICLINIC, double scale = 1.0);
1416
1417template <typename T>
1418void locateDecompositionCell(T* x, T* y, T* z, int* cell_idx, int natom, const double* umat,
1419 const double* invu, int cell_na, int cell_nb, int cell_nc,
1420 UnitCellType unit_cell = UnitCellType::TRICLINIC, double scale = 1.0);
1421
1422template <typename T>
1423void locateDecompositionCell(std::vector<T> *x, std::vector<T> *y, std::vector<T> *z,
1424 std::vector<int> *cell_idx, const double* umat, const double* invu,
1425 int cell_na, int cell_nb, int cell_nc,
1426 UnitCellType unit_cell = UnitCellType::TRICLINIC, double scale = 1.0);
1427
1428template <typename T>
1429void locateDecompositionCell(Hybrid<T> *x, Hybrid<T> *y, Hybrid<T> *z, Hybrid<int> *cell_idx,
1430 const double* umat, const double* invu, int cell_na, int cell_nb,
1431 int cell_nc, UnitCellType unit_cell = UnitCellType::TRICLINIC,
1432 double scale = 1.0);
1434
1443double computeMigrationRate(double effective_cutoff, double sigma);
1444
1457int3 optimizeCellConfiguration(int cell_na, int cell_nb, int cell_nc, int subdivisions);
1458
1475void loadRuler(int cell_count, const int95_t cell_len, const int95_t box_len, int remainder,
1476 llint* ruler, int* ruler_ovrf);
1477
1478#ifdef STORMM_USE_HPC
1491cudaFuncAttributes queryMigrationKernelRequirements(PrecisionModel coord_prec,
1492 NeighborListKind neighbor_list, int stage,
1493 int gpos_bits);
1494
1518void launchMigration(CellGridWriter<double, llint, double, double4> *cgw,
1519 const CellOriginsReader &corg, const PsSynthesisReader &poly_psr,
1520 const int2 bt_i, const int2 bt_ii);
1521
1522void launchMigration(CellGridWriter<double, llint, double, double4> *cgw_qq,
1524 const CellOriginsReader &corg_qq, const CellOriginsReader &corg_lj,
1525 const PsSynthesisReader &poly_psr, const int2 bt_i, const int2 bt_ii);
1526
1527void launchMigration(CellGridWriter<float, int, float, float4> *cgw,
1528 const CellOriginsReader &corg, const PsSynthesisReader &poly_psr,
1529 const int2 bt_i, const int2 bt_ii);
1530
1531void launchMigration(CellGridWriter<float, int, float, float4> *cgw_qq,
1533 const CellOriginsReader &corg_qq, const CellOriginsReader &corg_lj,
1534 const PsSynthesisReader &poly_psr, const int2 bt_i, const int2 bt_ii);
1535
1536void launchMigration(CellGrid<double, llint, double, double4> *cg,
1537 const PhaseSpaceSynthesis &poly_ps, const CoreKlManager &launcher);
1538
1539void launchMigration(CellGrid<double, llint, double, double4> *cg_qq,
1541 const PhaseSpaceSynthesis &poly_ps, const CoreKlManager &launcher);
1542
1543void launchMigration(CellGrid<float, int, float, float4> *cg,
1544 const PhaseSpaceSynthesis &poly_ps, const CoreKlManager &launcher);
1545
1546void launchMigration(CellGrid<float, int, float, float4> *cg_qq,
1548 const PhaseSpaceSynthesis &poly_ps, const CoreKlManager &launcher);
1550
1572void launchCellGridAction(CellGridWriter<void, void, void, void> *cgw, size_t tc_mat,
1573 size_t tc_acc, const GpuDetails &gpu, CellGridAction process);
1574
1575void launchCellGridAction(CellGridWriter<void, void, void, void> *cgw, size_t tc_mat,
1576 size_t tc_acc, const PsSynthesisReader &poly_psr, const GpuDetails &gpu,
1577 CellGridAction process);
1578
1579void launchCellGridAction(const CellGridReader<void, void, void, void> &cgr, size_t tc_mat,
1580 size_t tc_acc, PsSynthesisWriter *poly_psw, const GpuDetails &gpu,
1581 CellGridAction process);
1583
1584#endif // STORMM_USE_HPC
1585
1586} // namespace energy
1587} // namespace stormm
1588
1589#include "cellgrid.tpp"
1590
1591#endif
A class to guide the implementation of GPU kernels, with selected thread counts per block and block c...
Definition core_kernel_manager.h:56
Pertinent aspects of one particular GPU. Condensing the data for each GPU in this manner helps to ens...
Definition gpu_details.h:27
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
An object to manage the spatial decomposition of a system of particles. The general strategy is to ar...
Definition cellgrid.h:562
double getCutoff() const
Get the particle-particle cutoff defining the neighbor list.
int getSystemCount() const
Get the number of systems in the object.
int getTotalCellCount() const
Get the total number of cells allocated in the object.
CellGridWriter< T, Tacc, Tcalc, T4 > data(CoordinateCycle orientation, HybridTargetLevel tier=HybridTargetLevel::HOST)
Obtain the object's abstract in order to access its members in C-programming fashion,...
int getCellCount(int index) const
Get the number of cells allotted to any one system.
const CellOriginsReader getRulers(CoordinateCycle orientation, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Obtain the object's rulers for determining the origins of each neighbor list cell in terms of the fix...
void updatePositions(PhaseSpaceSynthesis *dest, HybridTargetLevel tier, const GpuDetails &gpu)
Update the positions and cells of residence for all particles based on the current positions in the a...
void markImageRelevance(HybridTargetLevel tier=HybridTargetLevel::HOST, const GpuDetails &gpu=null_gpu)
Compute whether various atoms may be within range of the tower when they are in the plate of various ...
const PhaseSpaceSynthesis * getCoordinateSynthesisPointer() const
Get a const pointer to the coordinate synthesis served by this object.
TinyBoxPresence getTinyBoxPresence() const
Get the presence of a tiny unit cell anywhere in the synthesis.
void updateCyclePosition()
Update the object's cycle position as it participates in the WHITE:BLACK tick-tock mechanics of other...
CellGrid(const PhaseSpaceSynthesis *poly_ps_ptr_in, const AtomGraphSynthesis *poly_ag_ptr_in, double cutoff_in, double padding_in, int mesh_subdivisions_in, NonbondedTheme theme_in, uint cell_base_capacity_in=default_cellgrid_base_capacity, ExceptionResponse policy_in=ExceptionResponse::WARN)
The constructor accepts an associated PhaseSpaceSynthesis object and a precision model....
void contributeForces(PhaseSpaceSynthesis *dest, HybridTargetLevel tier, const GpuDetails &gpu) const
Contribute forces accumulated in the cell grid back to a coordinate synthesis with its own force accu...
int getPositionScalingBits() const
Get the number of bits in the fixed-precision format.
int2 getChainLocation(int system_index, int atom_index, CoordinateCycle orientation) const
Get the chain index of an atom based on its system and topological atom index. The chain index is ret...
uint getCellBaseCapacity() const
Get the base capacity of any particular cell in the grid. All systems' cells share the same base capa...
const AtomGraphSynthesis * getTopologySynthesisPointer() const
Get a const pointer to the topology synthesis served by this object.
void initializeForces(HybridTargetLevel tier=HybridTargetLevel::HOST, const GpuDetails &gpu=null_gpu)
Initialize forces for the cell grid, on the CPU host or GPU device. This standalone feature provides ...
uint getImageIndex(int system_index, int atom_index, CoordinateCycle orientation) const
Find the image location of an atom based on its system and topological atom number.
int4 getCellLocation(int system_index, int atom_index, CoordinateCycle orientation) const
Find the cell grid location of an atom based on its system and topological atom number....
CellGridWriter< void, void, void, void > templateFreeData(CoordinateCycle orientation, HybridTargetLevel tier=HybridTargetLevel::HOST)
Obtain the object's abstract with templating removed. Overloading and descriptions of parameters foll...
const PsSynthesisBorders getUnitCellTransforms(CoordinateCycle orientation, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get a miniature abstract of the underlying coordinate synthesis containing pointers to the arays of u...
CoordinateCycle getCyclePosition() const
Get the position in the time cycle.
const CellGrid< T, Tacc, Tcalc, T4 > * getSelfPointer() const
Get a pointer to the object itself, useful if the object is only available by const reference.
double getPadding() const
Get the padding incorporated into each neighbor list cell.
double getEffectiveCutoff() const
Get the effective cutoff.
CellGrid(const CellGrid &original)
The presence of POINTER-kind Hybrid objects in the cell origin rulers invalidates the default copy an...
NonbondedTheme getTheme() const
Get the non-bonded theme of this cell grid–does it hold atoms with only electrostatic or van-der Waal...
int getMeshSubdivisions() const
Get the number of mesh elements spanning each spatial decomposition cell. The "mesh" refers to a part...
A collection of one or more AtomGraph objects, with similar components arranged in contiguous arrays ...
Definition atomgraph_synthesis.h:55
A fixed-precision representation of coordinates, velocities, and forces to manage a set of simulation...
Definition phasespace_synthesis.h:325
Definition stormm_vector_types.h:22
Definition stormm_vector_types.h:27
Definition stormm_vector_types.h:33
A mixed tuple for 95-bit integer accumulation. This is the proper way to take double-precision floati...
Definition stormm_vector_types.h:265
Definition stormm_vector_types.h:40
Read-only abstract for the CellGrid object. This is unused in typical MD applications,...
Definition cellgrid.h:296
const T4 * image
The array of atom coordinates and property information.
Definition cellgrid.h:387
CellGridReader(NonbondedTheme theme_in, int system_count_in, int total_cell_count_in, int total_chain_count_in, int mesh_ticks_in, uint cell_base_capacity_in, float lpos_scale_in, float inv_lpos_scale_in, float inv_frc_scale_in, const ullint *system_cell_grids_in, const Tcalc *system_cell_umat_in, const T *system_cell_invu_in, const T *system_pmig_invu_in, const uint2 *cell_limits_in, const uint *chain_limits_in, const int *system_chain_bounds_in, const int *chain_system_owner_in, const T4 *image_in, const int *nonimg_atom_idx_in, const uint *img_atom_idx_in, const ushort *img_atom_chn_cell_in, const int *nt_groups_in, const ushort *relevance_in, const Tacc *xfrc_in, const Tacc *yfrc_in, const Tacc *zfrc_in, const int *xfrc_ovrf_in, const int *yfrc_ovrf_in, const int *zfrc_ovrf_in)
As is other abstracts, the constructor takes a list of inputs for all member variables.
const Tcalc * system_cell_umat
Definition cellgrid.h:351
const int * xfrc_ovrf
Overflow bits for xfrc.
Definition cellgrid.h:415
const int total_cell_count
The total number of decomposition cells across all systems.
Definition cellgrid.h:329
const float lpos_scale
Definition cellgrid.h:341
const float inv_frc_scale
Definition cellgrid.h:347
CellGridReader(const CellGridReader &original)=default
The const-ness of all members implicitly deletes the copy and move assignment operators,...
const int * system_chain_bounds
Definition cellgrid.h:377
const int * yfrc_ovrf
Overflow bits for yfrc.
Definition cellgrid.h:416
const Tacc * xfrc
Accumulated Cartesian X forces on all imaged particles.
Definition cellgrid.h:412
const int twice_cell_count
Twice the number of decomposition cells across all systems.
Definition cellgrid.h:330
const ushort * relevance
Definition cellgrid.h:408
const T * system_cell_invu
Definition cellgrid.h:354
const int * nonimg_atom_idx
Definition cellgrid.h:388
const Tacc * zfrc
Accumulated Cartesian Z forces on all imaged particles.
Definition cellgrid.h:414
const ushort * img_atom_chn_cell
Definition cellgrid.h:400
const float inv_lpos_scale
Definition cellgrid.h:345
const Tacc * yfrc
Accumulated Cartesian Y forces on all imaged particles.
Definition cellgrid.h:413
const uint2 * cell_limits
Definition cellgrid.h:360
const uint cell_base_capacity
Definition cellgrid.h:337
const int * nt_groups
Definition cellgrid.h:403
const ullint * system_cell_grids
Definition cellgrid.h:349
const uint * img_atom_idx
Definition cellgrid.h:395
const int mesh_ticks
Definition cellgrid.h:334
const NonbondedTheme theme
Definition cellgrid.h:326
const int * zfrc_ovrf
Overflow bits for zfrc.
Definition cellgrid.h:417
const int system_count
Number of systems whose spatial decompositions are stored.
Definition cellgrid.h:328
const uint * chain_limits
Definition cellgrid.h:371
const T * system_pmig_invu
Definition cellgrid.h:357
const int * chain_system_owner
Definition cellgrid.h:384
const int total_chain_count
Definition cellgrid.h:331
Writeable abstract for the CellGrid object, able to receive new coordinates or accumulate forces.
Definition cellgrid.h:137
const int * nt_groups
Definition cellgrid.h:273
const NonbondedTheme theme
Definition cellgrid.h:162
T * system_pmig_invu
Definition cellgrid.h:194
CellGridWriter(const CellGridWriter &original)=default
The presence of const array sizing members implicitly deletes the copy and move assignment operators,...
Tacc * zfrc
Accumulators for Cartesian Z forces on imaged particles.
Definition cellgrid.h:284
CellGridWriter(NonbondedTheme theme_in, int system_count_in, int total_cell_count_in, int total_chain_count_in, int mesh_ticks_in, uint cell_base_capacity_in, float lpos_scale_in, float inv_lpos_scale_in, float frc_scale_in, const ullint *system_cell_grids_in, Tcalc *system_cell_umat_in, T *system_cell_invu_in, T *system_pmig_invu, uint2 *cell_limits_in, uint2 *cell_limits_alt_in, const uint *chain_limits_in, const int *system_chain_bounds_in, const int *chain_system_owner_in, T4 *image_in, T4 *image_alt_in, uchar *migration_keys_in, int *wander_count_in, int *wander_count_alt_in, uint2 *wanderers_in, int *nonimg_atom_idx_in, int *nonimg_atom_idx_alt_in, uint *img_atom_idx_in, uint *img_atom_idx_alt_in, ushort *img_atom_chn_cell_in, ushort *img_atom_chn_cell_alt_in, const int *nt_groups_in, ushort *relevance_in, Tacc *xfrc_in, Tacc *yfrc_in, Tacc *zfrc_in, int *xfrc_ovrf_in, int *yfrc_ovrf_in, int *zfrc_ovrf_in)
As is other abstracts, the constructor takes a list of inputs for all member variables.
ushort * img_atom_chn_cell
Definition cellgrid.h:268
const int total_chain_count
Definition cellgrid.h:167
int * zfrc_ovrf
Overflow bits for zfrc.
Definition cellgrid.h:287
ushort * img_atom_chn_cell_alt
Definition cellgrid.h:271
int * wander_count_alt
Definition cellgrid.h:242
uint2 * wanderers
Definition cellgrid.h:247
int * wander_count
Definition cellgrid.h:239
Tacc * yfrc
Accumulators for Cartesian Y forces on imaged particles.
Definition cellgrid.h:283
int * nonimg_atom_idx_alt
Definition cellgrid.h:259
const uint * chain_limits
Definition cellgrid.h:210
const int mesh_ticks
Definition cellgrid.h:170
T4 * image_alt
Definition cellgrid.h:229
Tacc * xfrc
Accumulators for Cartesian X forces on imaged particles.
Definition cellgrid.h:282
uint2 * cell_limits_alt
Definition cellgrid.h:208
const int * system_chain_bounds
Definition cellgrid.h:216
uint * img_atom_idx
Definition cellgrid.h:261
const int total_cell_count
The total number of decomposition cells across all systems.
Definition cellgrid.h:165
const ullint * system_cell_grids
Definition cellgrid.h:185
uchar * migration_keys
Definition cellgrid.h:235
ushort * relevance
Definition cellgrid.h:278
int * xfrc_ovrf
Overflow bits for xfrc.
Definition cellgrid.h:285
int * nonimg_atom_idx
Definition cellgrid.h:252
int * yfrc_ovrf
Overflow bits for yfrc.
Definition cellgrid.h:286
const int twice_cell_count
Twice the number of decomposition cells across all systems.
Definition cellgrid.h:166
uint2 * cell_limits
Definition cellgrid.h:197
const int * chain_system_owner
Definition cellgrid.h:223
const int system_count
Number of systems whose spatial decompositions are stored.
Definition cellgrid.h:164
const float inv_lpos_scale
Definition cellgrid.h:181
const float lpos_scale
Definition cellgrid.h:177
uint * img_atom_idx_alt
Definition cellgrid.h:266
Tcalc * system_cell_umat
Definition cellgrid.h:188
T4 * image
Definition cellgrid.h:226
const uint cell_base_capacity
Definition cellgrid.h:173
T * system_cell_invu
Definition cellgrid.h:191
const float frc_scale
Definition cellgrid.h:183
Definition cellgrid.h:459
const int * bx_ovrf
Overflow bits for projection of the unit cell B axis along Cartesian X.
Definition cellgrid.h:496
const llint * by
Projection of the unit cell B axis along Cartesian Y.
Definition cellgrid.h:491
const llint * ax
Definition cellgrid.h:487
const int * cy_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian Y.
Definition cellgrid.h:499
const llint * bx
Projection of the unit cell B axis along Cartesian X.
Definition cellgrid.h:490
const int * cz_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian Z.
Definition cellgrid.h:500
const llint * cz
Projection of the unit cell C axis along Cartesian z.
Definition cellgrid.h:494
const int * ax_ovrf
Overflow bits for projection of the unit cell A axis along Cartesian X.
Definition cellgrid.h:495
const int * cx_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian X.
Definition cellgrid.h:498
const llint * cx
Projection of the unit cell C axis along Cartesian X.
Definition cellgrid.h:492
CellOriginsReader(const CellOriginsReader &original)=default
The presence of the const member "stride" invalidates the copy and move assignment operators....
CellOriginsReader(int stride_in, const llint *ax_in, const int *ax_ovrf_in, const llint *bx_in, const int *bx_ovrf_in, const llint *by_in, const int *by_ovrf_in, const llint *cx_in, const int *cx_ovrf_in, const llint *cy_in, const int *cy_ovrf_in, const llint *cz_in, const int *cz_ovrf_in)
The constructor takes a list of valus for all member variables. As with many other abstracts,...
Definition cellgrid.cpp:20
const int * by_ovrf
Overflow bits for projection of the unit cell B axis along Cartesian Y.
Definition cellgrid.h:497
const llint * cy
Projection of the unit cell C axis along Cartesian Y.
Definition cellgrid.h:493
const int stride
The stride taken between systems in any of the arrays below.
Definition cellgrid.h:486
Definition cellgrid.h:421
CellOriginsWriter(int stride_in, llint *ax_in, int *ax_ovrf_in, llint *bx_in, int *bx_ovrf_in, llint *by_in, int *by_ovrf_in, llint *cx_in, int *cx_ovrf_in, llint *cy_in, int *cy_ovrf_in, llint *cz_in, int *cz_ovrf_in)
The constructor takes a list of valus for all member variables. There is only one sizing constant–all...
Definition cellgrid.cpp:10
llint * bx
Projection of the unit cell B axis along Cartesian X.
Definition cellgrid.h:445
CellOriginsWriter(const CellOriginsWriter &original)=default
The presence of the const member "stride" invalidates the copy and move assignment operators....
const int stride
The stride taken between systems in any of the arrays below.
Definition cellgrid.h:441
llint * ax
Definition cellgrid.h:442
int * cx_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian X.
Definition cellgrid.h:453
int * ax_ovrf
Overflow bits for projection of the unit cell A axis along Cartesian X.
Definition cellgrid.h:450
int * bx_ovrf
Overflow bits for projection of the unit cell B axis along Cartesian X.
Definition cellgrid.h:451
llint * by
Projection of the unit cell B axis along Cartesian Y.
Definition cellgrid.h:446
int * cy_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian Y.
Definition cellgrid.h:454
llint * cx
Projection of the unit cell C axis along Cartesian X.
Definition cellgrid.h:447
llint * cy
Projection of the unit cell C axis along Cartesian Y.
Definition cellgrid.h:448
int * by_ovrf
Overflow bits for projection of the unit cell B axis along Cartesian Y.
Definition cellgrid.h:452
llint * cz
Projection of the unit cell C axis along Cartesian z.
Definition cellgrid.h:449
int * cz_ovrf
Overflow bits for projection of the unit cell C axis along Cartesian Z.
Definition cellgrid.h:455
A read-only abstract for the system demarcations in the object. This information is sometimes critica...
Definition phasespace_synthesis.h:61
The reader for a PhaseSpaceSynthesis object, containing all of the data relevant for propagating dyna...
Definition phasespace_synthesis.h:199
The writer for a PhaseSpaceSynthesis object, containing all of the data relevant for propagating dyna...
Definition phasespace_synthesis.h:87
Collect the critical non-bonded parameters and masking information for work unit-based evaluation of ...
Definition synthesis_abstracts.h:181