ATLAS Offline Software
Classes | Macros | Typedefs | Functions
test-half-precision.cxx File Reference
#include "HDF5Utils/Writer.h"
#include <random>
Include dependency graph for test-half-precision.cxx:

Go to the source code of this file.

Classes

struct  out_t
 

Macros

#define ADD(NAME)   consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0)
 
#define HADD(NAME)   consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0, h)
 

Typedefs

using consumer_t = H5Utils::Consumers< const out_t & >
 
using mt_t = decltype(std::mt19937())
 

Functions

consumer_t getFullConsumers ()
 
consumer_t getHalfConsumers ()
 
std::vector< out_tgetOutputs (size_t length, mt_t &rand)
 
void fill (H5::Group &out_file, size_t iterations)
 
int main (int nargs, char *argv[])
 

Macro Definition Documentation

◆ ADD

#define ADD (   NAME)    consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0)

Definition at line 20 of file test-half-precision.cxx.

◆ HADD

#define HADD (   NAME)    consumers.add(#NAME, [](const out_t& o){ return o.NAME;}, 0, h)

Definition at line 21 of file test-half-precision.cxx.

Typedef Documentation

◆ consumer_t

Definition at line 17 of file test-half-precision.cxx.

◆ mt_t

using mt_t = decltype(std::mt19937())

Definition at line 42 of file test-half-precision.cxx.

Function Documentation

◆ fill()

void fill ( H5::Group &  out_file,
size_t  iterations 
)

Definition at line 64 of file test-half-precision.cxx.

64  {
65 
66  const int deflate = 7;
67  const int max_width = 10;
68  std::mt19937 random(42);
69 
70  // compare outputs
72  writer_t::configuration_type config;
73  config.name = "full";
74  config.extent = {max_width};
75  config.deflate = deflate;
76  writer_t full(out_file, getFullConsumers(), config);
77  config.name = "half";
78  writer_t half(out_file, getHalfConsumers(), config);
79  std::uniform_int_distribution<int> width(0, max_width+1);
80  for (size_t n = 0; n < iterations; n++) {
81  auto out = getOutputs(width(random), random);
82  full.fill(out);
83  half.fill(out);
84  }
85 }

◆ getFullConsumers()

consumer_t getFullConsumers ( )

Definition at line 23 of file test-half-precision.cxx.

23  {
24  consumer_t consumers;
25  ADD(ftype);
26  ADD(dtype);
27  ADD(btype);
28  return consumers;
29 }

◆ getHalfConsumers()

consumer_t getHalfConsumers ( )

Definition at line 30 of file test-half-precision.cxx.

30  {
31  consumer_t consumers;
33  HADD(ftype);
34  HADD(dtype);
35  ADD(btype);
36  return consumers;
37 }

◆ getOutputs()

std::vector<out_t> getOutputs ( size_t  length,
mt_t rand 
)

Definition at line 44 of file test-half-precision.cxx.

44  {
45  std::vector<out_t> outvec;
46  std::uniform_int_distribution<int> exponent(-10, 2);
47  std::uniform_real_distribution<float> man(-0.0001, 0.0001);
48  std::uniform_int_distribution<short> booldist(0, 1);
49  for (size_t n = 0; n < length; n++) {
50  out_t out;
51  double value = std::exp2(exponent(rand)) * (1 + man(rand));
52  out.dtype = value;
53  out.ftype = value;
54  out.btype = booldist(rand);
55  outvec.push_back(out);
56  }
57  return outvec;
58 }

◆ main()

int main ( int  nargs,
char *  argv[] 
)

Definition at line 87 of file test-half-precision.cxx.

87  {
88  H5::H5File out_file("output.h5", H5F_ACC_TRUNC);
89  size_t iterations = 1;
90  if (nargs > 2) {
91  return 1;
92  }
93  if (nargs > 1) iterations = std::atoi(argv[1]);
94  fill(out_file, iterations);
95  return 0;
96 }
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-half-precision.cxx:64
getHalfConsumers
consumer_t getHalfConsumers()
Definition: test-half-precision.cxx:30
CaloLCW_tf.nargs
nargs
Definition: CaloLCW_tf.py:26
PlotCalibFromCool.dtype
dtype
Definition: PlotCalibFromCool.py:495
python.base_data.config
config
Definition: base_data.py:20
getFullConsumers
consumer_t getFullConsumers()
Definition: test-half-precision.cxx:23
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
athena.value
value
Definition: athena.py:124
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
H5Utils::Compression::HALF_PRECISION
@ HALF_PRECISION
getOutputs
std::vector< out_t > getOutputs(size_t length, mt_t &rand)
Definition: test-half-precision.cxx:44
H5Utils::Writer
Writer.
Definition: Writer.h:349
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
beamspotman.n
n
Definition: beamspotman.py:729
out_t
Definition: test-half-precision.cxx:12
MuonEfficiencyCorrectionsCfg.out_file
out_file
Definition: MuonEfficiencyCorrectionsCfg.py:69
HADD
#define HADD(NAME)
Definition: test-half-precision.cxx:20
find_data.full
full
Definition: find_data.py:26
H5Utils::Consumers
Definition: Writer.h:129
h
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
ADD
#define ADD(NAME)
Definition: test-half-precision.cxx:19
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
H5Utils::defaults::deflate
const int deflate
Definition: defaults.h:10