COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
sutra_controller_generic.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // This file is part of COMPASS <https://anr-compass.github.io/compass/>
3 //
4 // Copyright (C) 2011-2019 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 // Distributed under GNU - LGPL
7 //
8 // COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
9 // General Public License as published by the Free Software Foundation, either version 3 of the License,
10 // or any later version.
11 //
12 // COMPASS: End-to-end AO simulation tool using GPU acceleration
13 // The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.
14 //
15 // The final product includes a software package for simulating all the critical subcomponents of AO,
16 // particularly in the context of the ELT and a real-time core based on several control approaches,
17 // with performances consistent with its integration into an instrument. Taking advantage of the specific
18 // hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to
19 // conduct large simulation campaigns called to the ELT.
20 //
21 // The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components
22 // of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and
23 // various systems configurations such as multi-conjugate AO.
24 //
25 // COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
26 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 // See the GNU Lesser General Public License for more details.
28 //
29 // You should have received a copy of the GNU Lesser General Public License along with COMPASS.
30 // If not, see <https://www.gnu.org/licenses/lgpl-3.0.txt>.
31 // -----------------------------------------------------------------------------
32 
41 
42 #ifndef _SUTRA_CONTROLLER_GENERIC_H_
43 #define _SUTRA_CONTROLLER_GENERIC_H_
44 
45 #include <sutra_acquisim.h>
46 #include <sutra_controller.h>
47 
48 template <typename Tcomp, typename Tout>
49 class sutra_controller_generic : public SutraController<Tcomp, Tout> {
50  public:
56  CarmaObj<Tcomp> *d_compbuff; // Buffer for computations
58  CarmaObj<Tcomp> *d_olmeas; // Open-loop measurements for POLC
60  std::vector<CarmaObj<Tcomp> *> d_err_ngpu;
61  std::vector<CarmaObj<Tcomp> *> d_cmat_ngpu;
62  std::vector<int> P2Pdevices;
63  bool polc;
64  int nstates;
65 
66  string command_law;
67 
68  public:
69  sutra_controller_generic(CarmaContext *context, long nvalid, long nslope,
70  long nactu, float delay, SutraDms *dms,
71  int *idx_dms, int ndm, int *idx_centro, int ncentro, int nstates);
74 
75  string get_type();
76  string get_commandlaw();
77  int set_decayFactor(float *decayFactor);
78  int set_modal_gains(float *gain);
79  int set_cmat(float *cmat);
80  int set_matE(float *matE);
81  int set_commandlaw(string law);
82  int set_polc(bool p);
83  int set_imat(float *imat);
84  int comp_polc();
85  int comp_com();
88 
89  private:
90  template <typename Q = Tcomp>
91  typename std::enable_if<!std::is_same<Q, half>::value, int>::type
92  fill_cmatPadded_impl() {
93  return EXIT_SUCCESS;
94  };
95  template <typename Q = Tcomp>
96  typename std::enable_if<std::is_same<Q, half>::value, int>::type
97  fill_cmatPadded_impl();
98 };
99 
100 template <typename T>
101 void pad_cmat(T *idata, int m, int n, T *odata, int m2, int n2,
102  CarmaDevice *device);
103 #endif // _SUTRA_CONTROLLER_GENERIC_H_
sutra_controller_generic::d_cmat_ngpu
std::vector< CarmaObj< Tcomp > * > d_cmat_ngpu
Definition: sutra_controller_generic.h:61
sutra_controller.h
sutra_controller_generic::command_law
string command_law
Definition: sutra_controller_generic.h:66
SutraController::delay
Tcomp delay
Definition: sutra_controller.h:79
CarmaDevice
Definition: carma_context.h:57
sutra_controller_generic::d_cmat
CarmaObj< Tcomp > * d_cmat
Definition: sutra_controller_generic.h:52
SutraDms
Definition: sutra_dm.h:164
sutra_controller_generic::~sutra_controller_generic
~sutra_controller_generic()
sutra_controller_generic
this class provides the controller_generic features to COMPASS
Definition: sutra_controller_generic.h:49
sutra_controller_generic::d_olmeas
CarmaObj< Tcomp > * d_olmeas
Definition: sutra_controller_generic.h:58
sutra_controller_generic::d_matE
CarmaObj< Tcomp > * d_matE
Definition: sutra_controller_generic.h:51
sutra_controller_generic::d_decayFactor
CarmaObj< Tcomp > * d_decayFactor
Definition: sutra_controller_generic.h:55
sutra_controller_generic::d_gain
CarmaObj< Tcomp > * d_gain
Definition: sutra_controller_generic.h:54
SutraController::gain
Tcomp gain
Definition: sutra_controller.h:80
sutra_controller_generic::d_err_ngpu
std::vector< CarmaObj< Tcomp > * > d_err_ngpu
Definition: sutra_controller_generic.h:60
sutra_controller_generic::set_cmat
int set_cmat(float *cmat)
sutra_controller_generic::set_decayFactor
int set_decayFactor(float *decayFactor)
sutra_controller_generic::nstates
int nstates
Definition: sutra_controller_generic.h:64
sutra_controller_generic::set_polc
int set_polc(bool p)
sutra_controller_generic::comp_polc
int comp_polc()
sutra_controller_generic::set_matE
int set_matE(float *matE)
sutra_controller_generic::d_compbuff
CarmaObj< Tcomp > * d_compbuff
Definition: sutra_controller_generic.h:56
sutra_controller_generic::get_type
string get_type()
CarmaObj< Tcomp >
CarmaContext
this class provides the context in which CarmaObj are created
Definition: carma_context.h:104
sutra_controller_generic::d_compbuff2
CarmaObj< Tcomp > * d_compbuff2
Definition: sutra_controller_generic.h:57
SutraController::nslope
int nslope()
Definition: sutra_controller.h:124
sutra_controller_generic::comp_com
int comp_com()
!!! YOU MUST set d_centroids before calling it!!!!
sutra_acquisim.h
pad_cmat
void pad_cmat(T *idata, int m, int n, T *odata, int m2, int n2, CarmaDevice *device)
sutra_controller_generic::get_commandlaw
string get_commandlaw()
sutra_controller_generic::sutra_controller_generic
sutra_controller_generic(CarmaContext *context, long nvalid, long nslope, long nactu, float delay, SutraDms *dms, int *idx_dms, int ndm, int *idx_centro, int ncentro, int nstates)
sutra_controller_generic::d_cmatPadded
CarmaObj< Tcomp > * d_cmatPadded
Definition: sutra_controller_generic.h:53
sutra_controller_generic::fill_cmatPadded
int fill_cmatPadded()
sutra_controller_generic::sutra_controller_generic
sutra_controller_generic(const sutra_controller_generic &controller)
sutra_controller_generic::set_modal_gains
int set_modal_gains(float *gain)
SutraController::nactu
int nactu()
Definition: sutra_controller.h:123
sutra_controller_generic::d_imat
CarmaObj< Tcomp > * d_imat
Definition: sutra_controller_generic.h:59
sutra_controller_generic::set_commandlaw
int set_commandlaw(string law)
sutra_controller_generic::set_imat
int set_imat(float *imat)
sutra_controller_generic::P2Pdevices
std::vector< int > P2Pdevices
Definition: sutra_controller_generic.h:62
sutra_controller_generic::polc
bool polc
Definition: sutra_controller_generic.h:63
SutraController
this class provides the controller features to COMPASS
Definition: sutra_controller.h:73
sutra_controller_generic::distribute_cmat
int distribute_cmat()