Go to the documentation of this file.
12 #ifndef RTCTK_EXAMPLEDATATASK_GPU_COMPUTATION_HPP
13 #define RTCTK_EXAMPLEDATATASK_GPU_COMPUTATION_HPP
38 void SetStaticConfig(
unsigned to_read,
unsigned n_slopes,
unsigned n_modes,
unsigned gpu) {
40 m_n_samples_to_read = to_read;
41 m_n_slopes = n_slopes;
45 m_s2m_matrix.resize(m_n_modes, m_n_slopes);
48 LOG4CPLUS_DEBUG(
GetLogger(),
"m_n_slopes: " << m_n_slopes);
49 LOG4CPLUS_DEBUG(
GetLogger(),
"m_n_modes: " << m_n_modes);
50 LOG4CPLUS_DEBUG(
GetLogger(),
"m_n_samples_to_read: " << m_n_samples_to_read);
51 LOG4CPLUS_DEBUG(
GetLogger(),
"m_gpu: " << gpu);
54 m_gpu_comp = std::make_unique<GpuLib>(m_n_slopes, m_n_modes, gpu);
57 m_gpu_comp->ResetAvgSlopes();
61 m_s2m_matrix = std::move(s2m_matrix);
63 if (m_n_modes != m_s2m_matrix.get_nrows() || m_n_slopes != m_s2m_matrix.get_ncols()) {
64 std::stringstream err_text;
65 err_text <<
"s2m wrong shape: ";
67 <<
"expected : " << m_n_modes <<
" x " << m_n_slopes;
69 <<
"received : " << m_s2m_matrix.get_nrows() <<
" x "
70 << m_s2m_matrix.get_ncols();
76 m_gpu_comp->SetMatrix(m_s2m_matrix.data());
84 m_gpu_comp->ResetAvgSlopes();
88 m_gpu_comp->InitReaderThread();
93 m_gpu_comp->NewSample(sample.
wfs.
slopes.data(), m_sample_idx);
112 if (m_sample_idx != m_n_samples_to_read) {
116 LOG4CPLUS_INFO(
GetLogger(),
"Computation::Compute() - samples: " << m_sample_idx);
118 auto time_start = std::chrono::system_clock::now();
120 m_gpu_comp->Compute();
122 auto elapsed = std::chrono::system_clock::now() - time_start;
124 m_avg_slopes = std::move(m_gpu_comp->GetAvgSlopes());
125 m_avg_modes = std::move(m_gpu_comp->GetResults());
130 m_gpu_comp->ResetAvgSlopes();
132 return {m_avg_slopes, m_avg_modes, m_last_sample_id, m_iteration_idx, elapsed};
136 unsigned m_last_sample_id;
137 unsigned m_iteration_idx;
138 unsigned m_sample_idx;
142 unsigned m_n_samples_to_read;
144 std::vector<float> m_avg_slopes;
145 std::vector<float> m_avg_modes;
148 std::unique_ptr<GpuLib> m_gpu_comp;
151 #endif // RTCTK_EXAMPLEDATATASK_GPU_COMPUTATION_HPP
void Reset()
Definition: computation.hpp:79
WfsLoopBaseTopic< N_SUBAPS > wfs
Definition: topics.hpp:30
Provides macros and utilities for exception handling.
std::vector< float > const & avg_modes
Definition: computation.hpp:99
Definition: commandReplier.cpp:20
unsigned last_sample_id
Definition: computation.hpp:102
void SetDynamicConfig(MatrixBuffer< float > &&s2m_matrix)
Definition: computation.hpp:60
Declaration of the MatrixBuffer template class used in APIs.
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:207
Definition: computation.hpp:97
std::array< float, 2 *NSUBAPS > slopes
Definition: topics.hpp:24
unsigned iteration_idx
Definition: computation.hpp:103
std::vector< float > const & avg_slopes
Definition: computation.hpp:98
void ThreadInit()
Definition: computation.hpp:87
uint64_t sample_id
Definition: topics.hpp:29
Definition: topics.hpp:28
GPU library for computation.
void OnDataAvailable(TopicType const &sample)
Definition: computation.hpp:91
log4cplus::Logger & GetLogger(const std::string &name="")
Get handle to a specific logger (used with logging macros)
std::chrono::duration< double > elapsed
Definition: computation.hpp:104
void SetStaticConfig(unsigned to_read, unsigned n_slopes, unsigned n_modes, unsigned gpu)
Definition: computation.hpp:38
Logging Support Library based on log4cplus.
Definition: computation.hpp:28
Result Compute()
Definition: computation.hpp:108
Computation()
Definition: computation.hpp:32
Common topic definitions used in various examples.