coffee
Coronagraph Optimization For Fast Exoplanet Exploration
COREMOD_memory.h
Go to the documentation of this file.
1 
17 #ifndef _COREMODMEMORY_H
18 #define _COREMODMEMORY_H
19 
20 /* the number of images in the data structure is kept NB_IMAGES_BUFFER above the number of used images prior to the execution of any function. It means that no function should create more than 100 images. */
21 #define NB_IMAGES_BUFFER 500
22 /* when the number of free images in the data structure is below NB_IMAGES_BUFFER, it is increased by NB_IMAGES_BUFFER */
23 #define NB_IMAGES_BUFFER_REALLOC 600
24 
25 /* the number of variables in the data structure is kept NB_VARIABLES_BUFFER above the number of used variables prior to the execution of any function. It means that no function should create more than 100 variables. */
26 #define NB_VARIABLES_BUFFER 100
27 /* when the number of free variables in the data structure is below NB_VARIABLES_BUFFER, it is increased by NB_VARIABLES_BUFFER */
28 #define NB_VARIABLES_BUFFER_REALLOC 150
29 
30 
31 /*void print_sys_mem_info();*/
32 
33 
34 
35 
36 typedef struct
37 {
38  int on;
39  long long cnt;
40  long long filecnt;
41  long interval;
42  int logexit;
43  char fname[200];
44 } LOGSHIM_CONF;
45 
46 
47 
48 typedef struct
49 {
50  long cnt0;
51  long cnt1;
53 
54 
55 
56 void __attribute__ ((constructor)) libinit_COREMOD_memory();
57 int_fast8_t init_COREMOD_memory();
58 
59 
60 
61 
62 
63 //int ImageCreateSem(IMAGE *image, long NBsem);
64 
65 //int ImageCreate(IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int NBkw);
66 
67 
68 int_fast8_t COREMOD_MEMORY_testfunc();
69 
70 
71 /* =============================================================================================== */
72 /* =============================================================================================== */
76 /* =============================================================================================== */
78 /* =============================================================================================== */
79 
80 
81 int_fast8_t memory_monitor(const char *termttyname);
82 
83 long compute_nb_image();
84 
85 long compute_nb_variable();
86 
87 long long compute_image_memory();
88 
90 
91 long image_ID(const char *name);
92 
93 long image_ID_noaccessupdate(const char *name);
94 
95 long variable_ID(const char *name);
96 
97 long next_avail_image_ID();
98 
100 
101 int_fast8_t delete_image_ID(const char* imname);
102 
103 int_fast8_t delete_image_ID_prefix(const char *prefix);
104 
105 int_fast8_t delete_variable_ID(const char* varname);
106 
107 long create_variable_long_ID(const char *name, long value);
108 
109 long create_variable_string_ID(const char *name, const char *value);
110 
111 long create_image_ID(const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int nbkw);
112 
113 int_fast8_t clearall();
114 
115 void *save_fits_function( void *ptr );
116 
118 
119 
120 
121 /* =============================================================================================== */
122 /* =============================================================================================== */
126 /* =============================================================================================== */
128 /* =============================================================================================== */
129 
130 long image_write_keyword_L(const char *IDname, const char *kname, long value, const char *comment);
131 long image_write_keyword_D(const char *IDname, const char *kname, double value, const char *comment);
132 long image_write_keyword_S(const char *IDname, const char *kname, const char *value, const char *comment);
133 
134 long image_list_keywords(const char *IDname);
135 
136 long image_read_keyword_D(const char *IDname, const char *kname, double *val);
137 long image_read_keyword_L(const char *IDname, const char *kname, long *val);
138 
140 
141 
142 
143 /* =============================================================================================== */
144 /* =============================================================================================== */
148 /* =============================================================================================== */
150 /* =============================================================================================== */
151 
152 
153 long read_sharedmem_image_size(const char *name, const char *fname);
154 long read_sharedmem_image(const char *name);
155 
157 
158 
159 
160 /* =============================================================================================== */
161 /* =============================================================================================== */
165 /* =============================================================================================== */
167 /* =============================================================================================== */
168 
169 
170 long create_1Dimage_ID(const char *ID_name, uint32_t xsize);
171 
172 long create_1DCimage_ID(const char *ID_name, uint32_t xsize);
173 
174 long create_2Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize);
175 
176 long create_2Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize);
177 
178 long create_2DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize);
179 
180 long create_2DCimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize);
181 
182 long create_3Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
183 
184 long create_3Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
185 
186 long create_3DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
187 
189 
190 
191 
192 /* =============================================================================================== */
193 /* =============================================================================================== */
197 /* =============================================================================================== */
199 /* =============================================================================================== */
200 
201 long create_variable_ID(const char *name, double value);
202 
204 
205 
206 
207 
208 
209 /* =============================================================================================== */
210 /* =============================================================================================== */
214 /* =============================================================================================== */
216 /* =============================================================================================== */
217 
218 long copy_image_ID(const char *name, const char *newname, int shared);
219 
220 long chname_image_ID(const char *ID_name, const char *new_name);
221 
222 long COREMOD_MEMORY_cp2shm(const char *IDname, const char *IDshmname);
223 
225 
226 
227 
228 
229 
230 /* =============================================================================================== */
231 /* =============================================================================================== */
235 /* =============================================================================================== */
237 /* =============================================================================================== */
238 
239 int_fast8_t init_list_image_ID_ncurses(const char *termttyname);
240 
241 void close_list_image_ID_ncurses( void );
242 
243 int_fast8_t list_image_ID_ncurses();
244 
245 int_fast8_t list_image_ID_ofp(FILE *fo);
246 
247 int_fast8_t list_image_ID_ofp_simple(FILE *fo);
248 
249 int_fast8_t list_image_ID();
250 
251 int_fast8_t list_image_ID_file(const char *fname);
252 
253 int_fast8_t list_variable_ID();
254 
255 int_fast8_t list_variable_ID_file(const char *fname);
256 
257 
259 
260 
261 
262 /* =============================================================================================== */
263 /* =============================================================================================== */
267 /* =============================================================================================== */
269 /* =============================================================================================== */
270 
271 int_fast8_t mk_complex_from_reim(const char *re_name, const char *im_name, const char *out_name, int sharedmem);
272 
273 int_fast8_t mk_complex_from_amph(const char *am_name, const char *ph_name, const char *out_name, int sharedmem);
274 
275 int_fast8_t mk_reim_from_complex(const char *in_name, const char *re_name, const char *im_name, int sharedmem);
276 
277 int_fast8_t mk_amph_from_complex(const char *in_name, const char *am_name, const char *ph_name, int sharedmem);
278 
279 int_fast8_t mk_reim_from_amph(const char *am_name, const char *ph_name, const char *re_out_name, const char *im_out_name, int sharedmem);
280 
281 int_fast8_t mk_amph_from_reim(const char *re_name, const char *im_name, const char *am_out_name, const char *ph_out_name, int sharedmem);
282 
284 
285 
286 
287 
288 
289 /* =============================================================================================== */
290 /* =============================================================================================== */
294 /* =============================================================================================== */
296 /* =============================================================================================== */
297 
298 int_fast8_t check_2Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize);
299 
300 int_fast8_t check_3Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
301 
302 long COREMOD_MEMORY_check_2Dsize(const char *IDname, uint32_t xsize, uint32_t ysize);
303 
304 long COREMOD_MEMORY_check_3Dsize(const char *IDname, uint32_t xsize, uint32_t ysize, uint32_t zsize);
305 
307 
308 
309 
310 
311 /* =============================================================================================== */
312 /* =============================================================================================== */
316 /* =============================================================================================== */
318 /* =============================================================================================== */
319 
320 int_fast8_t rotate_cube(const char *ID_name, const char *ID_out_name, int orientation);
321 
323 
324 
325 
326 
327 
328 /* =============================================================================================== */
329 /* =============================================================================================== */
333 /* =============================================================================================== */
335 /* =============================================================================================== */
336 
337 long COREMOD_MEMORY_image_set_status(const char *IDname, int status);
338 long COREMOD_MEMORY_image_set_cnt0(const char *IDname, int cnt0);
339 long COREMOD_MEMORY_image_set_cnt1(const char *IDname, int cnt1);
340 
342 
343 
344 
345 
346 /* =============================================================================================== */
347 /* =============================================================================================== */
351 /* =============================================================================================== */
353 /* =============================================================================================== */
354 
355 long COREMOD_MEMORY_image_set_createsem(const char *IDname, long NBsem);
356 long COREMOD_MEMORY_image_set_sempost(const char *IDname, long index);
357 long COREMOD_MEMORY_image_set_sempost_byID(long ID, long index);
358 long COREMOD_MEMORY_image_set_sempost_excl_byID(long ID, long index);
359 
360 long COREMOD_MEMORY_image_set_sempost_loop(const char *IDname, long index, long dtus);
361 long COREMOD_MEMORY_image_set_semwait(const char *IDname, long index);
362 void *waitforsemID(void *ID);
363 long COREMOD_MEMORY_image_set_semwait_OR_IDarray(long *IDarray, long NB_ID);
364 long COREMOD_MEMORY_image_set_semflush_IDarray(long *IDarray, long NB_ID);
365 long COREMOD_MEMORY_image_set_semflush(const char *IDname, long index);
366 
368 
369 
370 
371 /* =============================================================================================== */
372 /* =============================================================================================== */
376 /* =============================================================================================== */
378 /* =============================================================================================== */
379 
380 
383 long COREMOD_MEMORY_streamDiff(const char *IDstream0_name, const char *IDstream1_name, const char *IDstreammask_name, const char *IDstreamout_name, long semtrig);
384 
385 
386 
389 long COREMOD_MEMORY_stream_halfimDiff(const char *IDstream_name, const char *IDstreamout_name, long semtrig);
390 
391 
401 long COREMOD_MEMORY_streamAve(const char *IDstream_name, int NBave, int mode, const char *IDout_name);
402 
403 
404 
405 
408 long COREMOD_MEMORY_image_streamupdateloop(const char *IDinname, const char *IDoutname, long usperiod, long NBcubes, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode);
409 
410 
411 
424 long COREMOD_MEMORY_image_streamupdateloop_semtrig(const char *IDinname, const char *IDoutname, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode);
425 
426 
427 
428 
429 long COREMOD_MEMORY_streamDelay(const char *IDin_name, const char *IDout_name, long delayus, long dtus);
430 
431 long COREMOD_MEMORY_SaveAll_snapshot(const char *dirname);
432 
433 long COREMOD_MEMORY_SaveAll_sequ(const char *dirname, const char *IDtrig_name, long semtrig, long NBframes);
434 
435 
436 
437 long COREMOD_MEMORY_image_NETWORKtransmit(const char *IDname, const char *IPaddr, int port, int mode, int RT_priority);
438 
439 long COREMOD_MEMORY_image_NETWORKreceive(int port, int mode, int RT_priority);
440 
441 
442 
443 long COREMOD_MEMORY_PixMapDecode_U(const char *inputstream_name, uint32_t xsizeim, uint32_t ysizeim, const char* NBpix_fname, const char* IDmap_name, const char *IDout_name, const char *IDout_pixslice_fname);
444 
446 
447 
448 
449 
450 
451 /* =============================================================================================== */
452 /* =============================================================================================== */
456 /* =============================================================================================== */
458 /* =============================================================================================== */
459 
460 
461 int_fast8_t COREMOD_MEMORY_logshim_printstatus(const char *IDname);
462 int_fast8_t COREMOD_MEMORY_logshim_set_on(const char *IDname, int setv);
463 int_fast8_t COREMOD_MEMORY_logshim_set_logexit(const char *IDname, int setv);
464 long COREMOD_MEMORY_sharedMem_2Dim_log(const char *IDname, uint32_t zsize, const char *logdir, const char *IDlogdata_name);
465 
467 
468 
469 #endif
int_fast8_t init_COREMOD_memory()
Definition: COREMOD_memory.c:1050
long create_3Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2538
int_fast8_t list_image_ID_file(const char *fname)
Definition: COREMOD_memory.c:3465
int_fast8_t COREMOD_MEMORY_logshim_set_logexit(const char *IDname, int setv)
Definition: COREMOD_memory.c:6749
long COREMOD_MEMORY_cp2shm(const char *IDname, const char *IDshmname)
Definition: COREMOD_memory.c:2925
long create_3DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2566
int_fast8_t mk_amph_from_complex(const char *in_name, const char *am_name, const char *ph_name, int sharedmem)
Definition: COREMOD_memory.c:3884
long create_1Dimage_ID(const char *ID_name, uint32_t xsize)
Definition: COREMOD_memory.c:2382
int_fast8_t mk_reim_from_complex(const char *in_name, const char *re_name, const char *im_name, int sharedmem)
Definition: COREMOD_memory.c:3789
long create_3Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2520
long COREMOD_MEMORY_sharedMem_2Dim_log(const char *IDname, uint32_t zsize, const char *logdir, const char *IDlogdata_name)
long COREMOD_MEMORY_image_set_semwait(const char *IDname, long index)
Definition: COREMOD_memory.c:4411
long create_2Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2416
long COREMOD_MEMORY_image_set_cnt0(const char *IDname, int cnt0)
Definition: COREMOD_memory.c:4284
int_fast8_t check_3Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:4049
int_fast8_t list_image_ID_ofp(FILE *fo)
Definition: COREMOD_memory.c:3289
long image_write_keyword_L(const char *IDname, const char *kname, long value, const char *comment)
Definition: COREMOD_memory.c:2008
void * waitforsemID(void *ID)
Definition: COREMOD_memory.c:4429
int_fast8_t rotate_cube(const char *ID_name, const char *ID_out_name, int orientation)
Definition: COREMOD_memory.c:4163
long long compute_image_memory()
Definition: COREMOD_memory.c:1419
long COREMOD_MEMORY_check_2Dsize(const char *IDname, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:4090
long create_2Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2446
int_fast8_t COREMOD_MEMORY_logshim_set_on(const char *IDname, int setv)
Definition: COREMOD_memory.c:6705
long COREMOD_MEMORY_image_streamupdateloop_semtrig(const char *IDinname, const char *IDoutname, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode)
takes a 3Dimage (circular buffer) and writes slices to a 2D image synchronized with an image semaphor...
Definition: COREMOD_memory.c:5149
long read_sharedmem_image_size(const char *name, const char *fname)
Definition: COREMOD_memory.c:2194
long COREMOD_MEMORY_image_set_sempost_loop(const char *IDname, long index, long dtus)
Definition: COREMOD_memory.c:4393
long image_read_keyword_L(const char *IDname, const char *kname, long *val)
Definition: COREMOD_memory.c:2143
long COREMOD_MEMORY_image_set_sempost_excl_byID(long ID, long index)
Definition: COREMOD_memory.c:4379
int_fast8_t COREMOD_MEMORY_logshim_printstatus(const char *IDname)
Definition: COREMOD_memory.c:6644
int_fast8_t list_image_ID_ofp_simple(FILE *fo)
Definition: COREMOD_memory.c:3422
int_fast8_t clearall()
Definition: COREMOD_memory.c:1809
long COREMOD_MEMORY_check_3Dsize(const char *IDname, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:4118
long COREMOD_MEMORY_streamDiff(const char *IDstream0_name, const char *IDstream1_name, const char *IDstreammask_name, const char *IDstreamout_name, long semtrig)
Difference between two streams.
Definition: COREMOD_memory.c:4571
Definition: COREMOD_memory.h:48
long variable_ID(const char *name)
Definition: COREMOD_memory.c:1527
int_fast8_t delete_image_ID_prefix(const char *prefix)
Definition: COREMOD_memory.c:1773
int_fast8_t list_variable_ID_file(const char *fname)
Definition: COREMOD_memory.c:3543
long image_write_keyword_D(const char *IDname, const char *kname, double value, const char *comment)
Definition: COREMOD_memory.c:2039
long COREMOD_MEMORY_image_NETWORKreceive(int port, int mode, int RT_priority)
Definition: COREMOD_memory.c:5965
int_fast8_t list_image_ID_ncurses()
Definition: COREMOD_memory.c:3102
long COREMOD_MEMORY_image_set_sempost_byID(long ID, long index)
Definition: COREMOD_memory.c:4367
long COREMOD_MEMORY_image_set_semflush(const char *IDname, long index)
set semaphore value to 0
Definition: COREMOD_memory.c:4526
long COREMOD_MEMORY_image_set_cnt1(const char *IDname, int cnt1)
Definition: COREMOD_memory.c:4294
long create_variable_ID(const char *name, double value)
Definition: COREMOD_memory.c:2622
long COREMOD_MEMORY_PixMapDecode_U(const char *inputstream_name, uint32_t xsizeim, uint32_t ysizeim, const char *NBpix_fname, const char *IDmap_name, const char *IDout_name, const char *IDout_pixslice_fname)
Definition: COREMOD_memory.c:6326
Definition: COREMOD_memory.h:36
int_fast8_t init_list_image_ID_ncurses(const char *termttyname)
Definition: COREMOD_memory.c:3078
long copy_image_ID(const char *name, const char *newname, int shared)
Definition: COREMOD_memory.c:2760
long image_ID_noaccessupdate(const char *name)
Definition: COREMOD_memory.c:1496
long create_1DCimage_ID(const char *ID_name, uint32_t xsize)
Definition: COREMOD_memory.c:2400
void * save_fits_function(void *ptr)
Definition: COREMOD_memory.c:1830
int_fast8_t mk_complex_from_amph(const char *am_name, const char *ph_name, const char *out_name, int sharedmem)
Definition: COREMOD_memory.c:3666
int_fast8_t memory_monitor(const char *termttyname)
Definition: COREMOD_memory.c:1376
long compute_nb_variable()
Definition: COREMOD_memory.c:1404
long COREMOD_MEMORY_image_streamupdateloop(const char *IDinname, const char *IDoutname, long usperiod, long NBcubes, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode)
takes a 3Dimage (circular buffer) and writes slices to a 2D image with time interval specified in us ...
Definition: COREMOD_memory.c:4879
long COREMOD_MEMORY_streamDelay(const char *IDin_name, const char *IDout_name, long delayus, long dtus)
Definition: COREMOD_memory.c:5312
long COREMOD_MEMORY_image_NETWORKtransmit(const char *IDname, const char *IPaddr, int port, int mode, int RT_priority)
Definition: COREMOD_memory.c:5637
long image_list_keywords(const char *IDname)
Definition: COREMOD_memory.c:2100
long COREMOD_MEMORY_image_set_semwait_OR_IDarray(long *IDarray, long NB_ID)
Wait for multiple images semaphores [OR], only works for sem0.
Definition: COREMOD_memory.c:4464
long COREMOD_MEMORY_image_set_status(const char *IDname, int status)
Definition: COREMOD_memory.c:4274
long image_read_keyword_D(const char *IDname, const char *kname, double *val)
Definition: COREMOD_memory.c:2123
long chname_image_ID(const char *ID_name, const char *new_name)
Definition: COREMOD_memory.c:2896
long create_variable_long_ID(const char *name, long value)
Definition: COREMOD_memory.c:2665
long create_image_ID(const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int nbkw)
Definition: COREMOD_memory.c:2306
int_fast8_t mk_amph_from_reim(const char *re_name, const char *im_name, const char *am_out_name, const char *ph_out_name, int sharedmem)
Definition: COREMOD_memory.c:3991
long COREMOD_MEMORY_stream_halfimDiff(const char *IDstream_name, const char *IDstreamout_name, long semtrig)
Definition: COREMOD_memory.c:4645
long compute_variable_memory()
Definition: COREMOD_memory.c:1442
long COREMOD_MEMORY_image_set_sempost(const char *IDname, long index)
Definition: COREMOD_memory.c:4349
void __attribute__((constructor)) libinit_COREMOD_memory()
Definition: 00CORE.c:87
long compute_nb_image()
Definition: COREMOD_memory.c:1391
void close_list_image_ID_ncurses(void)
Definition: COREMOD_memory.c:3273
int_fast8_t delete_variable_ID(const char *varname)
Definition: COREMOD_memory.c:1791
long image_write_keyword_S(const char *IDname, const char *kname, const char *value, const char *comment)
Definition: COREMOD_memory.c:2068
long next_avail_image_ID()
Definition: COREMOD_memory.c:1567
long create_variable_string_ID(const char *name, const char *value)
Definition: COREMOD_memory.c:2701
long read_sharedmem_image(const char *name)
Definition: COREMOD_memory.c:2266
long COREMOD_MEMORY_image_set_semflush_IDarray(long *IDarray, long NB_ID)
flush multiple semaphores
Definition: COREMOD_memory.c:4500
long next_avail_variable_ID()
Definition: COREMOD_memory.c:1601
long create_2DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2462
int_fast8_t mk_complex_from_reim(const char *re_name, const char *im_name, const char *out_name, int sharedmem)
Definition: COREMOD_memory.c:3576
int_fast8_t list_image_ID()
Definition: COREMOD_memory.c:3447
int_fast8_t list_variable_ID()
Definition: COREMOD_memory.c:3531
long COREMOD_MEMORY_image_set_createsem(const char *IDname, long NBsem)
Definition: COREMOD_memory.c:4324
int_fast8_t delete_image_ID(const char *imname)
Definition: COREMOD_memory.c:1625
int_fast8_t mk_reim_from_amph(const char *am_name, const char *ph_name, const char *re_out_name, const char *im_out_name, int sharedmem)
Definition: COREMOD_memory.c:3982
int_fast8_t COREMOD_MEMORY_testfunc()
Definition: COREMOD_memory.c:1306
int_fast8_t check_2Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:4029
long create_2DCimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2480
long COREMOD_MEMORY_SaveAll_sequ(const char *dirname, const char *IDtrig_name, long semtrig, long NBframes)
Definition: COREMOD_memory.c:5515
long COREMOD_MEMORY_SaveAll_snapshot(const char *dirname)
Definition: COREMOD_memory.c:5451
long COREMOD_MEMORY_streamAve(const char *IDstream_name, int NBave, int mode, const char *IDout_name)
Averages frames in stream.
Definition: COREMOD_memory.c:4721
long image_ID(const char *name)
Definition: COREMOD_memory.c:1461