COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
sutra_controller_utils.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-2023 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 
7 // -----------------------------------------------------------------------------
8 
15 
16 #ifndef SUTRA_CONTROLLER_UTILS_H_
17 #define SUTRA_CONTROLLER_UTILS_H_
18 
19 #include <sutra_atmos.h>
20 #include <sutra_dm.h>
21 #include <sutra_sensors.h>
22 #include <cstdio>
23 
24 struct gtomo_struct {
25  double DiamTel; // Telescope diameter [m]
26  double obs; // Central obstruction
27  double pasDPHI; // DPHI step
28  long Nw; // Number of WFS
29  long Nx; // Total number of valid ssp
30  long *Nssp; // Number of nxsub for each wfs
31  long *Nsubap; // Number of valid subap for each wfs
32  double *diamPup; // Nssp
33  double *XPup; // 0
34  double *YPup; // 0
35  double *thetaML; // 0
36  double *alphaX; // wfs positions
37  double *alphaY; // wfs positions
38  double *GsAlt; // LGS altitude (0)
39 
40  double lgs_cst; // 0
41  double spot_width; // 1
42  double lgs_depth; // 10000
43  double lgs_alt; // 90000.
44  int nlgs; // 0
45 
46  long *ioff_d; // Cumulative number of nvalid ssp with ioff[0] = 0
47  long *Nssp_d; // Nssp
48  long *Nsubap_d;
49 
50  double *alphaX_d;
51  double *alphaY_d;
52  double *GsAlt_d;
53  double *diamPup_d;
54  double *thetaML_d;
55  double *X_d;
56  double *Y_d;
57  double *XPup_d;
58  double *YPup_d;
59 
60  long max_Nl0;
61  long *indexL0_d;
62  double *L0diff_d;
63  double *h_d;
64  double *cn2_d;
65  double *tabDPHI_d;
66  double *u_d;
67  double *v_d;
68  double *sspSizeL_d;
69 
70  cudaStream_t matcov_stream;
71 };
72 
73 struct cphim_struct {
74  double DiamTel;
75  long Ndphi; // Useless ?
76  long Nlayer;
77  double pasDPHI;
78  double pasDu; // Useless
79  long int_npts;
80  long Nw;
81  long Nx;
82  long Ndm;
83  long Nactu;
84  long *Nactu_tot;
85  long *indLayerDm;
86  long *NlayerDM;
87  long *Nssp;
88  long *Nsubap; // Number of valid subap for each wfs
89  double *diamPup;
90  double *XPup;
91  double *YPup;
92  double *thetaML;
93  double *alphaX;
94  double *alphaY;
95  double *GsAlt;
96  double x0;
97  double y0;
98 
99  double lgs_cst;
100  double spot_width;
101  double lgs_depth;
102  double lgs_alt;
103  int nlgs;
104 
105  long *ioff_d;
106  long *Nssp_d;
107  long *Nactu_tot_d;
109  long *NlayerDM_d;
110  double *alphaX_d;
111  double *alphaY_d;
112  double *GsAlt_d;
113  double *diamPup_d;
114  double *thetaML_d;
115  double *X_d;
116  double *Y_d;
117  double *XPup_d;
118  double *YPup_d;
119 
120  long max_Nl0;
121  long *indexL0_d;
122  long *Nsubap_d; // Number of valid subap for each wfs
123  double *L0diff_d;
124  double *h_d;
125  double *hDm_d;
126  double *cn2_d;
127  double *k2_d;
128  double *tabDPHI_d;
129  double *tab_int_x;
130  double *tab_int_y;
131  double *xact_d;
132  double *yact_d;
133  double *u_d;
134  double *v_d;
135  double *dx_d;
136  double *sspSizeL_d;
137  double FoV;
138 
139  cudaStream_t cphim_stream;
140 };
141 
142 void process_err(cudaError_t e, const char *str);
143 void matts_gpu_gb(double *data, int nrows, int ncols, int xoffset, int yoffset,
144  int lda, struct tomo_struct tomo,
145  struct gtomo_struct *tomo_gpu);
146 void init_tomo_gpu_gb(struct gtomo_struct *tomo_gpu, SutraAtmos *atmos,
147  SutraSensors *sensors, double diamTel, double cobs);
148 void free_tomo_gpu_gb(struct gtomo_struct *tomo_gpu);
149 void update_tomo_atm_gpu_gb(struct gtomo_struct *tomo_gpu,
150  SutraSensors *sensors, SutraAtmos *atmos,
151  double *L0, double *cn2, double *alphaX,
152  double *alphaY);
153 void update_tomo_sys_gpu_gb(struct gtomo_struct *tomo_gpu,
154  SutraSensors *sensors, double *alphaX,
155  double *alphaY);
157  SutraAtmos *atmos, double *L0, double *cn2,
158  double *alphaX, double *alphaY);
160  double *alphaX, double *alphaY, double *xactu,
161  double *yactu, double *X, double *Y, long *NlayerDm,
162  long *indLayerDm, double *alt_dm, double *pitch,
163  double *k2, double FoV);
164 void matcov_gpu_3(double *data, int nrows, int ncols, int xoffset, int yoffset,
165  int lda, struct tomo_struct tomo,
166  struct gtomo_struct *tomo_gpu);
167 void matcov_gpu_4(float *data, int nrows, int ncols, int xoffset, int yoffset,
168  int lda, struct gtomo_struct *tomo_gpu, SutraAtmos *atmos,
169  SutraSensors *sensors, double *alphaX, double *alphaY);
170 void CPHIM(float *data, int nrows, int ncols, int xoffset, int yoffset, int lda,
171  struct cphim_struct *cphim_struct, SutraAtmos *atmos,
172  SutraSensors *sensors, double *alphaX, double *alphaY,
173  CarmaDevice *device);
174 void generateXY(struct gtomo_struct *tomo_gpu, SutraSensors *sensors);
175 void tab_dphi_gpu_gb(double *tab_dphi, struct gtomo_struct *tomo_gpu,
176  long Ndphi, double *L0diff_d, int Nl0, double convert);
177 void sub_pos_gpu_gb(struct gtomo_struct *tomo_gpu, long Nlayer);
178 void sub_pos_cphim(struct cphim_struct *cphim_struct, long Nlayer, long Nw,
179  long Nsubap);
180 void tab_u831J0(double *tab_int_x, double *tab_int_y, long npts);
181 void cuda_zcen(double *idata, double *odata, int N, CarmaDevice *device);
182 void cumsum(double *odata, double *idata, int N);
184  SutraSensors *sensors, SutraDms *dms, double diamTel);
186 void test_DPHI_highpass(double R, double x0, long npts, CarmaDevice *device);
187 
188 #endif // SUTRA_CONTROLLER_UTILS_H_
this class provides the atmos features to COMPASS
Definition: sutra_atmos.h:25
this class provides the sensors features to COMPASS
Definition: sutra_sensors.h:34
cudaStream_t cphim_stream
cudaStream_t matcov_stream
void CPHIM(float *data, int nrows, int ncols, int xoffset, int yoffset, int lda, struct cphim_struct *cphim_struct, SutraAtmos *atmos, SutraSensors *sensors, double *alphaX, double *alphaY, CarmaDevice *device)
void cuda_zcen(double *idata, double *odata, int N, CarmaDevice *device)
void init_cphim_struct(struct cphim_struct *cphim_struct, SutraAtmos *atmos, SutraSensors *sensors, SutraDms *dms, double diamTel)
void init_tomo_gpu_gb(struct gtomo_struct *tomo_gpu, SutraAtmos *atmos, SutraSensors *sensors, double diamTel, double cobs)
void test_DPHI_highpass(double R, double x0, long npts, CarmaDevice *device)
void update_tomo_sys_gpu_gb(struct gtomo_struct *tomo_gpu, SutraSensors *sensors, double *alphaX, double *alphaY)
void update_tomo_atm_gpu_gb(struct gtomo_struct *tomo_gpu, SutraSensors *sensors, SutraAtmos *atmos, double *L0, double *cn2, double *alphaX, double *alphaY)
void update_cphim_atm(struct cphim_struct *cphim_struct, SutraSensors *sensors, SutraAtmos *atmos, double *L0, double *cn2, double *alphaX, double *alphaY)
void tab_u831J0(double *tab_int_x, double *tab_int_y, long npts)
void matcov_gpu_4(float *data, int nrows, int ncols, int xoffset, int yoffset, int lda, struct gtomo_struct *tomo_gpu, SutraAtmos *atmos, SutraSensors *sensors, double *alphaX, double *alphaY)
void process_err(cudaError_t e, const char *str)
void update_cphim_sys(struct cphim_struct *cphim_struct, SutraSensors *sensors, double *alphaX, double *alphaY, double *xactu, double *yactu, double *X, double *Y, long *NlayerDm, long *indLayerDm, double *alt_dm, double *pitch, double *k2, double FoV)
void sub_pos_gpu_gb(struct gtomo_struct *tomo_gpu, long Nlayer)
void free_tomo_gpu_gb(struct gtomo_struct *tomo_gpu)
void cumsum(double *odata, double *idata, int N)
void matts_gpu_gb(double *data, int nrows, int ncols, int xoffset, int yoffset, int lda, struct tomo_struct tomo, struct gtomo_struct *tomo_gpu)
void matcov_gpu_3(double *data, int nrows, int ncols, int xoffset, int yoffset, int lda, struct tomo_struct tomo, struct gtomo_struct *tomo_gpu)
void sub_pos_cphim(struct cphim_struct *cphim_struct, long Nlayer, long Nw, long Nsubap)
void tab_dphi_gpu_gb(double *tab_dphi, struct gtomo_struct *tomo_gpu, long Ndphi, double *L0diff_d, int Nl0, double convert)
void free_cphim_struct(struct cphim_struct *cphim_struct)
void generateXY(struct gtomo_struct *tomo_gpu, SutraSensors *sensors)