Unpacker.cuh 1.37 KB
Newer Older
Ewan Barr's avatar
Ewan Barr committed
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_UNPACKER_CUH
#define PSRDADA_CPP_EFFELSBERG_EDD_UNPACKER_CUH

#include "psrdada_cpp/common.hpp"
#include <thrust/device_vector.h>

namespace psrdada_cpp {
namespace effelsberg {
namespace edd {
namespace kernels {

__global__
Ewan Barr's avatar
Ewan Barr committed
13
void unpack_edd_12bit_to_float32(uint64_t const* __restrict__ in, float* __restrict__ out, int n);
Ewan Barr's avatar
Ewan Barr committed
14

Tobias Winchen's avatar
Tobias Winchen committed
15
16
17
__global__
void unpack_edd_10bit_to_float32(uint64_t const* __restrict__ in, float* __restrict__ out, int n);

Ewan Barr's avatar
Ewan Barr committed
18
__global__
Ewan Barr's avatar
Ewan Barr committed
19
void unpack_edd_8bit_to_float32(uint64_t const* __restrict__ in, float* __restrict__ out, int n);
Ewan Barr's avatar
Ewan Barr committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

}

class Unpacker
{
public:
    typedef thrust::device_vector<uint64_t> InputType;
    typedef thrust::device_vector<float> OutputType;

public:

    Unpacker(cudaStream_t stream);
    ~Unpacker();
    Unpacker(Unpacker const&) = delete;

    template <int Nbits>
36
37
38
    void unpack(const uint64_t*  input, float* output, size_t size);

    template <int Nbits>
Tobias Winchen's avatar
Tobias Winchen committed
39
    void unpack(InputType const& input, OutputType& output)
40
41
42
43
44
45
    {
      InputType::value_type const* input_ptr = thrust::raw_pointer_cast(input.data());
      OutputType::value_type* output_ptr = thrust::raw_pointer_cast(output.data());
      unpack<Nbits>(input_ptr, output_ptr, input.size());
    }

Ewan Barr's avatar
Ewan Barr committed
46
47

private:
Ewan Barr's avatar
Ewan Barr committed
48
    cudaStream_t _stream;
Ewan Barr's avatar
Ewan Barr committed
49
50
51
52
53
54
55
56
57
58
};

} //namespace edd
} //namespace effelsberg
} //namespace psrdada_cpp

#endif // PSRDADA_CPP_EFFELSBERG_EDD_UNPACKER_CUH