eddfft.cuh 1.84 KB
Newer Older
1
2
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_EDDFFT_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_EDDFFT_HPP
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

#include "psrdada_cpp/raw_bytes.hpp"
#include "thrust/device_vector.h"
#include "thrust/host_vector.h"
#include "cufft.h"

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

    __global__
    void unpack_edd_12bit_to_float32(char* __restrict__ in, float* __restrict__ out, int n);

} //kernels

template <class HandlerType>
class SimpleFFTSpectrometer
{
public:
    SimpleFFTSpectrometer(
        std::size_t fft_length,
        std::size_t naccumulate,
        std::size_t nbits,
        HandlerType& handler);
    ~SimpleFFTSpectrometer();

    /**
     * @brief      A callback to be called on connection
     *             to a ring buffer.
     *
     * @detail     The first available header block in the
     *             in the ring buffer is provided as an argument.
     *             It is here that header parameters could be read
     *             if desired.
     *
     * @param      block  A RawBytes object wrapping a DADA header buffer
     */
    void init(RawBytes& block);

    /**
     * @brief      A callback to be called on acqusition of a new
     *             data block.
     *
     * @param      block  A RawBytes object wrapping a DADA data buffer
     */
    bool operator()(RawBytes& block);

private:
    std::size_t _fft_length;
    std::size_t _naccumulate;
    std::size_t _nbits;
    HandlerType& _handler;
    bool _first_block;
    std::size_t _nsamps;
    cufftHandle _fft_plan;
    thrust::device_vector<uint64_t> _edd_raw;
    thrust::device_vector<float> _edd_unpacked;
    thrust::device_vector<cufftComplex> _channelised;
    thrust::device_vector<float> _detected;
};


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

70
71
#include "psrdada_cpp/effelsberg/edd/detail/eddfft.cu"
#endif //PSRDADA_CPP_EFFELSBERG_EDD_EDDFFT_HPP