VTK-m  2.0
ZFP1DDecompress.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_worklet_zfp_1d_decompressor_h
11 #define vtk_m_worklet_zfp_1d_decompressor_h
12 
13 #include <vtkm/Math.h>
14 #include <vtkm/cont/Algorithm.h>
15 #include <vtkm/cont/ArrayHandle.h>
18 #include <vtkm/cont/AtomicArray.h>
19 #include <vtkm/cont/Timer.h>
23 
24 using ZFPWord = vtkm::UInt64;
25 
26 #include <stdio.h>
27 
28 namespace vtkm
29 {
30 namespace worklet
31 {
32 namespace detail
33 {
34 
35 
36 
37 } // namespace detail
38 
39 
41 {
42 public:
43  template <typename Scalar, typename StorageIn, typename StorageOut>
46  const vtkm::Float64 requestedRate,
47  vtkm::Id dims)
48  {
49  //DataDumpb(data, "uncompressed");
50  zfp::ZFPStream stream;
51  constexpr vtkm::Int32 topoDims = 1;
52  ;
53  stream.SetRate(requestedRate, topoDims, vtkm::Float64());
54 
55 
56  // Check to see if we need to increase the block sizes
57  // in the case where dim[x] is not a multiple of 4
58 
59  vtkm::Id paddedDims = dims;
60  // ensure that we have block sizes
61  // that are a multiple of 4
62  if (paddedDims % 4 != 0)
63  paddedDims += 4 - dims % 4;
64  constexpr vtkm::Id four = 4;
65  vtkm::Id totalBlocks = (paddedDims / four);
66 
67 
68  zfp::detail::CalcMem1d(paddedDims, stream.minbits);
69 
70  // hopefully this inits/allocates the mem only on the device
71  output.Allocate(dims);
72 
73  // launch 1 thread per zfp block
74  vtkm::cont::ArrayHandleCounting<vtkm::Id> blockCounter(0, 1, totalBlocks);
75 
76  // using Timer = vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial>;
77  // Timer timer;
79  zfp::Decode1(dims, paddedDims, stream.maxbits));
80  decompressDispatcher.Invoke(blockCounter, output, encodedData);
81 
82  // vtkm::Float64 time = timer.GetElapsedTime();
83  // size_t total_bytes = output.GetNumberOfValues() * sizeof(vtkm::Float64);
84  // vtkm::Float64 gB = vtkm::Float64(total_bytes) / (1024. * 1024. * 1024.);
85  // vtkm::Float64 rate = gB / time;
86  // std::cout<<"Decompress time "<<time<<" sec\n";
87  // std::cout<<"Decompress rate "<<rate<<" GB / sec\n";
88  // DataDump(output, "decompressed");
89  }
90 };
91 } // namespace worklet
92 } // namespace vtkm
93 #endif // vtk_m_worklet_zfp_1d_decompressor_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm::worklet::zfp::ZFPStream::SetRate
vtkm::Float64 SetRate(const vtkm::Float64 rate, const vtkm::Int32 dims, T vtkmNotUsed(valueType))
Definition: ZFPStructs.h:36
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
ArrayHandleConstant.h
vtkm::worklet::ZFP1DDecompressor
Definition: ZFP1DDecompress.h:40
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
ZFPTools.h
vtkm::worklet::ZFP1DDecompressor::Decompress
void Decompress(const vtkm::cont::ArrayHandle< vtkm::Int64, StorageIn > &encodedData, vtkm::cont::ArrayHandle< Scalar, StorageOut > &output, const vtkm::Float64 requestedRate, vtkm::Id dims)
Definition: ZFP1DDecompress.h:44
DispatcherMapField.h
vtkm::worklet::zfp::ZFPStream::minbits
vtkm::UInt32 minbits
Definition: ZFPStructs.h:30
vtkm::worklet::zfp::Decode1
Definition: ZFPDecode1.h:52
vtkm::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
Math.h
Timer.h
Algorithm.h
vtkm::cont::ArrayHandleCounting< vtkm::Id >
vtkm::worklet::zfp::ZFPStream::maxbits
vtkm::UInt32 maxbits
Definition: ZFPStructs.h:31
ArrayHandleCounting.h
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::Float64
double Float64
Definition: Types.h:155
ZFPDecode1.h
vtkm::worklet::zfp::ZFPStream
Definition: ZFPStructs.h:28
ZFPWord
vtkm::UInt64 ZFPWord
Definition: ZFPTools.h:24
AtomicArray.h