2#ifndef STORMM_PMEGRID_H
3#define STORMM_PMEGRID_H
7#include "Accelerator/gpu_details.h"
8#include "Accelerator/hybrid.h"
9#include "Constants/behavior.h"
10#include "Constants/hpc_bounds.h"
11#include "DataTypes/stormm_vector_types.h"
12#include "Math/math_enumerators.h"
13#include "Numerics/split_fixed_precision.h"
14#include "Synthesis/phasespace_synthesis.h"
20using card::GpuDetails;
22using card::HybridKind;
23using card::HybridTargetLevel;
24using constants::CartesianDimension;
25using constants::PrecisionModel;
26using constants::UnitCellAxis;
28using synthesis::PhaseSpaceSynthesis;
32constexpr int minimum_qspread_fp_bits = 24;
33constexpr int minimum_ljspread_fp_bits = 24;
34constexpr int maximum_qspread_fp_bits_sp = 56;
35constexpr int maximum_qspread_fp_bits_dp = 88;
36constexpr int default_qspread_fp_bits_sp = 32;
37constexpr int default_qspread_fp_bits_dp = 64;
38constexpr int maximum_ljspread_fp_bits_sp = 50;
39constexpr int maximum_ljspread_fp_bits_dp = 82;
40constexpr int default_ljspread_fp_bits_sp = 24;
41constexpr int default_ljspread_fp_bits_dp = 56;
42constexpr int mapping_nonoverflow_bits_dp = 61;
43constexpr int mapping_nonoverflow_bits_sp = 29;
44constexpr int default_bspline_order = 5;
45constexpr int density_mapping_wu_size = 32;
58constexpr int max_shared_acc_atom_bearing_region_adim = 28;
60constexpr int max_shared_acc_atom_bearing_region_adim = 9;
62constexpr int max4s_grid_mapping_volume = 48;
63constexpr int max4s_atom_bearing_region_adim = 7;
64constexpr int max4s_atom_bearing_cross_section = 16;
65constexpr int max5s_grid_mapping_volume = 48;
66constexpr int max5s_atom_bearing_region_adim = 7;
67constexpr int max5s_atom_bearing_cross_section = 16;
68constexpr int max6s_grid_mapping_volume = 48;
69constexpr int max6s_atom_bearing_region_adim = 4;
70constexpr int max6s_atom_bearing_cross_section = 12;
77 PMIGridWriter(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in,
int fp_bits_in,
78 int nsys_in,
int order_in,
int wu_count_in,
int max_grid_points_in,
79 const uint4* dims_in,
double* ddata_in,
float* fdata_in,
80 const uint* work_units_in);
121 PMIGridReader(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in,
int fp_bits_in,
122 int nsys_in,
int order_in,
const uint4* dims_in,
const double* ddata_in,
123 const float* fdata_in);
168 bool use_overflow_in,
int fp_bits_in,
int nsys_in,
int order_in,
169 int wu_count_in,
const uint4* dims_in,
double* ddata_in,
float* fdata_in,
170 int* overflow_in,
const uint* work_units_in);
221 PMIGridFPReader(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in,
222 bool use_overflow_in,
int fp_bits_in,
int nsys_in,
int order_in,
223 const uint4* dims_in,
const double* ddata_in,
const float* fdata_in,
224 const int* overflow_in);
277 template <
typename T,
typename Tacc,
typename Tcalc,
typename T4>
279 int b_spline_order_in = default_bspline_order,
280 PrecisionModel mode_in = PrecisionModel::SINGLE,
281 FFTMode fft_staging_in = FFTMode::IN_PLACE,
int fp_accumulation_bits_in = 0,
282 int shared_fp_accumulation_bits_in = -1,
const GpuDetails &gpu = null_gpu,
283 const QMapMethod work_unit_configuration_in = QMapMethod::GENERAL_PURPOSE);
285 template <
typename T,
typename Tacc,
typename Tcalc,
typename T4>
287 int b_spline_order_in = default_bspline_order,
288 PrecisionModel mode_in = PrecisionModel::SINGLE,
289 FFTMode fft_staging_in = FFTMode::IN_PLACE,
int fp_accumulation_bits_in = 0,
290 int shared_fp_accumulation_bits_in = -1,
const GpuDetails &gpu = null_gpu,
291 const QMapMethod work_unit_configuration_in = QMapMethod::GENERAL_PURPOSE);
311 PrecisionModel
getMode()
const;
385 const PMIGridReader data(HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
406 template <
typename T,
typename Tacc,
typename Tcalc,
typename T4>
454 std::vector<double>
getGrid(
int system_index)
const;
477 void setMode(PrecisionModel mode_in);
526 void initialize(HybridTargetLevel tier = HybridTargetLevel::HOST,
536 void convertToReal(HybridTargetLevel tier = HybridTargetLevel::HOST,
542 NonbondedTheme theme;
555 int fp_accumulation_bits;
561 int shared_fp_accumulation_bits;
574 bool use_short_format_accumulation;
586 int shared_acc_buffer_size;
589 QMapMethod recommendation;
593 QMapMethod work_unit_configuration;
609 int largest_work_unit_grid_points;
686 void validateFixedPrecisionBits(
int fp_bits)
const;
691 void validateSystemIndex(
int system_index)
const;
697 int findSharedBufferSize(
const GpuDetails &gpu)
const;
701 int computeMappingHalo()
const;
724 void addWorkUnit(std::vector<uint> *result,
int sysid,
int pos_a,
int pos_b,
int pos_c,
725 int gmap_a,
int gmap_b,
int gmap_c,
734 void checkShortFormatViability();
737 void computeLargestWorkUnitGridPoints();
745 unrollTemplateFreeCGReader(HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
750 template <
typename T,
typename T4>
const AtomGraphSynthesis* unrollCgAgsPtrOne()
const;
754 template <
typename T,
typename Tacc,
typename T4>
792#include "pmigrid.tpp"
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
int getInterpolationOrder() const
Get the interpolation order to be used in mapping particle density to the particle-mesh interaction g...
Definition pmigrid.cpp:156
int getFixedPrecisionBits() const
Get the number of bits used in scaling numbers for fixed precision accumulation.
Definition pmigrid.cpp:141
NonbondedTheme getTheme() const
Get the non-bonded propery mapped onto the particle-mesh interaction grid.
Definition pmigrid.cpp:106
void setMode(PrecisionModel mode_in)
Change the mode in which the object is set to operate. This will leave bounds arrays unchanged but bl...
Definition pmigrid.cpp:605
const AtomGraphSynthesis * getTopologySynthesisPointer() const
Get a pointer to the underlying topology synthesis.
Definition pmigrid.cpp:557
int getSharedFixedPrecisionBits() const
Get the number of bits used in scaling numbers for fixed precision accumulation in shared accumulatio...
Definition pmigrid.cpp:146
void prepareFixedPrecisionModel(int fp_accumulation_bits_in, int shared_fp_bits_in)
Set the object to enable or disable fixed-precision accumulation.
Definition pmigrid.cpp:631
const PMIGrid * getSelfPointer() const
Get a pointer to the PMIGrid object itself.
Definition pmigrid.cpp:580
QMapMethod getRecommendedMappingMethod() const
Get the recommended density mapping method for the current set of grids.
Definition pmigrid.cpp:126
int getWorkUnitCount() const
Get the number of work units used by the optimized kernel.
Definition pmigrid.cpp:199
const CellGrid< T, Tacc, Tcalc, T4 > * getCellGridPointer() const
Get the pointer to the attached CellGrid object, which provides the basis for the grids / meshes cont...
PMIGridWriter data(HybridTargetLevel tier=HybridTargetLevel::HOST)
Get the abstract for this object containing its precision mode, grid dimensions, and pointers to rele...
Definition pmigrid.cpp:219
void convertToReal(HybridTargetLevel tier=HybridTargetLevel::HOST, const GpuDetails &gpu=null_gpu)
Convert fixed-precision integer data in the object to real data. There is no function to convert real...
Definition pmigrid.cpp:933
QMapMethod getWorkUnitConfiguration() const
Get the work unit configuration of the object.
Definition pmigrid.cpp:131
void prepareWorkUnits(QMapMethod approach, const GpuDetails &gpu)
Prepare a set of work units for the synthesis of systems. These work units will be tailored to the sy...
Definition pmigrid.cpp:731
PMIGridAccumulator fpData(HybridTargetLevel tier=HybridTargetLevel::HOST)
Get the fixed-precision abstract for this object, re-interpreting either main data array and adding a...
Definition pmigrid.cpp:242
PMIGrid(const CellGrid< T, Tacc, Tcalc, T4 > *cg_in, NonbondedTheme theme_in, int b_spline_order_in=default_bspline_order, PrecisionModel mode_in=PrecisionModel::SINGLE, FFTMode fft_staging_in=FFTMode::IN_PLACE, int fp_accumulation_bits_in=0, int shared_fp_accumulation_bits_in=-1, const GpuDetails &gpu=null_gpu, const QMapMethod work_unit_configuration_in=QMapMethod::GENERAL_PURPOSE)
The constructor builds the object off of a CellGrid object, which is in turn linked to a particular c...
size_t getCellGridCalculationTypeID() const
Get the type ID of the attached CellGrid object's fractional space coordinate transformations,...
Definition pmigrid.cpp:306
bool useOverflowAccumulation() const
Report whether the PMIGrid will need to use overflow accumulators.
Definition pmigrid.cpp:214
bool dataIsReal() const
Indicate whether the data is present as real numbers or fixed-precision accumulators....
Definition pmigrid.cpp:136
void setRecommendedMappingMethod(const GpuDetails &gpu)
Set the recommended mapping method based on the density of the grid and available resources.
Definition pmigrid.cpp:693
bool fixedPrecisionEnabled() const
Indicate whether fixed-precision accumulation is enabled. This will test whether fp_accumulation_bits...
Definition pmigrid.cpp:121
std::vector< double > getGrid(int system_index) const
Export the particle-mesh interaction grid asssociated with one system in the synthesis....
Definition pmigrid.cpp:439
FFTMode getFFTStaging() const
Get the method for performing real-to-complex and complex-to-real FFTs. This implies how the grid dat...
Definition pmigrid.cpp:116
const PhaseSpaceSynthesis * getCoordinateSynthesisPointer() const
Get a pointer to the underlying coordinate synthesis.
Definition pmigrid.cpp:552
size_t getCellGridMatrixTypeID() const
Get the type ID of the attached CellGrid object's cell dimension matrix expressions....
Definition pmigrid.cpp:296
bool shortFormatAccumulation() const
Report whether the PMIGrid will use short format accumulation.
Definition pmigrid.cpp:209
size_t getCellGridCoordinateTypeID() const
Get the type ID of the attached CellGrid object's coordinate data, a four-tuple of its cell dimension...
Definition pmigrid.cpp:311
PrecisionModel getMode() const
Get the mode in which the object is set to operate.
Definition pmigrid.cpp:111
int getLargestWorkUnitGridPoints() const
Report the number of grid points present in the largest work unit.
Definition pmigrid.cpp:204
int getSystemCount() const
Get the number of systems with grid managed by this object.
Definition pmigrid.cpp:151
size_t getCellGridAccumulatorTypeID() const
Get the type ID of the attached CellGrid object's accumulators. This is "typename Tacc" in vari...
Definition pmigrid.cpp:301
double getTotalOnGrid(int system_index) const
Get the total substance, particle density, mapped to all grid elements for a particular system.
Definition pmigrid.cpp:316
uint4 getGridDimensions(int system_index) const
Obtain the dimensions of one of the grids in the object.
Definition pmigrid.cpp:166
PMIGrid(const PMIGrid &original)=default
The choice to re-cast arrays in the abstracts rather than have special POINTER-kind Hybrid objects in...
void initialize(HybridTargetLevel tier=HybridTargetLevel::HOST, const GpuDetails &gpu=null_gpu)
Initialize the particle-mesh interaction grids, respecting the object's precision and accumulation mo...
Definition pmigrid.cpp:856
void setRealDataFormat(bool real_in=true)
Change the character of the data format. If called with TRUE the object will report holding real-valu...
Definition pmigrid.cpp:626
const CellGridReader< void, void, void, void > getTemplateFreeCellGridReader(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get an abstract of the attached cell grid object, with all templating cast away. This exists because ...
Definition pmigrid.cpp:275
size_t getTotalCapacity() const
Get the total capacity allocated to store grid data.
Definition pmigrid.cpp:161
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:51
Read-only abstract for the CellGrid object. This is unused in typical MD applications,...
Definition cellgrid.h:296
A writeable abstract which reinterprets some pointers to enable split fixed-precision accumulation wi...
Definition pmigrid.h:163
PMIGridAccumulator(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in, bool use_overflow_in, int fp_bits_in, int nsys_in, int order_in, int wu_count_in, const uint4 *dims_in, double *ddata_in, float *fdata_in, int *overflow_in, const uint *work_units_in)
The constructor takes inputs from the object's member variables and re-interprets some of them as nec...
Definition pmigrid.cpp:57
const int order
Definition pmigrid.h:192
const NonbondedTheme theme
Definition pmigrid.h:180
int * overflow
Definition pmigrid.h:208
const float fp_scale
Definition pmigrid.h:188
llint * lldata
Primary accumulator for 95-bit split fixed precision data.
Definition pmigrid.h:206
const uint4 * dims
Definition pmigrid.h:203
const int nsys
Definition pmigrid.h:190
const int wu_count
Definition pmigrid.h:200
const FFTMode fftm
Definition pmigrid.h:183
const uint * work_units
Definition pmigrid.h:211
const PrecisionModel mode
The mode in which the object is to operate.
Definition pmigrid.h:182
const int order_cubed
Definition pmigrid.h:197
const int fp_bits
Definition pmigrid.h:186
const int order_squared
Definition pmigrid.h:194
int * idata
Primary accumulator for 63-bit split fixed precision data.
Definition pmigrid.h:207
PMIGridAccumulator(const PMIGridAccumulator &original)=default
As with other abstracts, the presence of one or more const members forbids definition of the copy and...
const bool use_overflow
Flag to indicate that overflow accumulators must be used.
Definition pmigrid.h:185
A read-only abstract which can interpret the PMIGrid data in split fixed-precision format.
Definition pmigrid.h:217
const int * idata
Primary accumulator for 63-bit split fixed precision data.
Definition pmigrid.h:260
const int nsys
Definition pmigrid.h:252
const PrecisionModel mode
The mode in which the object is to operate.
Definition pmigrid.h:244
const int * overflow
Definition pmigrid.h:261
const bool use_overflow
Flag to indicate that overflow accumulators are relevant.
Definition pmigrid.h:247
const int order
Definition pmigrid.h:254
const float fp_scale
Definition pmigrid.h:250
const uint4 * dims
Definition pmigrid.h:256
PMIGridFPReader(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in, bool use_overflow_in, int fp_bits_in, int nsys_in, int order_in, const uint4 *dims_in, const double *ddata_in, const float *fdata_in, const int *overflow_in)
The constructor takes inputs from the object's member variables and re-interprets some of them as nec...
Definition pmigrid.cpp:77
const NonbondedTheme theme
Definition pmigrid.h:242
const int fp_bits
Definition pmigrid.h:248
const llint * lldata
Primary accumulator for 95-bit split fixed precision data.
Definition pmigrid.h:259
PMIGridFPReader(const PMIGridFPReader &original)=default
As with other abstracts, the presence of one or more const members forbids definition of the copy and...
const FFTMode fftm
Definition pmigrid.h:245
A read-only abstract for the Particle-Mesh Interaction Grid class.
Definition pmigrid.h:118
const float * fdata
Definition pmigrid.h:157
const PrecisionModel mode
The mode in which the object is to operate.
Definition pmigrid.h:143
const NonbondedTheme theme
Definition pmigrid.h:141
const int order
Definition pmigrid.h:150
const double * ddata
Definition pmigrid.h:155
PMIGridReader(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in, int fp_bits_in, int nsys_in, int order_in, const uint4 *dims_in, const double *ddata_in, const float *fdata_in)
The constructor take a straight list of inputs for all member variables.
Definition pmigrid.cpp:35
const int nsys
Definition pmigrid.h:148
const float shacc_fp_scale
Definition pmigrid.h:146
PMIGridReader(const PMIGridReader &original)=default
As with other abstracts, the presence of one or more const members forbids definition of the copy and...
const FFTMode fftm
Definition pmigrid.h:144
const uint4 * dims
Definition pmigrid.h:152
A writeable abstract for the Particle-Mesh Interaction Grid class.
Definition pmigrid.h:74
float * fdata
Definition pmigrid.h:111
const int max_grid_points
Definition pmigrid.h:104
const float shacc_fp_scale
Definition pmigrid.h:95
const NonbondedTheme theme
Definition pmigrid.h:90
const uint * work_units
Definition pmigrid.h:113
const FFTMode fftm
Definition pmigrid.h:93
const uint4 * dims
Definition pmigrid.h:106
double * ddata
Definition pmigrid.h:109
PMIGridWriter(NonbondedTheme theme_in, PrecisionModel mode_in, FFTMode fftm_in, int fp_bits_in, int nsys_in, int order_in, int wu_count_in, int max_grid_points_in, const uint4 *dims_in, double *ddata_in, float *fdata_in, const uint *work_units_in)
The constructor take a straight list of inputs for all member variables.
Definition pmigrid.cpp:23
const int order
Definition pmigrid.h:99
const PrecisionModel mode
The mode in which the object is to operate.
Definition pmigrid.h:92
PMIGridWriter(const PMIGridWriter &original)=default
As with other abstracts, the presence of one or more const members forbids definition of the copy and...
const int wu_count
Definition pmigrid.h:101
const int nsys
Definition pmigrid.h:97