Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ComputeResults.c
Go to the documentation of this file.
1//
2// Copyright (C) 2016, 2017 Karl Wette
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with with program; see the file COPYING. If not, write to the
16// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17// MA 02110-1301 USA
18//
19
20///
21/// \file
22/// \ingroup lalpulsar_bin_Weave
23///
24
25#include "config.h"
26
27#include "ComputeResults.h"
28
29#ifdef LALPULSAR_CUDA_ENABLED
30#include <cuda.h>
31#include <cuda_runtime_api.h>
32#endif
33
34#include <lal/UserInputPrint.h>
35#include <lal/ExtrapolatePulsarSpins.h>
36
37#define XLAL_CHECK_CUDA_CALL(...) do { \
38 cudaError_t retn; \
39 XLAL_CHECK ( ( retn = (__VA_ARGS__) ) == cudaSuccess, XLAL_EERR, "%s failed with return code %i", #__VA_ARGS__, retn ); \
40 } while(0)
41
42///
43/// Aligned arrays use maximum required alignment, i.e.\ 32 bytes for AVX
44///
45const UINT4 alignment = 32;
46
47///
48/// Input data segment info
49///
50typedef struct {
51 /// Start time of segment
53 /// End time of segment
55 /// Timestamp of first SFT from each detector
57 /// Timestamp of last SFT from each detector
59 /// Number of SFTs from each detector
61 /// Minimum of frequency range loaded from SFTs
63 /// Maximum of frequency range loaded from SFTs
66
67///
68/// Input data required for computing coherent results
69///
71 /// List of detector names from setup file
73 /// Bitflag representing search simulation level
75 /// Input data segment info
77 /// Whether input data segment info contains SFT info
79 /// F-statistic input data
80 FstatInput *Fstat_input;
81 /// What F-statistic quantities to compute
83 /// Number of detectors in F-statistic data
85 /// Map detectors in F-statistic data in this segment to 'global' detector list across segments in coherent results
87 /// Whether F-statistic timing info is being collected
89};
90
91///
92/// Results of a coherent computation on a single segment
93///
95 /// Coherent template parameters of the first frequency bin
97 /// Number of frequencies
99 /// Multi-detector F-statistics per frequency
101 /// Multi-detector F-statistics per frequency, stored in CUDA device memory
103 /// Per-detector F-statistics per frequency
105};
106
107///
108/// \name Internal functions
109///
110/// @{
111
112#ifdef LALPULSAR_CUDA_ENABLED
113int XLALVectorsMaxREAL4CUDA( REAL4 *max, const REAL4 **vec, const size_t nvec, const size_t nbin );
114int XLALVectorsAddREAL4CUDA( REAL4 *sum, const REAL4 **vec, const size_t nvec, const size_t nbin );
115#endif
116
117/// @}
118
119///
120/// Create coherent input data
121///
123 const LALStringVector *setup_detectors,
124 const WeaveSimulationLevel simulation_level,
125 const SFTCatalog *sft_catalog,
126 const UINT4 segment_index,
127 const LALSeg *segment,
128 const PulsarDopplerParams *min_phys,
129 const PulsarDopplerParams *max_phys,
130 const double dfreq,
132 const LALStringVector *sft_noise_sqrtSX,
133 const LALStringVector *Fstat_assume_sqrtSX,
134 FstatOptionalArgs *Fstat_opt_args,
135 WeaveStatisticsParams *statistics_params,
136 BOOLEAN recalc_stage
137)
138{
139
140 // Check input
141 XLAL_CHECK_NULL( setup_detectors != NULL, XLAL_EFAULT );
142 XLAL_CHECK_NULL( ( simulation_level & WEAVE_SIMULATE_MIN_MEM ) || ( sft_catalog != NULL ), XLAL_EFAULT );
143 XLAL_CHECK_NULL( segment != NULL, XLAL_EFAULT );
144 XLAL_CHECK_NULL( min_phys != NULL, XLAL_EFAULT );
145 XLAL_CHECK_NULL( max_phys != NULL, XLAL_EFAULT );
148 XLAL_CHECK_NULL( Fstat_opt_args != NULL, XLAL_EFAULT );
149 XLAL_CHECK_NULL( statistics_params != NULL, XLAL_EFAULT );
150
151 // Allocate memory
152 WeaveCohInput *coh_input = XLALCalloc( 1, sizeof( *coh_input ) );
153 XLAL_CHECK_NULL( coh_input != NULL, XLAL_ENOMEM );
154
155 // Set fields
156 coh_input->setup_detectors = setup_detectors;
157 coh_input->simulation_level = simulation_level;
158 coh_input->seg_info_have_sft_info = ( sft_catalog != NULL );
159 coh_input->Fstat_collect_timing = Fstat_opt_args->collectTiming;
160
161 // Record information from segment
162 coh_input->seg_info.segment_start = segment->start;
163 coh_input->seg_info.segment_end = segment->end;
164
165 // Return now if simulating search with minimal memory allocation
166 if ( coh_input->simulation_level & WEAVE_SIMULATE_MIN_MEM ) {
167 return coh_input;
168 }
169
170 // Get a timeslice of SFT catalog restricted to the given segment
171 SFTCatalog XLAL_INIT_DECL( sft_catalog_seg );
172 XLAL_CHECK_NULL( XLALSFTCatalogTimeslice( &sft_catalog_seg, sft_catalog, &segment->start, &segment->end ) == XLAL_SUCCESS, XLAL_EFUNC );
173 XLAL_CHECK_NULL( sft_catalog_seg.length > 0, XLAL_EINVAL, "No SFTs found in segment %u", segment_index );
174
175 // Check that the number of SFTs in each segment matches the number provided by the segment list in the setup file, if nonzero
176 const UINT4 sft_count = ( UINT4 ) segment->id;
177 XLAL_CHECK_NULL( sft_count == 0 || sft_catalog_seg.length == sft_count, XLAL_EFAILED, "Number of SFTs found for segment %u (%u) is inconsistent with expected number of SFTs given by segment list (%u)", segment_index, sft_catalog_seg.length, sft_count );
178
179 // Get list of detectors of SFT catalog in this segment
180 LALStringVector *sft_catalog_seg_detectors = XLALListIFOsInCatalog( &sft_catalog_seg );
181 XLAL_CHECK_NULL( sft_catalog_seg_detectors != NULL, XLAL_EFUNC );
182
183 // Compute frequency range covered by spindown range over in the given segment
184 LIGOTimeGPS sft_start = sft_catalog_seg.data[0].header.epoch;
185 LIGOTimeGPS sft_end = sft_catalog_seg.data[sft_catalog_seg.length - 1].header.epoch;
186 const double sft_end_timebase = 1.0 / sft_catalog_seg.data[sft_catalog_seg.length - 1].header.deltaF;
187 XLALGPSAdd( &sft_end, sft_end_timebase );
188 PulsarSpinRange XLAL_INIT_DECL( spin_range );
189 XLAL_CHECK_NULL( XLALInitPulsarSpinRangeFromSpins( &spin_range, &min_phys->refTime, min_phys->fkdot, max_phys->fkdot ) == XLAL_SUCCESS, XLAL_EFUNC );
190 double sft_min_cover_freq = 0, sft_max_cover_freq = 0;
191 XLAL_CHECK_NULL( XLALCWSignalCoveringBand( &sft_min_cover_freq, &sft_max_cover_freq, &sft_start, &sft_end, &spin_range, 0, 0, 0 ) == XLAL_SUCCESS, XLAL_EFUNC );
192
193 // Parse SFT noise sqrt(Sh) string vector for detectors in this segment
194 // - This is important when segments contain data from a subset of detectors
195 MultiNoiseFloor Fstat_injectSqrtSX;
196 if ( sft_noise_sqrtSX != NULL ) {
197 XLAL_CHECK_NULL( XLALParseMultiNoiseFloorMapped( &Fstat_injectSqrtSX, sft_catalog_seg_detectors, sft_noise_sqrtSX, setup_detectors ) == XLAL_SUCCESS, XLAL_EFUNC );
198 Fstat_opt_args->injectSqrtSX = &Fstat_injectSqrtSX;
199 }
200
201 // Parse F-statistic assumed sqrt(Sh) string vector for detectors in this segment
202 // - This is important when segments contain data from a subset of detectors
203 MultiNoiseFloor Fstat_assumeSqrtSX;
204 if ( Fstat_assume_sqrtSX != NULL ) {
205 XLAL_CHECK_NULL( XLALParseMultiNoiseFloorMapped( &Fstat_assumeSqrtSX, sft_catalog_seg_detectors, Fstat_assume_sqrtSX, setup_detectors ) == XLAL_SUCCESS, XLAL_EFUNC );
206 Fstat_opt_args->assumeSqrtSX = &Fstat_assumeSqrtSX;
207 }
208
209 // Load F-statistic input data
210 coh_input->Fstat_input = XLALCreateFstatInput( &sft_catalog_seg, sft_min_cover_freq, sft_max_cover_freq, dfreq, ephemerides, Fstat_opt_args );
211 XLAL_CHECK_NULL( coh_input->Fstat_input != NULL, XLAL_EFUNC );
212 Fstat_opt_args->prevInput = coh_input->Fstat_input;
213
214 // Decide what F-statistic quantities to compute
215 WeaveStatisticType requested_stats = ( recalc_stage ) ? statistics_params->completionloop_statistics[1] : statistics_params->mainloop_statistics;
216 if ( requested_stats & WEAVE_STATISTIC_COH2F ) {
217#ifdef LALPULSAR_CUDA_ENABLED
218 const char *Fstat_method = XLALGetFstatInputMethodName( coh_input->Fstat_input );
219 XLAL_CHECK_NULL( Fstat_method != NULL, XLAL_EFUNC );
220 if ( XLALStringCaseCompare( Fstat_method, "ResampCUDA" ) == 0 ) {
221 coh_input->Fstat_what_to_compute |= FSTATQ_2F_CUDA;
222 } else {
223 coh_input->Fstat_what_to_compute |= FSTATQ_2F;
224 }
225#else
226 coh_input->Fstat_what_to_compute |= FSTATQ_2F;
227#endif
228 }
229 if ( requested_stats & WEAVE_STATISTIC_COH2F_DET ) {
230 coh_input->Fstat_what_to_compute |= FSTATQ_2F_PER_DET;
231 }
232
233 // Map detectors in F-statistic data in the given segment to their index in the coherent results
234 // - This is important when segments contain data from a subset of detectors
235 // - Map entry 'i' in 'Fstat_detector_info' (F-statistic data) to entry 'idx' in 'detectors' (coherent results)
236 // The array 'n2F_det[idx]' counts the total number of F-statistics computed for detector 'idx' across all segments
237 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) {
238 const MultiLALDetector *Fstat_detector_info = XLALGetFstatInputDetectors( coh_input->Fstat_input );
239 coh_input->Fstat_ndetectors = Fstat_detector_info->length;
240 char *statistics_detectors_string = XLALConcatStringVector( statistics_params->detectors, "," );
241 for ( size_t i = 0; i < coh_input->Fstat_ndetectors; ++i ) {
242 const char *prefix = Fstat_detector_info->sites[i].frDetector.prefix;
243 const int idx = XLALFindStringInVector( prefix, statistics_params->detectors );
244 XLAL_CHECK_NULL( idx >= 0, XLAL_EFAILED, "Detector '%s' from F-statistic data not found in list of detectors '%s'", prefix, statistics_detectors_string );
245 coh_input->Fstat_res_idx[i] = idx;
246 statistics_params->n2F_det[idx] += 1;
247 }
248 XLALFree( statistics_detectors_string );
249 }
250
251 // Record information from SFTs in the given segment
252 {
253 MultiSFTCatalogView *sft_catalog_seg_view = XLALGetMultiSFTCatalogView( &sft_catalog_seg );
254 XLAL_CHECK_NULL( sft_catalog_seg_view != NULL, XLAL_EINVAL );
255 for ( size_t j = 0; j < sft_catalog_seg_view->length; ++j ) {
256 XLAL_CHECK_NULL( sft_catalog_seg_view->data[j].length > 0, XLAL_EINVAL );
257 char *detector_name = XLALGetChannelPrefix( sft_catalog_seg_view->data[j].data[0].header.name );
258 XLAL_CHECK_NULL( detector_name != NULL, XLAL_EFUNC );
259 const int k = XLALFindStringInVector( detector_name, sft_catalog_seg_detectors );
260 if ( k >= 0 ) {
261 const UINT4 length = sft_catalog_seg_view->data[j].length;
262 coh_input->seg_info.sft_first[k] = sft_catalog_seg_view->data[j].data[0].header.epoch;
263 coh_input->seg_info.sft_last[k] = sft_catalog_seg_view->data[j].data[length - 1].header.epoch;
264 coh_input->seg_info.sft_count[k] = length;
265 }
266 XLALFree( detector_name );
267 }
268 XLALDestroyMultiSFTCatalogView( sft_catalog_seg_view );
269 }
270 XLAL_CHECK_NULL( XLALGetFstatInputSFTBand( coh_input->Fstat_input, &coh_input->seg_info.sft_min_freq, &coh_input->seg_info.sft_max_freq ) == XLAL_SUCCESS, XLAL_EFUNC );
271
272
273 // Cleanup
274 XLALDestroyStringVector( sft_catalog_seg_detectors );
275
276 return coh_input;
277
278}
279
280///
281/// Destroy coherent input data
282///
284 WeaveCohInput *coh_input
285)
286{
287 if ( coh_input != NULL ) {
288 XLALDestroyFstatInput( coh_input->Fstat_input );
289 XLALFree( coh_input );
290 }
291}
292
293///
294/// Write various information from coherent input data to a FITS file
295///
297 FITSFile *file,
298 const size_t ncoh_input,
299 WeaveCohInput *const *coh_input
300)
301{
302
303 // Check input
304 XLAL_CHECK( file != NULL, XLAL_EFAULT );
305 XLAL_CHECK( ncoh_input > 0, XLAL_ESIZE );
306 XLAL_CHECK( coh_input != NULL, XLAL_EFAULT );
307
308 // Write total number of SFTs used by search
309 {
310 UINT4 nsfts = 0;
311 for ( size_t i = 0; i < ncoh_input; ++i ) {
312 for ( size_t j = 0; j < PULSAR_MAX_DETECTORS; ++j ) {
313 nsfts += coh_input[i]->seg_info.sft_count[j];
314 }
315 }
316 XLAL_CHECK_MAIN( XLALFITSHeaderWriteUINT4( file, "nsfts", nsfts, "number of SFTs used by search" ) == XLAL_SUCCESS, XLAL_EFUNC );
317 }
318
319 // Return now if simulating search
320 if ( coh_input[0]->simulation_level & WEAVE_SIMULATE ) {
321 return XLAL_SUCCESS;
322 }
323
324 // Write F-statistic method name
325 {
326 const char *method_name = XLALGetFstatInputMethodName( coh_input[0]->Fstat_input );
327 XLAL_CHECK( method_name != NULL, XLAL_EFUNC );
328 XLAL_CHECK( XLALFITSHeaderWriteString( file, "fstat method", method_name, "name of F-statistic method" ) == XLAL_SUCCESS, XLAL_EFUNC );
329 }
330
331 // Write F-statistic timing information
332 if ( coh_input[0]->Fstat_collect_timing ) {
333
334 // Get timing information from F-statistic input data
335 REAL4 tauF_eff = 0, tauF_core = 0, tauF_buffer = 0, NCalls = 0, NBufferMisses = 0;
336 UINT4 nmodel = 0;
337 const char *XLAL_INIT_DECL( model_names, [TIMING_MODEL_MAX_VARS] );
338 REAL4 XLAL_INIT_DECL( model_values, [TIMING_MODEL_MAX_VARS] );
339 for ( size_t i = 0; i < ncoh_input; ++i ) {
340
341 // Get timing data
342 FstatTimingGeneric XLAL_INIT_DECL( timing_generic );
343 FstatTimingModel XLAL_INIT_DECL( timing_model );
344 XLAL_CHECK( XLALGetFstatTiming( coh_input[i]->Fstat_input, &timing_generic, &timing_model ) == XLAL_SUCCESS, XLAL_EFUNC );
345 XLAL_CHECK( timing_generic.NCalls > 0, XLAL_EFAILED );
346
347 // Accumulate generic timing constants
348 tauF_eff += timing_generic.tauF_eff;
349 tauF_core += timing_generic.tauF_core;
350 tauF_buffer += timing_generic.tauF_buffer;
351 NCalls += timing_generic.NCalls;
352 NBufferMisses += timing_generic.NBufferMisses;
353
354 // Get names of method-specific timing constants
355 if ( nmodel == 0 ) {
356 nmodel = timing_model.numVariables;
357 for ( size_t j = 0; j < nmodel; ++j ) {
358 model_names[j] = timing_model.names[j];
359 }
360 } else {
361 XLAL_CHECK( nmodel == timing_model.numVariables, XLAL_EFAILED );
362 for ( size_t j = 0; j < nmodel; ++j ) {
363 XLAL_CHECK( strcmp( model_names[j], timing_model.names[j] ) == 0, XLAL_EFAILED );
364 }
365 }
366
367 // Accumulate method-specific timing constants
368 for ( size_t j = 0; j < nmodel; ++j ) {
369 model_values[j] += timing_model.values[j];
370 }
371
372 }
373
374 // Write generic timing constants
375 XLAL_CHECK( XLALFITSHeaderWriteREAL4( file, "fstat tauF_eff", tauF_eff / ncoh_input, "F-statistic generic timing constant" ) == XLAL_SUCCESS, XLAL_EFUNC );
376 XLAL_CHECK( XLALFITSHeaderWriteREAL4( file, "fstat tauF_core", tauF_core / ncoh_input, "F-statistic generic timing constant" ) == XLAL_SUCCESS, XLAL_EFUNC );
377 XLAL_CHECK( XLALFITSHeaderWriteREAL4( file, "fstat tauF_buffer", tauF_buffer / ncoh_input, "F-statistic generic timing constant" ) == XLAL_SUCCESS, XLAL_EFUNC );
378 XLAL_CHECK( XLALFITSHeaderWriteREAL4( file, "fstat b", NBufferMisses / NCalls, "F-statistic generic timing constant" ) == XLAL_SUCCESS, XLAL_EFUNC );
379
380 // Write method-specific timing constants
381 for ( size_t j = 0; j < nmodel; ++j ) {
382 char keyword[64];
383 snprintf( keyword, sizeof( keyword ), "fstat %s", model_names[j] );
384 XLAL_CHECK( XLALFITSHeaderWriteREAL4( file, keyword, model_values[j] / ncoh_input, "F-statistic method-specific timing constant" ) == XLAL_SUCCESS, XLAL_EFUNC );
385 }
386
387 }
388
389 return XLAL_SUCCESS;
390
391}
392
393///
394/// Write various segment information from coherent input data to a FITS file
395///
397 FITSFile *file,
398 const size_t ncoh_input,
399 WeaveCohInput *const *coh_input
400)
401{
402
403 // Check input
404 XLAL_CHECK( file != NULL, XLAL_EFAULT );
405 XLAL_CHECK( ncoh_input > 0, XLAL_ESIZE );
406 XLAL_CHECK( coh_input != NULL, XLAL_EFAULT );
407
408 // Begin FITS table
409 XLAL_CHECK( XLALFITSTableOpenWrite( file, "segment_info", "segment information" ) == XLAL_SUCCESS, XLAL_EFUNC );
410
411 // Describe FITS table
412 char col_name[64];
414 XLAL_CHECK( XLAL_FITS_TABLE_COLUMN_ADD( file, GPSTime, segment_start ) == XLAL_SUCCESS, XLAL_EFUNC );
415 XLAL_CHECK( XLAL_FITS_TABLE_COLUMN_ADD( file, GPSTime, segment_end ) == XLAL_SUCCESS, XLAL_EFUNC );
416 if ( coh_input[0]->seg_info_have_sft_info ) {
417 for ( size_t i = 0; i < coh_input[0]->setup_detectors->length; ++i ) {
418 snprintf( col_name, sizeof( col_name ), "sft_first_%s", coh_input[0]->setup_detectors->data[i] );
419 XLAL_CHECK( XLAL_FITS_TABLE_COLUMN_ADD_NAMED( file, GPSTime, sft_first[i], col_name ) == XLAL_SUCCESS, XLAL_EFUNC );
420 snprintf( col_name, sizeof( col_name ), "sft_last_%s", coh_input[0]->setup_detectors->data[i] );
421 XLAL_CHECK( XLAL_FITS_TABLE_COLUMN_ADD_NAMED( file, GPSTime, sft_last[i], col_name ) == XLAL_SUCCESS, XLAL_EFUNC );
422 snprintf( col_name, sizeof( col_name ), "sft_count_%s", coh_input[0]->setup_detectors->data[i] );
424 }
427 }
428
429 // Write FITS table
430 for ( size_t i = 0; i < ncoh_input; ++i ) {
431 XLAL_CHECK( XLALFITSTableWriteRow( file, &coh_input[i]->seg_info ) == XLAL_SUCCESS, XLAL_EFUNC );
432 }
433
434 return XLAL_SUCCESS;
435
436}
437
438///
439/// Create and compute coherent results
440///
442 WeaveCohResults **coh_res,
443 WeaveCohInput *coh_input,
444 const PulsarDopplerParams *coh_phys,
445 const UINT4 coh_nfreqs,
446 WeaveSearchTiming *tim
447)
448{
449
450 // Check input
451 XLAL_CHECK( coh_res != NULL, XLAL_EFAULT );
452 XLAL_CHECK( coh_input != NULL, XLAL_EFAULT );
453 XLAL_CHECK( coh_phys != NULL, XLAL_EFAULT );
454 XLAL_CHECK( coh_nfreqs > 0, XLAL_EINVAL );
455
456 // Allocate results struct if required
457 if ( *coh_res == NULL ) {
458 *coh_res = XLALCalloc( 1, sizeof( **coh_res ) );
459 XLAL_CHECK( *coh_res != NULL, XLAL_ENOMEM );
460 }
461
462 // Set fields
463 ( *coh_res )->coh_phys = *coh_phys;
464 ( *coh_res )->nfreqs = coh_nfreqs;
465
466 // Return now if simulating search with minimal memory allocation
467 if ( coh_input->simulation_level & WEAVE_SIMULATE_MIN_MEM ) {
468 return XLAL_SUCCESS;
469 }
470
471 // Reallocate vectors of multi- and per-detector F-statistics per frequency
472 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F ) {
473 if ( ( *coh_res )->coh2F == NULL || ( *coh_res )->coh2F->length < ( *coh_res )->nfreqs ) {
474 ( *coh_res )->coh2F = XLALResizeREAL4Vector( ( *coh_res )->coh2F, ( *coh_res )->nfreqs );
475 XLAL_CHECK( ( *coh_res )->coh2F != NULL, XLAL_ENOMEM );
476 }
477 }
478 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_CUDA ) {
479#ifdef LALPULSAR_CUDA_ENABLED
480 if ( ( *coh_res )->coh2F_CUDA.data == NULL || ( *coh_res )->coh2F_CUDA.length < ( *coh_res )->nfreqs ) {
481 cudaFree( ( *coh_res )->coh2F_CUDA.data );
482 XLAL_CHECK( cudaMalloc( ( void ** ) & ( *coh_res )->coh2F_CUDA.data, sizeof( ( *coh_res )->coh2F_CUDA.data[0] ) * ( *coh_res )->nfreqs ) == cudaSuccess, XLAL_ENOMEM );
483 ( *coh_res )->coh2F_CUDA.length = ( *coh_res )->nfreqs;
484 }
485#else
486 XLAL_ERROR( XLAL_EFAILED, "CUDA not enabled" );
487#endif
488 }
489 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) {
490 for ( size_t i = 0; i < coh_input->Fstat_ndetectors; ++i ) {
491 const size_t idx = coh_input->Fstat_res_idx[i];
492 if ( ( *coh_res )->coh2F_det[idx] == NULL || ( *coh_res )->coh2F_det[idx]->length < ( *coh_res )->nfreqs ) {
493 ( *coh_res )->coh2F_det[idx] = XLALResizeREAL4Vector( ( *coh_res )->coh2F_det[idx], ( *coh_res )->nfreqs );
494 XLAL_CHECK( ( *coh_res )->coh2F_det[idx] != NULL, XLAL_ENOMEM );
495 }
496 }
497 }
498
499 // Return now if simulating search
500 if ( coh_input->simulation_level & WEAVE_SIMULATE ) {
501 return XLAL_SUCCESS;
502 }
503
504 // Start timing of coherent results
505 if ( tim != NULL ) {
507 }
508
509 // Use a local F-statistic results structure, since we supply our own memory
510 // - The 'internalalloclen' field stores the memory size in elements of the results arrays (e.g. 'coh2F'),
511 // as opposed to 'numFreqBins' which stores how many elements of the result arrays are in use.
512 FstatResults XLAL_INIT_DECL( Fstat_res_struct );
513 FstatResults *Fstat_res = &Fstat_res_struct;
514 Fstat_res->internalalloclen = ( *coh_res )->nfreqs;
515 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F ) {
516 Fstat_res->twoF = ( *coh_res )->coh2F->data;
517 }
518#ifdef LALPULSAR_CUDA_ENABLED
519 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_CUDA ) {
520 Fstat_res->twoF_CUDA = ( *coh_res )->coh2F_CUDA.data;
521 }
522#endif
523 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) {
524 Fstat_res->numDetectors = coh_input->Fstat_ndetectors;
525 for ( size_t i = 0; i < coh_input->Fstat_ndetectors; ++i ) {
526 const size_t idx = coh_input->Fstat_res_idx[i];
527 Fstat_res->twoFPerDet[i] = ( *coh_res )->coh2F_det[idx]->data;
528 }
529 }
530
531 // Compute the F-statistic starting at the point 'coh_phys', with 'nfreqs' frequency bins
532 XLAL_CHECK( XLALComputeFstat( &Fstat_res, coh_input->Fstat_input, coh_phys, ( *coh_res )->nfreqs, coh_input->Fstat_what_to_compute ) == XLAL_SUCCESS, XLAL_EFUNC );
533
534 // Sanity check the F-statistic results structure
535 XLAL_CHECK( Fstat_res->internalalloclen == ( *coh_res )->nfreqs, XLAL_EFAILED );
536 XLAL_CHECK( Fstat_res->numFreqBins == ( *coh_res )->nfreqs, XLAL_EFAILED );
537 XLAL_CHECK( !( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) || ( Fstat_res->numDetectors == coh_input->Fstat_ndetectors ), XLAL_EFAILED );
538 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F ) {
539 XLAL_CHECK( Fstat_res->twoF == ( *coh_res )->coh2F->data, XLAL_EFAILED );
540 }
541#ifdef LALPULSAR_CUDA_ENABLED
542 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_CUDA ) {
543 XLAL_CHECK( Fstat_res->twoF_CUDA == ( *coh_res )->coh2F_CUDA.data, XLAL_EFAILED );
544 }
545#endif
546 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) {
547 for ( size_t i = 0; i < coh_input->Fstat_ndetectors; ++i ) {
548 const size_t idx = coh_input->Fstat_res_idx[i];
549 XLAL_CHECK( Fstat_res->twoFPerDet[i] == ( *coh_res )->coh2F_det[idx]->data, XLAL_EFAILED, "%p vs %p", Fstat_res->twoFPerDet[i], ( *coh_res )->coh2F_det[idx]->data );
550 }
551 }
552
553 // Stop timing of coherent results
554 if ( tim != NULL ) {
556 }
557
558 return XLAL_SUCCESS;
559
560}
561
562///
563/// Destroy coherent results
564///
566 WeaveCohResults *coh_res
567)
568{
569 if ( coh_res != NULL ) {
570 XLALDestroyREAL4Vector( coh_res->coh2F );
571#ifdef LALPULSAR_CUDA_ENABLED
572 if ( coh_res->coh2F_CUDA.data != NULL ) {
573 cudaFree( coh_res->coh2F_CUDA.data );
574 }
575#endif
576 for ( size_t i = 0; i < PULSAR_MAX_DETECTORS; ++i ) {
577 XLALDestroyREAL4Vector( coh_res->coh2F_det[i] );
578 }
579 XLALFree( coh_res );
580 }
581}
582
583///
584/// Create and initialise semicoherent results
585///
587 WeaveSemiResults **semi_res,
588 const WeaveSimulationLevel simulation_level,
589 const UINT4 ndetectors,
590 const UINT4 nsegments,
591 const UINT8 semi_index,
592 const PulsarDopplerParams *semi_phys,
593 const double dfreq,
594 const UINT4 semi_nfreqs,
595 const WeaveStatisticsParams *statistics_params
596)
597{
598
599 // Check input
600 XLAL_CHECK( semi_res != NULL, XLAL_EFAULT );
601 XLAL_CHECK( semi_phys != NULL, XLAL_EFAULT );
603 XLAL_CHECK( semi_nfreqs > 0, XLAL_EINVAL );
604 XLAL_CHECK( statistics_params != NULL, XLAL_EFAULT );
605
606 WeaveStatisticType mainloop_stats = statistics_params->mainloop_statistics;
607
608 const WeaveStatisticType supported_mainloop = (
609 0
620 );
621
622 WeaveStatisticType unsupported = ( mainloop_stats & ~supported_mainloop );
623 if ( unsupported != 0 ) {
624 char *unsupported_names = XLALPrintStringValueOfUserFlag( ( const int * )&unsupported, &WeaveStatisticChoices );
625 XLALPrintError( "BUG: unsupported main-loop statistics requested: %s\n", unsupported_names );
626 XLALFree( unsupported_names );
628 }
629
630 // Allocate results struct if required
631 if ( *semi_res == NULL ) {
632 *semi_res = XLALCalloc( 1, sizeof( **semi_res ) );
633 XLAL_CHECK( *semi_res != NULL, XLAL_ENOMEM );
634
635 // Allocate array for per-segment index
636 ( *semi_res )->coh_index = XLALCalloc( nsegments, sizeof( *( *semi_res )->coh_index ) );
637 XLAL_CHECK( ( *semi_res )->coh_index != NULL, XLAL_ENOMEM );
638
639 // Allocate array for per-segment coordinates
640 ( *semi_res )->coh_phys = XLALCalloc( nsegments, sizeof( *( *semi_res )->coh_phys ) );
641 XLAL_CHECK( ( *semi_res )->coh_phys != NULL, XLAL_ENOMEM );
642
643 // If we need coh2F in "main loop": allocate vector
644 if ( mainloop_stats & WEAVE_STATISTIC_COH2F ) {
645 if ( statistics_params->coh_input[0]->Fstat_what_to_compute & FSTATQ_2F_CUDA ) {
646#ifdef LALPULSAR_CUDA_ENABLED
647 XLAL_CHECK( cudaMallocManaged( ( void ** ) & ( *semi_res )->coh2F_CUDA, nsegments * sizeof( *( *semi_res )->coh2F_CUDA ), cudaMemAttachGlobal ) == cudaSuccess, XLAL_ENOMEM );
648 memset( ( *semi_res )->coh2F_CUDA, 0, nsegments * sizeof( *( *semi_res )->coh2F_CUDA ) );
649#else
650 XLAL_ERROR( XLAL_EFAILED, "CUDA not enabled" );
651#endif
652 } else {
653 XLAL_CHECK( ( ( *semi_res )->coh2F = XLALMalloc( nsegments * sizeof( *( *semi_res )->coh2F ) ) ) != NULL, XLAL_ENOMEM );
654 memset( ( *semi_res )->coh2F, 0, nsegments * sizeof( *( *semi_res )->coh2F ) );
655 }
656 }
657
658 // If we need coh2F_det in "main loop": allocate vector
659 if ( mainloop_stats & WEAVE_STATISTIC_COH2F_DET ) {
660 for ( size_t i = 0; i < ndetectors; ++i ) {
661 ( *semi_res )->coh2F_det[i] = XLALCalloc( nsegments, sizeof( *( *semi_res )->coh2F_det[i] ) );
662 XLAL_CHECK( ( *semi_res )->coh2F_det[i] != NULL, XLAL_ENOMEM );
663 }
664 }
665
666 }
667
668 // Set fields
669 ( *semi_res )->simulation_level = simulation_level;
670 ( *semi_res )->ndetectors = ndetectors;
671 ( *semi_res )->nsegments = nsegments;
672 ( *semi_res )->dfreq = dfreq;
673 ( *semi_res )->nfreqs = semi_nfreqs;
674 ( *semi_res )->semi_index = semi_index;
675 ( *semi_res )->semi_phys = *semi_phys;
676 ( *semi_res )->statistics_params = statistics_params;
677
678 // Initialise number of coherent results
679 ( *semi_res )->ncoh_res = 0;
680
681 // If we need max2F in "main loop": Reallocate vector of max-over-segments of multi-detector F-statistics per frequency
682 if ( mainloop_stats & WEAVE_STATISTIC_MAX2F ) {
683 if ( ( *semi_res )->max2F == NULL || ( *semi_res )->max2F->length < ( *semi_res )->nfreqs ) {
684#ifdef LALPULSAR_CUDA_ENABLED
685 if ( ( *semi_res )->max2F == NULL ) {
686 XLAL_CHECK( ( ( *semi_res )->max2F = XLALCalloc( 1, sizeof( *( *semi_res )->max2F ) ) ) != NULL, XLAL_ENOMEM );
687 }
688 if ( ( *semi_res )->max2F->data != NULL ) {
689 cudaFree( ( *semi_res )->max2F->data );
690 }
691 XLAL_CHECK( cudaMallocManaged( ( void ** ) & ( *semi_res )->max2F->data, sizeof( ( *semi_res )->max2F->data[0] ) * ( *semi_res )->nfreqs, cudaMemAttachGlobal ) == cudaSuccess, XLAL_ENOMEM );
692 ( *semi_res )->max2F->length = ( *semi_res )->nfreqs;
693#else
694 ( *semi_res )->max2F = XLALResizeREAL4VectorAligned( ( *semi_res )->max2F, ( *semi_res )->nfreqs, alignment );
695 XLAL_CHECK( ( *semi_res )->max2F != NULL, XLAL_ENOMEM );
696#endif
697 }
698 }
699 // If we need max2F_det in "main loop": Reallocate vector of max-over-segments of per-detector F-statistics per frequency
700 if ( mainloop_stats & WEAVE_STATISTIC_MAX2F_DET ) {
701 for ( size_t i = 0; i < ( *semi_res )->ndetectors; ++i ) {
702 if ( ( *semi_res )->max2F_det[i] == NULL || ( *semi_res )->max2F_det[i]->length < ( *semi_res )->nfreqs ) {
703 ( *semi_res )->max2F_det[i] = XLALResizeREAL4VectorAligned( ( *semi_res )->max2F_det[i], ( *semi_res )->nfreqs, alignment );
704 XLAL_CHECK( ( *semi_res )->max2F_det[i] != NULL, XLAL_ENOMEM );
705 }
706 }
707 }
708
709 // If we need sum2F in "main loop": Reallocate vector of sum of multi-detector F-statistics per frequency
710 if ( mainloop_stats & WEAVE_STATISTIC_SUM2F ) {
711 if ( ( *semi_res )->sum2F == NULL || ( *semi_res )->sum2F->length < ( *semi_res )->nfreqs ) {
712#ifdef LALPULSAR_CUDA_ENABLED
713 if ( ( *semi_res )->sum2F == NULL ) {
714 XLAL_CHECK( ( ( *semi_res )->sum2F = XLALCalloc( 1, sizeof( *( *semi_res )->sum2F ) ) ) != NULL, XLAL_ENOMEM );
715 }
716 if ( ( *semi_res )->sum2F->data != NULL ) {
717 cudaFree( ( *semi_res )->sum2F->data );
718 }
719 XLAL_CHECK( cudaMallocManaged( ( void ** ) & ( *semi_res )->sum2F->data, sizeof( ( *semi_res )->sum2F->data[0] ) * ( *semi_res )->nfreqs, cudaMemAttachGlobal ) == cudaSuccess, XLAL_ENOMEM );
720 ( *semi_res )->sum2F->length = ( *semi_res )->nfreqs;
721#else
722 ( *semi_res )->sum2F = XLALResizeREAL4VectorAligned( ( *semi_res )->sum2F, ( *semi_res )->nfreqs, alignment );
723 XLAL_CHECK( ( *semi_res )->sum2F != NULL, XLAL_ENOMEM );
724#endif
725 }
726 }
727 // If we need sum2F_det in "main loop": Reallocate vector of sum of per-detector F-statistics per frequency
728 if ( mainloop_stats & WEAVE_STATISTIC_SUM2F_DET ) {
729 for ( size_t i = 0; i < ( *semi_res )->ndetectors; ++i ) {
730 if ( ( *semi_res )->sum2F_det[i] == NULL || ( *semi_res )->sum2F_det[i]->length < ( *semi_res )->nfreqs ) {
731 ( *semi_res )->sum2F_det[i] = XLALResizeREAL4VectorAligned( ( *semi_res )->sum2F_det[i], ( *semi_res )->nfreqs, alignment );
732 XLAL_CHECK( ( *semi_res )->sum2F_det[i] != NULL, XLAL_ENOMEM );
733 }
734 }
735 }
736
737 // If we compute mean2F in "main loop": Reallocate vector of mean multi-F-statistics per frequency
738 if ( mainloop_stats & WEAVE_STATISTIC_MEAN2F ) {
739 if ( ( *semi_res )->mean2F == NULL || ( *semi_res )->mean2F->length < ( *semi_res )->nfreqs ) {
740 ( *semi_res )->mean2F = XLALResizeREAL4VectorAligned( ( *semi_res )->mean2F, ( *semi_res )->nfreqs, alignment );
741 XLAL_CHECK( ( *semi_res )->mean2F != NULL, XLAL_ENOMEM );
742 }
743 }
744
745 // (Re-)allocate vectors of line-robust log10(B_S/GL) statistic IFF used as a toplist statistic
746 if ( mainloop_stats & WEAVE_STATISTIC_BSGL ) {
747 if ( ( *semi_res )->log10BSGL == NULL || ( *semi_res )->log10BSGL->length < ( *semi_res )->nfreqs ) {
748 ( *semi_res )->log10BSGL = XLALResizeREAL4VectorAligned( ( *semi_res )->log10BSGL, ( *semi_res )->nfreqs, alignment );
749 XLAL_CHECK( ( *semi_res )->log10BSGL != NULL, XLAL_ENOMEM );
750 }
751 }
752
753 // (Re-)allocate vectors of transient-line-robust log10(B_S/GLtL) statistic IFF used as a toplist statistic
754 if ( mainloop_stats & WEAVE_STATISTIC_BSGLtL ) {
755 if ( ( *semi_res )->log10BSGLtL == NULL || ( *semi_res )->log10BSGLtL->length < ( *semi_res )->nfreqs ) {
756 ( *semi_res )->log10BSGLtL = XLALResizeREAL4VectorAligned( ( *semi_res )->log10BSGLtL, ( *semi_res )->nfreqs, alignment );
757 XLAL_CHECK( ( *semi_res )->log10BSGLtL != NULL, XLAL_ENOMEM );
758 }
759 }
760
761 // (Re-)allocate vectors of transient-signal line-robust log10(B_tS/GLtL) statistic IFF used as a toplist statistic
762 if ( mainloop_stats & WEAVE_STATISTIC_BtSGLtL ) {
763 if ( ( *semi_res )->log10BtSGLtL == NULL || ( *semi_res )->log10BtSGLtL->length < ( *semi_res )->nfreqs ) {
764 ( *semi_res )->log10BtSGLtL = XLALResizeREAL4VectorAligned( ( *semi_res )->log10BtSGLtL, ( *semi_res )->nfreqs, alignment );
765 XLAL_CHECK( ( *semi_res )->log10BtSGLtL != NULL, XLAL_ENOMEM );
766 }
767 }
768
769 return XLAL_SUCCESS;
770
771}
772
773///
774/// Add a new set of coherent results to the semicoherent results
775///
777 WeaveSemiResults *semi_res,
778 const UINT4 nsegments,
779 const WeaveCohResults **coh_res,
780 const UINT8 *coh_index,
781 const UINT4 *coh_offset,
782 WeaveSearchTiming *tim
783)
784{
785
786 // Check input
787 XLAL_CHECK( semi_res != NULL, XLAL_EFAULT );
788 XLAL_CHECK( semi_res->ncoh_res < semi_res->nsegments, XLAL_EINVAL );
789 XLAL_CHECK( semi_res->statistics_params != NULL, XLAL_EFAULT );
790 XLAL_CHECK( nsegments > 0, XLAL_EINVAL );
791 XLAL_CHECK( coh_res != NULL, XLAL_EFAULT );
792 for ( size_t j = 0; j < nsegments; ++j ) {
793 XLAL_CHECK( coh_res[j] != NULL, XLAL_EFAULT );
794 }
795 XLAL_CHECK( coh_index != NULL, XLAL_EFAULT );
796 XLAL_CHECK( coh_offset != NULL, XLAL_EFAULT );
797 XLAL_CHECK( tim != NULL, XLAL_EFAULT );
798
799 WeaveStatisticType mainloop_stats = semi_res->statistics_params->mainloop_statistics;
800
801 // Set number of processed coherent results
802 semi_res->ncoh_res = nsegments;
803
804 for ( size_t j = 0; j < nsegments; ++j ) {
805
806 // Check that offset does not overrun coherent results arrays
807 XLAL_CHECK( coh_offset[j] + semi_res->nfreqs <= coh_res[j]->nfreqs, XLAL_EFAILED, "Coherent offset (%u) + number of semicoherent frequency bins (%u) > number of coherent frequency bins (%u)", coh_offset[j], semi_res->nfreqs, coh_res[j]->nfreqs );
808
809 // Store per-segment coherent template index
810 semi_res->coh_index[j] = coh_index[j];
811
812 // Store per-segment coherent template parameters
813 semi_res->coh_phys[j] = coh_res[j]->coh_phys;
814 semi_res->coh_phys[j].fkdot[0] += semi_res->dfreq * coh_offset[j];
815
816 }
817
818 // Return now if simulating search
819 if ( semi_res->simulation_level & WEAVE_SIMULATE ) {
820 return XLAL_SUCCESS;
821 }
822
823 // Store per-segment F-statistics per frequency
824 if ( mainloop_stats & WEAVE_STATISTIC_COH2F ) {
825 if ( semi_res->coh2F_CUDA != NULL ) {
826 for ( size_t j = 0; j < nsegments; ++j ) {
827 XLAL_CHECK( coh_res[j]->coh2F_CUDA.data != NULL, XLAL_EFAULT );
828 semi_res->coh2F_CUDA[j] = coh_res[j]->coh2F_CUDA.data + coh_offset[j];
829 }
830 } else {
831 for ( size_t j = 0; j < nsegments; ++j ) {
832 XLAL_CHECK( coh_res[j]->coh2F->data != NULL, XLAL_EFAULT );
833 semi_res->coh2F[j] = coh_res[j]->coh2F->data + coh_offset[j];
834 }
835 }
836 }
837
838 // Store per-segment per-detector F-statistics per frequency
839 if ( mainloop_stats & WEAVE_STATISTIC_COH2F_DET ) {
840 for ( size_t i = 0; i < semi_res->ndetectors; ++i ) {
841 for ( size_t j = 0; j < nsegments; ++j ) {
842 semi_res->coh2F_det[i][j] = ( coh_res[j]->coh2F_det[i] != NULL ) ? coh_res[j]->coh2F_det[i]->data + coh_offset[j] : NULL;
843 }
844 }
845 }
846
847 // Start timing of semicoherent results
849
850 // Add to max-over-segments multi-detector F-statistics per frequency
851 if ( mainloop_stats & WEAVE_STATISTIC_MAX2F ) {
852 if ( semi_res->coh2F_CUDA != NULL ) {
853#ifdef LALPULSAR_CUDA_ENABLED
854
855 // CUDA implementation
856 XLAL_CHECK( XLALVectorsMaxREAL4CUDA( semi_res->max2F->data, semi_res->coh2F_CUDA, nsegments, semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
857
858#else
859 XLAL_ERROR( XLAL_EFAILED, "CUDA not enabled" );
860#endif
861 } else {
862
863 // Generic implementation
864 memcpy( semi_res->max2F->data, semi_res->coh2F[0], sizeof( semi_res->max2F->data[0] ) * semi_res->nfreqs );
865 for ( size_t j = 1; j < nsegments; ++j ) {
866 XLAL_CHECK( XLALVectorMaxREAL4( semi_res->max2F->data, semi_res->max2F->data, semi_res->coh2F[j], semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
867 }
868
869 }
870 }
871
872 // Switch timed statistic
874
875 // Add to max-over-segments per-detector F-statistics per frequency
876 if ( mainloop_stats & WEAVE_STATISTIC_MAX2F_DET ) {
877 for ( size_t i = 0; i < semi_res->ndetectors; ++i ) {
878 memset( semi_res->max2F_det[i]->data, 0, sizeof( semi_res->max2F_det[i]->data[0] ) * semi_res->nfreqs );
879 for ( size_t j = 0; j < nsegments; ++j ) {
880 if ( coh_res[j]->coh2F_det[i] != NULL ) {
881 XLAL_CHECK( XLALVectorMaxREAL4( semi_res->max2F_det[i]->data, semi_res->max2F_det[i]->data, coh_res[j]->coh2F_det[i]->data + coh_offset[j], semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
882 }
883 }
884 }
885 }
886
887 // Switch timed statistic
889
890 // Add to summed multi-detector F-statistics per frequency, and increment number of additions thus far
891 if ( mainloop_stats & WEAVE_STATISTIC_SUM2F ) {
892 if ( semi_res->coh2F_CUDA != NULL ) {
893#ifdef LALPULSAR_CUDA_ENABLED
894
895 // CUDA implementation
896 XLAL_CHECK( XLALVectorsAddREAL4CUDA( semi_res->sum2F->data, semi_res->coh2F_CUDA, nsegments, semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
897
898#else
899 XLAL_ERROR( XLAL_EFAILED, "CUDA not enabled" );
900#endif
901 } else {
902
903 // Generic implementation
904 memcpy( semi_res->sum2F->data, semi_res->coh2F[0], sizeof( semi_res->sum2F->data[0] ) * semi_res->nfreqs );
905 for ( size_t j = 1; j < nsegments; ++j ) {
906 XLAL_CHECK( XLALVectorAddREAL4( semi_res->sum2F->data, semi_res->sum2F->data, semi_res->coh2F[j], semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
907 }
908
909 }
910 }
911
912 // Switch timed statistic
914
915 // Add to summed per-detector F-statistics per frequency, and increment number of additions thus far
916 for ( size_t i = 0; i < semi_res->ndetectors; ++i ) {
917 if ( mainloop_stats & WEAVE_STATISTIC_SUM2F_DET ) {
918 memset( semi_res->sum2F_det[i]->data, 0, sizeof( semi_res->sum2F_det[i]->data[0] ) * semi_res->nfreqs );
919 }
920 for ( size_t j = 0; j < nsegments; ++j ) {
921 if ( coh_res[j]->coh2F_det[i] != NULL ) {
922 if ( mainloop_stats & WEAVE_STATISTIC_SUM2F_DET ) {
923 XLAL_CHECK( XLALVectorAddREAL4( semi_res->sum2F_det[i]->data, semi_res->sum2F_det[i]->data, coh_res[j]->coh2F_det[i]->data + coh_offset[j], semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
924 }
925 }
926 }
927 }
928
929 // Stop timing of semicoherent results
931
932 return XLAL_SUCCESS;
933
934}
935
936///
937/// Compute all remaining *toplist-ranking* semicoherent statistics (ie 'mainloop-statistics').
938/// For efficiency reasons any statistics not needed here will be computed later in the
939/// "completion loop" on the final toplist.
940///
942 WeaveSemiResults *semi_res,
943 WeaveSearchTiming *tim
944)
945{
946 // Check input
947 XLAL_CHECK( semi_res != NULL, XLAL_EFAULT );
948 XLAL_CHECK( semi_res->ncoh_res == semi_res->nsegments, XLAL_EINVAL );
949 XLAL_CHECK( semi_res->statistics_params != NULL, XLAL_EFAULT );
950 XLAL_CHECK( tim != NULL, XLAL_EFAULT );
951
952 WeaveStatisticType mainloop_stats = semi_res->statistics_params->mainloop_statistics;
953
954 // Return now if simulating search
955 if ( semi_res->simulation_level & WEAVE_SIMULATE ) {
956 return XLAL_SUCCESS;
957 }
958
959 // Store results from 'semi_res' in some convenience variables
960 const REAL4 *sum2F = semi_res->sum2F != NULL ? semi_res->sum2F->data : NULL;
961 const REAL4 *sum2F_det[PULSAR_MAX_DETECTORS];
962 for ( size_t i = 0; i < semi_res->ndetectors; ++i ) {
963 sum2F_det[i] = semi_res->sum2F_det[i] != NULL ? semi_res->sum2F_det[i]->data : NULL;
964 }
965 const REAL4 *max2F = semi_res->max2F != NULL ? semi_res->max2F->data : NULL;
966 const REAL4 *max2F_det[PULSAR_MAX_DETECTORS];
967 for ( size_t i = 0; i < semi_res->ndetectors; ++i ) {
968 max2F_det[i] = semi_res->max2F_det[i] != NULL ? semi_res->max2F_det[i]->data : NULL;
969 }
970
971 //
972 // Compute any remaining (ie that don't directly depend on coh_2F or coh2F_det) toplist ranking statistics
973 //
974
975 // Start timing of semicoherent results
977
978 // Compute mean multi-detector F-statistics per frequency:
979 if ( mainloop_stats & WEAVE_STATISTIC_MEAN2F ) {
980 XLAL_CHECK( XLALVectorScaleREAL4( semi_res->mean2F->data, 1.0 / semi_res->nsegments, sum2F, semi_res->nfreqs ) == XLAL_SUCCESS, XLAL_EFUNC );
981 }
982
983 // Switch timed statistic
985
986 // Compute line-robust log10(B_S/GL) statistic per frequency
987 if ( mainloop_stats & WEAVE_STATISTIC_BSGL ) {
988 XLAL_CHECK( XLALVectorComputeBSGL( semi_res->log10BSGL->data, sum2F, sum2F_det, semi_res->nfreqs, semi_res->statistics_params->BSGL_setup ) == XLAL_SUCCESS, XLAL_EFUNC );
989 }
990
991 // Switch timed statistic
993
994 // Compute transient-line-robust log10(B_S/GL) statistic per frequency
995 if ( mainloop_stats & WEAVE_STATISTIC_BSGLtL ) {
996 XLAL_CHECK( XLALVectorComputeBSGLtL( semi_res->log10BSGLtL->data, sum2F, sum2F_det, max2F_det, semi_res->nfreqs, semi_res->statistics_params->BSGL_setup ) == XLAL_SUCCESS, XLAL_EFUNC );
997 }
998
999 // Switch timed statistic
1001
1002 // Compute transient-signal line-robust log10(B_tS/GL) statistic per frequency
1003 if ( mainloop_stats & WEAVE_STATISTIC_BtSGLtL ) {
1004 XLAL_CHECK( XLALVectorComputeBtSGLtL( semi_res->log10BtSGLtL->data, max2F, sum2F_det, max2F_det, semi_res->nfreqs, semi_res->statistics_params->BSGL_setup ) == XLAL_SUCCESS, XLAL_EFUNC );
1005 }
1006
1007 // Stop timing of semicoherent results
1009
1010 return XLAL_SUCCESS;
1011
1012}
1013
1014///
1015/// Destroy final semicoherent results
1016///
1018 WeaveSemiResults *semi_res
1019)
1020{
1021 if ( semi_res == NULL ) {
1022 return;
1023 }
1024
1025 XLALFree( semi_res->coh_index );
1026 XLALFree( semi_res->coh_phys );
1027 XLALFree( semi_res->coh2F );
1028#ifdef LALPULSAR_CUDA_ENABLED
1029 cudaFree( semi_res->coh2F_CUDA );
1030#endif
1031
1032#ifdef LALPULSAR_CUDA_ENABLED
1033 if ( semi_res->max2F != NULL ) {
1034 if ( semi_res->max2F->data != NULL ) {
1035 cudaFree( semi_res->max2F->data );
1036 }
1037 XLALFree( semi_res->max2F );
1038 }
1039 if ( semi_res->sum2F != NULL ) {
1040 if ( semi_res->sum2F->data != NULL ) {
1041 cudaFree( semi_res->sum2F->data );
1042 }
1043 XLALFree( semi_res->sum2F );
1044 }
1045#else
1046 XLALDestroyREAL4VectorAligned( semi_res->max2F );
1047 XLALDestroyREAL4VectorAligned( semi_res->sum2F );
1048#endif
1049 XLALDestroyREAL4VectorAligned( semi_res->mean2F );
1050
1051 for ( size_t i = 0; i < PULSAR_MAX_DETECTORS; ++i ) {
1052 XLALFree( semi_res->coh2F_det[i] );
1053 XLALDestroyREAL4VectorAligned( semi_res->max2F_det[i] );
1054 XLALDestroyREAL4VectorAligned( semi_res->sum2F_det[i] );
1055 }
1056 XLALDestroyREAL4VectorAligned( semi_res->log10BSGL );
1057 XLALDestroyREAL4VectorAligned( semi_res->log10BSGLtL );
1058 XLALDestroyREAL4VectorAligned( semi_res->log10BtSGLtL );
1059
1060 XLALFree( semi_res );
1061 return;
1062
1063}
1064
1065
1066/// Simple API function to extract pointers to 2F results from WeaveCohResults
1068 REAL4Vector **coh2F,
1070 BOOLEAN *have_coh2F_det,
1071 WeaveCohResults *coh_res,
1072 const WeaveCohInput *coh_input
1073)
1074{
1075 XLAL_CHECK( coh_input != NULL, XLAL_EINVAL );
1076 XLAL_CHECK( coh_res != NULL, XLAL_EINVAL );
1077 XLAL_CHECK( coh_res->nfreqs >= 1, XLAL_EINVAL );
1078 XLAL_CHECK( coh2F != NULL && coh2F_det != NULL, XLAL_EINVAL );
1079 XLAL_CHECK( have_coh2F_det != NULL, XLAL_EINVAL );
1080 XLAL_CHECK( !( coh_input->Fstat_what_to_compute & FSTATQ_2F_CUDA ), XLAL_EINVAL );
1081
1082 ( *coh2F ) = coh_res->coh2F;
1083 ( *have_coh2F_det ) = 0;
1084 if ( coh_input->Fstat_what_to_compute & FSTATQ_2F_PER_DET ) {
1085 ( *have_coh2F_det ) = 1;
1086 // Set all pointers to NULL first, the copy only the results from 'active' IFOs
1087 memset( coh2F_det, 0, PULSAR_MAX_DETECTORS * sizeof( coh2F_det[0] ) );
1088 for ( UINT4 i = 0; i < coh_input->Fstat_ndetectors; ++i ) {
1089 const size_t idx = coh_input->Fstat_res_idx[i];
1090 coh2F_det[idx] = coh_res->coh2F_det[idx];
1091 }
1092 }
1093
1094 return XLAL_SUCCESS;
1095}
1096
1097/// Extract 2F results from WeaveSemiResults; handles results stores in CUDA device memory
1099 REAL4 *coh2F,
1100 const WeaveSemiResults *semi_res,
1101 const UINT4 freq_idx
1102)
1103{
1104
1105 // Check input
1106 XLAL_CHECK( coh2F != NULL, XLAL_EFAULT );
1107 XLAL_CHECK( semi_res != NULL, XLAL_EFAULT );
1108 XLAL_CHECK( freq_idx < semi_res->nfreqs, XLAL_EINVAL );
1109
1110 if ( semi_res->coh2F_CUDA != NULL ) {
1111#ifdef LALPULSAR_CUDA_ENABLED
1112 for ( size_t j = 0; j < semi_res->nsegments; ++j ) {
1113 if ( semi_res->coh2F_CUDA[j] != NULL ) {
1114 XLAL_CHECK_CUDA_CALL( cudaMemcpy( ( void * )&coh2F[j], &semi_res->coh2F_CUDA[j][freq_idx], sizeof( coh2F[j] ), cudaMemcpyDeviceToHost ) );
1115 } else {
1116 coh2F[j] = NAN;
1117 }
1118 }
1119#else
1120 XLAL_ERROR( XLAL_EFAILED, "CUDA not enabled" );
1121#endif
1122 } else {
1123 for ( size_t j = 0; j < semi_res->nsegments; ++j ) {
1124 if ( semi_res->coh2F[j] != NULL ) {
1125 coh2F[j] = semi_res->coh2F[j][freq_idx];
1126 } else {
1127 coh2F[j] = NAN;
1128 }
1129 }
1130 }
1131
1132 return XLAL_SUCCESS;
1133
1134}
1135
1136// Local Variables:
1137// c-file-style: "linux"
1138// c-basic-offset: 2
1139// End:
void XLALWeaveCohResultsDestroy(WeaveCohResults *coh_res)
Destroy coherent results.
int XLALWeaveSemiResultsComputeMain(WeaveSemiResults *semi_res, WeaveSearchTiming *tim)
Compute all remaining toplist-ranking semicoherent statistics (ie 'mainloop-statistics').
void XLALWeaveCohInputDestroy(WeaveCohInput *coh_input)
Destroy coherent input data.
int XLALWeaveCohInputWriteInfo(FITSFile *file, const size_t ncoh_input, WeaveCohInput *const *coh_input)
Write various information from coherent input data to a FITS file.
int XLALWeaveCohInputWriteSegInfo(FITSFile *file, const size_t ncoh_input, WeaveCohInput *const *coh_input)
Write various segment information from coherent input data to a FITS file.
const UINT4 alignment
Aligned arrays use maximum required alignment, i.e. 32 bytes for AVX.
int XLALWeaveSemiResultsInit(WeaveSemiResults **semi_res, const WeaveSimulationLevel simulation_level, const UINT4 ndetectors, const UINT4 nsegments, const UINT8 semi_index, const PulsarDopplerParams *semi_phys, const double dfreq, const UINT4 semi_nfreqs, const WeaveStatisticsParams *statistics_params)
Create and initialise semicoherent results.
void XLALWeaveSemiResultsDestroy(WeaveSemiResults *semi_res)
Destroy final semicoherent results.
#define XLAL_CHECK_CUDA_CALL(...)
int XLALWeaveCohResultsExtract(REAL4Vector **coh2F, REAL4Vector *coh2F_det[PULSAR_MAX_DETECTORS], BOOLEAN *have_coh2F_det, WeaveCohResults *coh_res, const WeaveCohInput *coh_input)
Simple API function to extract pointers to 2F results from WeaveCohResults.
int XLALWeaveCohResultsCompute(WeaveCohResults **coh_res, WeaveCohInput *coh_input, const PulsarDopplerParams *coh_phys, const UINT4 coh_nfreqs, WeaveSearchTiming *tim)
Create and compute coherent results.
WeaveCohInput * XLALWeaveCohInputCreate(const LALStringVector *setup_detectors, const WeaveSimulationLevel simulation_level, const SFTCatalog *sft_catalog, const UINT4 segment_index, const LALSeg *segment, const PulsarDopplerParams *min_phys, const PulsarDopplerParams *max_phys, const double dfreq, const EphemerisData *ephemerides, const LALStringVector *sft_noise_sqrtSX, const LALStringVector *Fstat_assume_sqrtSX, FstatOptionalArgs *Fstat_opt_args, WeaveStatisticsParams *statistics_params, BOOLEAN recalc_stage)
Create coherent input data.
int XLALWeaveSemiCoh2FExtract(REAL4 *coh2F, const WeaveSemiResults *semi_res, const UINT4 freq_idx)
Extract 2F results from WeaveSemiResults; handles results stores in CUDA device memory.
int XLALWeaveSemiResultsComputeSegs(WeaveSemiResults *semi_res, const UINT4 nsegments, const WeaveCohResults **coh_res, const UINT8 *coh_index, const UINT4 *coh_offset, WeaveSearchTiming *tim)
Add a new set of coherent results to the semicoherent results.
Module which computes coherent and semicoherent results.
int XLALVectorsAddREAL4CUDA(REAL4 *sum, const REAL4 **vec, const size_t nvec, const size_t nbin)
Add nvec vectors in vec[], of length nbin, and return the result in sum.
int XLALVectorsMaxREAL4CUDA(REAL4 *max, const REAL4 **vec, const size_t nvec, const size_t nbin)
Find the maximum of nvec vectors in vec[], of length nbin, and return the result in max.
int XLALFITSHeaderWriteUINT4(FITSFile UNUSED *file, const CHAR UNUSED *key, const UINT4 UNUSED value, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:762
int XLALFITSTableWriteRow(FITSFile UNUSED *file, const void UNUSED *record)
Definition: FITSFileIO.c:2550
int XLALFITSTableOpenWrite(FITSFile UNUSED *file, const CHAR UNUSED *name, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:2162
int XLALFITSHeaderWriteREAL4(FITSFile UNUSED *file, const CHAR UNUSED *key, const REAL4 UNUSED value, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:1089
int XLALFITSHeaderWriteString(FITSFile UNUSED *file, const CHAR UNUSED *key, const CHAR UNUSED *value, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:1339
int j
int k
int XLALWeaveSearchTimingStatistic(WeaveSearchTiming *tim, const WeaveStatisticType prev_statistic, const WeaveStatisticType next_statistic)
Change the search statistic currently being timed.
Definition: SearchTiming.c:322
@ WEAVE_SIMULATE
Simulate search (implicitly with full memory allocation)
Definition: Weave.h:82
@ WEAVE_SIMULATE_MIN_MEM
Simulate search with minimal memory allocation.
Definition: Weave.h:84
enum tagWeaveSimulationLevel WeaveSimulationLevel
Definition: Weave.h:60
enum tagWeaveStatisticType WeaveStatisticType
Definition: Weave.h:61
const UserChoices WeaveStatisticChoices
User input choices for all supported statistics.
@ WEAVE_STATISTIC_COH2F
Per segment multi-detector F-statistic.
@ WEAVE_STATISTIC_MAX2F
@ WEAVE_STATISTIC_COH2F_DET
Per segment per-detector F-statistic.
@ WEAVE_STATISTIC_BtSGLtL
(transient-)line robust log10(B_tS/GLtL) statistic
@ WEAVE_STATISTIC_SUM2F_DET
Per detector sum F-statistic.
@ WEAVE_STATISTIC_MAX2F_DET
@ WEAVE_STATISTIC_MEAN2F
Multi-detector average (over segments) F-statistic.
@ WEAVE_STATISTIC_BSGLtL
(transient-)line robust log10(B_S/GLtL) statistic
@ WEAVE_STATISTIC_BSGL
Line-robust log10(B_S/GL) statistic.
@ WEAVE_STATISTIC_NONE
@ WEAVE_STATISTIC_SUM2F
Multi-detector sum (over segments) F-statistic.
const MultiLALDetector * XLALGetFstatInputDetectors(const FstatInput *input)
Returns the detector information stored in a FstatInput structure.
Definition: ComputeFstat.c:687
const CHAR * XLALGetFstatInputMethodName(const FstatInput *input)
Returns the human-readable name of the -statistic method being used by a FstatInput structure.
Definition: ComputeFstat.c:672
int XLALGetFstatInputSFTBand(const FstatInput *input, REAL8 *minFreqFull, REAL8 *maxFreqFull)
Returns the frequency band loaded from input SFTs.
Definition: ComputeFstat.c:650
int XLALGetFstatTiming(const FstatInput *input, FstatTimingGeneric *timingGeneric, FstatTimingModel *timingModel)
Return measured values and details about generic F-statistic timing and method-specific timing model,...
void XLALDestroyFstatInput(FstatInput *input)
Free all memory associated with a FstatInput structure.
Definition: ComputeFstat.c:885
#define TIMING_MODEL_MAX_VARS
Definition: ComputeFstat.h:327
FstatQuantities
Bit-field of -statistic quantities which can be computed by XLALComputeFstat().
Definition: ComputeFstat.h:94
FstatInput * XLALCreateFstatInput(const SFTCatalog *SFTcatalog, const REAL8 minCoverFreq, const REAL8 maxCoverFreq, const REAL8 dFreq, const EphemerisData *ephemerides, const FstatOptionalArgs *optionalArgs)
Create a fully-setup FstatInput structure for computing the -statistic using XLALComputeFstat().
Definition: ComputeFstat.c:359
int XLALComputeFstat(FstatResults **Fstats, FstatInput *input, const PulsarDopplerParams *doppler, const UINT4 numFreqBins, const FstatQuantities whatToCompute)
Compute the -statistic over a band of frequencies.
Definition: ComputeFstat.c:760
@ FSTATQ_2F
Compute multi-detector .
Definition: ComputeFstat.h:96
@ FSTATQ_2F_CUDA
Compute multi-detector , store results on CUDA GPU (CUDA implementation of Resamp only).
Definition: ComputeFstat.h:101
@ FSTATQ_2F_PER_DET
Compute for each detector.
Definition: ComputeFstat.h:98
int XLALParseMultiNoiseFloorMapped(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *multiNoiseFloorDetNames, const LALStringVector *sqrtSX, const LALStringVector *sqrtSXDetNames)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
int XLALInitPulsarSpinRangeFromSpins(PulsarSpinRange *range, const LIGOTimeGPS *refTime, const PulsarSpins fkdot1, const PulsarSpins fkdot2)
Initialise a PulsarSpinRange struct from two PulsarSpins structs.
int XLALCWSignalCoveringBand(REAL8 *minCoverFreq, REAL8 *maxCoverFreq, const LIGOTimeGPS *time1, const LIGOTimeGPS *time2, const PulsarSpinRange *spinRange, const REAL8 binaryMaxAsini, const REAL8 binaryMinPeriod, const REAL8 binaryMaxEcc)
Determines a frequency band which covers the frequency evolution of a band of CW signals between two ...
#define XLAL_FITS_TABLE_COLUMN_BEGIN(record_type)
Definition: FITSFileIO.h:239
#define XLAL_FITS_TABLE_COLUMN_ADD_NAMED(file, type, field, col_name)
Definition: FITSFileIO.h:246
#define XLAL_FITS_TABLE_COLUMN_ADD(file, type, field)
Definition: FITSFileIO.h:243
struct tagFITSFile FITSFile
Representation of a FITS file.
Definition: FITSFileIO.h:54
unsigned char BOOLEAN
uint64_t UINT8
double REAL8
#define XLAL_INIT_DECL(var,...)
uint32_t UINT4
float REAL4
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
void XLALFree(void *p)
int XLALStringCaseCompare(const char *s1, const char *s2)
int XLALVectorComputeBSGLtL(REAL4 *outBSGLtL, const REAL4 *twoF, const REAL4 *twoFPerDet[PULSAR_MAX_DETECTORS], const REAL4 *maxTwoFSegPerDet[PULSAR_MAX_DETECTORS], const UINT4 len, const BSGLSetup *setup)
int XLALVectorComputeBSGL(REAL4 *outBSGL, const REAL4 *twoF, const REAL4 *twoFPerDet[PULSAR_MAX_DETECTORS], const UINT4 len, const BSGLSetup *setup)
int XLALVectorComputeBtSGLtL(REAL4 *outBtSGLtL, const REAL4 *maxTwoFSeg, const REAL4 *twoFPerDet[PULSAR_MAX_DETECTORS], const REAL4 *maxTwoFSegPerDet[PULSAR_MAX_DETECTORS], const UINT4 len, const BSGLSetup *setup)
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
void XLALDestroyMultiSFTCatalogView(MultiSFTCatalogView *multiView)
Destroys a MultiSFTCatalogView, without freeing the original catalog that the 'view' was referring to...
Definition: SFTcatalog.c:496
CHAR * XLALGetChannelPrefix(const CHAR *name)
Find the valid CW detector prefix.
Definition: SFTnaming.c:203
MultiSFTCatalogView * XLALGetMultiSFTCatalogView(const SFTCatalog *catalog)
Return a MultiSFTCatalogView generated from an input SFTCatalog.
Definition: SFTcatalog.c:380
LALStringVector * XLALListIFOsInCatalog(const SFTCatalog *catalog)
Return a sorted string vector listing the unique IFOs in the given catalog.
Definition: SFTcatalog.c:562
int XLALSFTCatalogTimeslice(SFTCatalog *slice, const SFTCatalog *catalog, const LIGOTimeGPS *minStartGPS, const LIGOTimeGPS *maxStartGPS)
Set a SFT catalog 'slice' to a timeslice of a larger SFT catalog 'catalog', with entries restricted t...
Definition: SFTcatalog.c:624
void XLALDestroyStringVector(LALStringVector *vect)
char * XLALConcatStringVector(const LALStringVector *strings, const char *sep)
INT4 XLALFindStringInVector(const char *needle, const LALStringVector *haystack)
char * XLALPrintStringValueOfUserFlag(const int *valFlag, const UserChoices *flagData)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
REAL4Vector * XLALResizeREAL4Vector(REAL4Vector *vector, UINT4 length)
int XLALVectorScaleREAL4(REAL4 *out, REAL4 scalar, const REAL4 *in, const UINT4 len)
void XLALDestroyREAL4VectorAligned(REAL4VectorAligned *in)
int XLALVectorMaxREAL4(REAL4 *out, const REAL4 *in1, const REAL4 *in2, const UINT4 len)
int XLALVectorAddREAL4(REAL4 *out, const REAL4 *in1, const REAL4 *in2, const UINT4 len)
REAL4VectorAligned * XLALResizeREAL4VectorAligned(REAL4VectorAligned *in, const UINT4 length, const UINT4 align)
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EERR
XLAL_ESIZE
XLAL_EINVAL
XLAL_EFAILED
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
float data[BLOCKSIZE]
Definition: hwinject.c:360
string prefix
CHAR name[LALNameLength]
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Struct of optional 'advanced level' and (potentially method-specific) arguments to be passed to the ...
Definition: ComputeFstat.h:137
MultiNoiseFloor * injectSqrtSX
Single-sided PSD values for fake Gaussian noise to be added to SFT data.
Definition: ComputeFstat.h:144
MultiNoiseFloor * assumeSqrtSX
Single-sided PSD values to be used for computing SFT noise weights instead of from a running median o...
Definition: ComputeFstat.h:145
FstatInput * prevInput
An FstatInput structure from a previous call to XLALCreateFstatInput(); may contain common workspace ...
Definition: ComputeFstat.h:146
BOOLEAN collectTiming
a flag to turn on/off the collection of F-stat-method-specific timing-data
Definition: ComputeFstat.h:147
XLALComputeFstat() computed results structure.
Definition: ComputeFstat.h:202
UINT4 numDetectors
Number of detectors over which the were computed.
Definition: ComputeFstat.h:221
REAL4 * twoFPerDet[PULSAR_MAX_DETECTORS]
If whatWasComputed & FSTATQ_2F_PER_DET is true, the values computed at numFreqBins frequencies space...
Definition: ComputeFstat.h:277
REAL4 * twoF_CUDA
If whatWasComputed & FSTATQ_2F_CUDA is true, the multi-detector values as for twoF,...
Definition: ComputeFstat.h:248
UINT4 numFreqBins
Number of frequencies at which the were computed.
Definition: ComputeFstat.h:217
REAL4 * twoF
If whatWasComputed & FSTATQ_2F is true, the multi-detector values computed at numFreqBins frequencie...
Definition: ComputeFstat.h:242
Generic F-stat timing coefficients (times in seconds) [see https://dcc.ligo.org/LIGO-T1600531-v4 for ...
Definition: ComputeFstat.h:316
Struct to carry the -statistic method-specific timing model in terms of a list of variable names and...
Definition: ComputeFstat.h:335
LALFrDetector frDetector
CHAR prefix[3]
LIGOTimeGPS end
INT4 id
LIGOTimeGPS start
array of detectors definitions 'LALDetector'
UINT4 length
number of detectors
LALDetector sites[PULSAR_MAX_DETECTORS]
array of site information
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
A multi-SFT-catalogue "view": a multi-IFO vector of SFT-catalogs.
Definition: SFTfileIO.h:255
SFTCatalog * data
array of SFT-catalog pointers
Definition: SFTfileIO.h:260
UINT4 length
number of detectors
Definition: SFTfileIO.h:259
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ... ] where fkdot = d^kFreq/dt^k.
LIGOTimeGPS refTime
Reference time of pulsar parameters (in SSB!)
Contains a "spin-range", ie spins and corresponding bands at a given (SSB) reference GPS-time .
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
UINT4 length
number of SFTs in catalog
Definition: SFTfileIO.h:242
SFTtype header
SFT-header info.
Definition: SFTfileIO.h:228
Input data segment info.
REAL8 sft_max_freq
Maximum of frequency range loaded from SFTs.
REAL8 sft_min_freq
Minimum of frequency range loaded from SFTs.
LIGOTimeGPS segment_start
Start time of segment.
LIGOTimeGPS segment_end
End time of segment.
Input data required for computing coherent results.
BOOLEAN seg_info_have_sft_info
Whether input data segment info contains SFT info.
FstatQuantities Fstat_what_to_compute
What F-statistic quantities to compute.
segment_info seg_info
Input data segment info.
WeaveSimulationLevel simulation_level
Bitflag representing search simulation level.
UINT4 Fstat_ndetectors
Number of detectors in F-statistic data.
size_t Fstat_res_idx[PULSAR_MAX_DETECTORS]
Map detectors in F-statistic data in this segment to 'global' detector list across segments in cohere...
const LALStringVector * setup_detectors
List of detector names from setup file.
FstatInput * Fstat_input
F-statistic input data.
BOOLEAN Fstat_collect_timing
Whether F-statistic timing info is being collected.
Results of a coherent computation on a single segment.
UINT4 nfreqs
Number of frequencies.
REAL4Vector * coh2F_det[PULSAR_MAX_DETECTORS]
Per-detector F-statistics per frequency.
REAL4Vector coh2F_CUDA
Multi-detector F-statistics per frequency, stored in CUDA device memory.
REAL4Vector * coh2F
Multi-detector F-statistics per frequency.
PulsarDopplerParams coh_phys
Coherent template parameters of the first frequency bin.
#define max(a, b)