2#ifndef STORMM_SPLIT_FIXED_PRECISION_H
3#define STORMM_SPLIT_FIXED_PRECISION_H
8#include "Accelerator/hybrid.h"
9#include "Constants/behavior.h"
10#include "Constants/scaling.h"
11#include "DataTypes/stormm_vector_types.h"
12#include "numeric_enumerators.h"
18using constants::ExceptionResponse;
19using constants::PrecisionModel;
30constexpr llint max_int_accumulation_ll = (1LL << (int_bit_count_int - 1));
31constexpr double max_int_accumulation = max_int_accumulation_ll;
32constexpr float max_int_accumulation_f = max_int_accumulation;
33constexpr double max_llint_accumulation = max_int_accumulation * max_int_accumulation * 2.0;
34constexpr float max_llint_accumulation_f = max_llint_accumulation;
35constexpr int max_short_accumulation = (1 << 15);
42AccumulationMethod translateAccumulationMethod(
const std::string &choice,
43 ExceptionResponse policy);
48std::string getAccumulationMethodName(AccumulationMethod method);
54AccumulationMethod chooseAccumulationMethod(
int frc_bits);
62std::string fixedPrecisionRangeErrorMessage(
int choice,
int min_val,
int max_val);
68void checkGlobalPositionBits(
int choice);
74void checkLocalPositionBits(
int choice);
80void checkVelocityBits(
int choice);
86void checkForceBits(
int choice);
92void checkEnergyBits(
int choice);
99void checkChargeMeshBits(
int choice, PrecisionModel pmodel);
108void checkFPVectorLength(
size_t primary_length,
size_t overflow_length,
const char* caller,
109 const std::string &message = std::string(
""));
133int2 hostFloatToInt63(
const float fval);
135void hostFloatToInt63(
const float fval,
int *primary,
int *overflow);
137void hostFloatToInt63(
const float* fval,
int* primary,
int* overflow,
size_t n_values,
140void hostFloatToInt63(
const float* fval_x,
const float* fval_y,
const float* fval_z,
141 int* primary_x,
int* overflow_x,
int* primary_y,
int* overflow_y,
142 int* primary_z,
int* overflow_z,
size_t n_values,
float scale = 1.0f);
144void hostFloatToInt63(
const std::vector<float> &fval, std::vector<int> *primary,
145 std::vector<int> *overflow,
float scale = 1.0f);
150void hostFloatToInt63(
const std::vector<float> &fval_x,
const std::vector<float> &fval_y,
151 const std::vector<float> &fval_z, std::vector<int> *primary_x,
152 std::vector<int> *overflow_x, std::vector<int> *primary_y,
153 std::vector<int> *overflow_y, std::vector<int> *primary_z,
154 std::vector<int> *overflow_z,
float scale = 1.0f);
161int2 hostLongLongToInt63(
const llint val);
163void hostLongLongToInt63(
const llint val,
int *primary,
int *overflow);
165void hostLongLongToInt63(
const llint* val,
int* primary,
int* overflow,
size_t n_values);
167void hostLongLongToInt63(
const llint* val_x,
const llint* val_y,
const llint* val_z,
168 int* primary_x,
int* overflow_x,
int* primary_y,
int* overflow_y,
169 int* primary_z,
int* overflow_z,
size_t n_values);
171void hostLongLongToInt63(
const std::vector<llint> &val, std::vector<int> *primary,
172 std::vector<int> *overflow);
174void hostLongLongToInt63(
const std::vector<llint> &val_x,
const std::vector<llint> &val_y,
175 const std::vector<llint> &val_z, std::vector<int> *primary_x,
176 std::vector<int> *overflow_x, std::vector<int> *primary_y,
177 std::vector<int> *overflow_y, std::vector<int> *primary_z,
178 std::vector<int> *overflow_z);
187int2 hostDoubleToInt63(
const double fval);
189void hostDoubleToInt63(
const double fval,
int *primary,
int *overflow);
191int95_t hostDoubleToInt95(
const double fval);
193void hostDoubleToInt95(
const double fval, llint *primary,
int *overflow);
195void hostDoubleToInt95(
const double* dval, llint* primary,
int* overflow,
size_t n_values,
198void hostDoubleToInt95(
const std::vector<double> &dval, std::vector<llint> *primary,
199 std::vector<int> *overflow,
double scale = 1.0);
204void hostDoubleToInt95(
const double* dval_x,
const double* dval_y,
const double* dval_z,
205 llint* primary_x,
int* overflow_x, llint* primary_y,
int* overflow_y,
206 llint* primary_z,
int* overflow_z,
size_t n_values,
double scale = 1.0);
208void hostDoubleToInt95(
const std::vector<double> &dval_x,
const std::vector<double> &dval_y,
209 const std::vector<double> &dval_z, std::vector<llint> *primary_x,
210 std::vector<int> *overflow_x, std::vector<llint> *primary_y,
211 std::vector<int> *overflow_y, std::vector<llint> *primary_z,
212 std::vector<int> *overflow_z,
double scale = 1.0);
240llint hostInt63ToLongLong(
int primary,
int overflow);
242void hostInt63ToLongLong(llint* result,
const int* primary,
const int* overflow,
size_t n_values);
244void hostInt63ToLongLong(std::vector<llint> *result,
const std::vector<int> &primary,
245 const std::vector<int> &overflow,
size_t n_values);
250void hostInt63ToLongLong(llint* result_x, llint* result_y, llint* result_z,
const int* primary_x,
251 const int* overflow_x,
const int* primary_y,
const int* overflow_y,
252 const int* primary_z,
const int* overflow_z,
size_t n_values);
254void hostInt63ToLongLong(std::vector<llint> *result_x, std::vector<llint> *result_y,
255 std::vector<llint> *result_z,
const std::vector<int> &primary_x,
256 const std::vector<int> &overflow_x,
const std::vector<int> &primary_y,
257 const std::vector<int> &overflow_y,
const std::vector<int> &primary_z,
258 const std::vector<int> &overflow_z,
size_t n_values);
266double hostInt63ToDouble(
int primary,
int overflow);
268void hostInt63ToDouble(
double* result,
const int* primary,
const int* overflow,
size_t n_values,
269 double descale = 1.0);
271void hostInt63ToDouble(std::vector<double> *result,
const std::vector<int> &primary,
272 const std::vector<int> &overflow,
double descale = 1.0);
275 const Hybrid<int> &overflow,
double descale = 1.0);
277float hostInt63ToFloat(
int primary,
int overflow);
279void hostInt63ToFloat(
float* result,
const int* primary,
const int* overflow,
size_t n_values,
280 float descale = 1.0f);
282void hostInt63ToFloat(std::vector<float> *result,
const std::vector<int> &primary,
283 const std::vector<int> &overflow,
float descale = 1.0f);
286 const Hybrid<int> &overflow,
float descale = 1.0f);
288void hostInt63ToDouble(
double* result_x,
double* result_y,
double* result_z,
const int* primary_x,
289 const int* overflow_x,
const int* primary_y,
const int* overflow_y,
290 const int* primary_z,
const int* overflow_z,
size_t n_values,
291 double descale = 1.0);
293void hostInt63ToDouble(std::vector<double> *result_x, std::vector<double> *result_y,
294 std::vector<double> *result_z,
const std::vector<int> &primary_x,
295 const std::vector<int> &overflow_x,
const std::vector<int> &primary_y,
296 const std::vector<int> &overflow_y,
const std::vector<int> &primary_z,
297 const std::vector<int> &overflow_z,
size_t n_values,
double descale = 1.0);
303 const Hybrid<int> &overflow_z,
size_t n_values,
double descale = 1.0);
305void hostInt63ToFloat(
float* result_x,
float* result_y,
float* result_z,
const int* primary_x,
306 const int* overflow_x,
const int* primary_y,
const int* overflow_y,
307 const int* primary_z,
const int* overflow_z,
size_t n_values,
308 float descale = 1.0f);
310void hostInt63ToFloat(std::vector<float> *result_x, std::vector<float> *result_y,
311 std::vector<float> *result_z,
const std::vector<int> &primary_x,
312 const std::vector<int> &overflow_x,
const std::vector<int> &primary_y,
313 const std::vector<int> &overflow_y,
const std::vector<int> &primary_z,
314 const std::vector<int> &overflow_z,
float descale = 1.0f);
320 float descale = 1.0f);
322double hostInt63ToDouble(int2 ival);
324float hostInt63ToFloat(int2 ival);
326double hostInt95ToDouble(
const int95_t ival);
328double hostInt95ToDouble(llint primary,
int overflow);
330void hostInt95ToDouble(
double* result,
const llint* primary,
const int* overflow,
size_t n_values,
331 double descale = 1.0);
333void hostInt95ToDouble(std::vector<double> *result,
const std::vector<llint> &primary,
334 const std::vector<int> &overflow,
double descale = 1.0);
337 const Hybrid<int> &overflow,
double descale = 1.0);
339void hostInt95ToDouble(
double* result_x,
double* result_y,
double* result_z,
340 const llint* primary_x,
const int* overflow_x,
const llint* primary_y,
341 const int* overflow_y,
const llint* primary_z,
const int* overflow_z,
342 size_t n_values,
double descale = 1.0);
344void hostInt95ToDouble(std::vector<double> *result_x, std::vector<double> *result_y,
345 std::vector<double> *result_z,
const std::vector<llint> &primary_x,
346 const std::vector<int> &overflow_x,
const std::vector<llint> &primary_y,
347 const std::vector<int> &overflow_y,
const std::vector<llint> &primary_z,
348 const std::vector<int> &overflow_z,
double descale = 1.0);
354 const Hybrid<int> &overflow_z,
double descale = 1.0);
356double hostSplitFPToReal(
const int95_t isfp);
358float hostSplitFPToReal(
const int2 isfp);
361double hostSplitFPToReal(
const int95_t isfp);
363float hostSplitFPToReal(
const int2 isfp);
378void hostSplitAccumulation(
const float fval,
int *primary,
int *overflow);
380void hostSplitAccumulation(
const double fval, llint *primary,
int *overflow);
408int95_t hostSplitFPSum(
const int95_t a,
const int95_t b);
410int2 hostSplitFPSum(
const int2 a,
const int2 b);
412int95_t hostSplitFPSum(
const int95_t a,
double breal);
414int2 hostSplitFPSum(
const int2 a,
float breal);
416int95_t hostSplitFPSum(
const int95_t a, llint b_x,
int b_y);
418int2 hostSplitFPSum(
const int2 a,
int b_x,
int b_y);
420template <
typename T>
void hostSplitFPSum(T *a_x,
int *a_y,
const int95_t b);
422template <
typename T>
void hostSplitFPSum(T *a_x,
int *a_y,
const int2 b);
424int95_t hostInt95Sum(llint a_x,
int a_y, llint b_x,
int b_y);
426int2 hostInt63Sum(
int a_x,
int a_y,
int b_x,
int b_y);
428int95_t hostInt95Sum(llint a_x,
int a_y,
double breal);
430int2 hostInt63Sum(
int a_x,
int a_y,
float breal);
438int95_t hostSplitFPSubtract(
const int95_t a,
const int95_t b);
440int2 hostSplitFPSubtract(
const int2 a,
const int2 b);
442int95_t hostSplitFPSubtract(
const int95_t a,
double breal);
444int2 hostSplitFPSubtract(
const int2 a,
float breal);
446int95_t hostSplitFPSubtract(
const int95_t a, llint b_x,
int b_y);
448int2 hostSplitFPSubtract(
const int2 a,
int b_x,
int b_y);
450template <
typename T>
void hostSplitFPSubtract(T *a_x,
int *a_y,
const int95_t b);
452template <
typename T>
void hostSplitFPSubtract(T *a_x,
int *a_y,
const int2 b);
454int95_t hostInt95Subtract(llint a_x,
int a_y, llint b_x,
int b_y);
456int2 hostInt63Subtract(
int a_x,
int a_y,
int b_x,
int b_y);
458int95_t hostInt95Subtract(llint a_x,
int a_y,
double breal);
460int2 hostInt63Subtract(
int a_x,
int a_y,
float breal);
472int95_t hostSplitFPMult(
const int95_t a,
int b);
474int95_t hostInt95Mult(llint a_x,
int a_y,
int b);
476int2 hostSplitFPMult(
const int2 a,
int b);
478int2 hostInt63Mult(
int a_x,
int a_y,
int b);
497int2 hostChangeFPBits(
const int2 fp,
int native_bits,
int output_bits);
499int95_t hostChangeFPBits(
const int95_t fp,
int native_bits,
int output_bits);
501void hostChangeFPBits(std::vector<int95_t> *fp,
int native_bits,
int output_bits);
503void hostChangeFPBits(
int* fp,
int* fp_ovrf,
size_t length,
int native_bits,
int output_bits);
505void hostChangeFPBits(llint* fp,
int* fp_ovrf,
size_t length,
int native_bits,
int output_bits);
507void hostChangeFPBits(std::vector<int> *fp, std::vector<int> *fp_ovrf,
int native_bits,
510void hostChangeFPBits(std::vector<llint> *fp, std::vector<int> *fp_ovrf,
int native_bits,
535void fixedPrecisionGrid(std::vector<int95_t> *coordinates,
const int95_t origin,
536 const int95_t increment);
538void fixedPrecisionGrid(std::vector<llint> *primary, std::vector<int> *overflow,
539 const int95_t origin,
const int95_t increment);
542 const int95_t increment);
544void fixedPrecisionGrid(llint *primary,
int *overflow,
const int95_t origin,
545 const int95_t increment,
const size_t grid_size);
551int95_t operator+=(
const int95_t lhs,
const int95_t rhs);
552int95_t operator-=(
const int95_t lhs,
const int95_t rhs);
553int95_t operator+(
const int95_t lhs,
const int95_t rhs);
554int95_t operator-(
const int95_t lhs,
const int95_t rhs);
560#include "split_fixed_precision.tpp"
564 using numerics::hostFloatToInt63;
565 using numerics::hostDoubleToInt95;
566 using numerics::hostInt63ToDouble;
567 using numerics::hostInt63ToFloat;
568 using numerics::hostInt95ToDouble;
569 using numerics::hostSplitAccumulation;
570 using numerics::hostSplitFPSubtract;
571 using numerics::hostSplitFPSum;
572 using numerics::hostSplitFPToReal;
573 using numerics::hostInt95Subtract;
574 using numerics::hostInt95Sum;
575 using numerics::hostInt63Subtract;
576 using numerics::hostInt63Sum;
577 using numerics::operator+=;
578 using numerics::operator-=;
579 using numerics::operator+;
580 using numerics::operator-;
581 using numerics::max_int_accumulation;
582 using numerics::max_int_accumulation_f;
583 using numerics::max_int_accumulation_ll;
584 using numerics::max_llint_accumulation;
585 using numerics::max_llint_accumulation_f;
586 using numerics::max_short_accumulation;
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202