bkloppenborg / liboi

OpenCL Interferometry Library
https://github.com/bkloppenborg/liboi/wiki
GNU Lesser General Public License v3.0
5 stars 6 forks source link

New non-convex chi2 formulation #25

Closed bkloppenborg closed 11 years ago

bkloppenborg commented 12 years ago

In a discussion with Fabien Baron, it appears stars that are well resolved often have underestimated chi2r for the triple products when T3 amplitudes are small. His solution is to implement the non-convex chi2 for the bispectra:

t3amp_residual = (t3amp_data - t3amp)/t3amperr
t3phi_residual = mod360(t3phi_data - t3phi)/t3phi_err

Alternatively, the phase expression can be rewritten as:

abs( exp(complex(0, t3_t3phi) ) - t3_model/abs(t3_model) ) /(t3_t3phierr)

In order to implement this formulation we will need to create a new chi2 kernel and (possibly) rearrange how data is stored on the GPU. In particular, it might be worthwhile to split the T3_amp and T3_phi into two separate memory blocks. Profiling will be needed to ensure memory access patterns do not significantly degrade performance.

bkloppenborg commented 12 years ago

Modifications required:

  1. COILibData: Remove phasor
  2. COILibData::InitData(): Remove data rotation functions.
  3. COILibData::CopyToOpenCLDevice(): Reorder data to be an array in this order: [v2, t3amp, t3phi] when uploaded to the GPU.
  4. COILibData::GetT3(): Fix for new data structure format. Data can be read directly from the mData array.
  5. CRoutine_FTtoT3::FTtoT3() and CRoutine_FTtoT3::FTtoT3_CPU(): Drop phasor from kernel argument. Supply n_t3 as parameter to kernel.
  6. ft_to_t3.cl: Drop phasor. Modify output storage format to be [v2, t3amp, t3phi]. Indexing is [0, n_v2, n_v2 + n_t3]. Drop MultComplex4(), implement MultComplex3 if it saves computation time.
  7. CRoutine_Chi(): Make chi, chi2, GetChi, GetChi2 functions virtual.
  8. Create new CRoutine_Chi_Convex() routine which inherits from CRoutine_Chi. Call standard routines for the first n_v2 +n_t3 data points. Use new kernel chi_t3_convex.cl on the remaining data.
  9. Create new chi_t3_convex.cl kernel which computes the chi on the phase by first projecting bispectra data and model into the Cartesian plane and then computes the standard chi expression.
  10. Create new abstract class, CRoutine_Chi_NonConvex inheriting from CRoutine_Chi. Call standard routines for the first n_v2 + n_t3 data points. Use new kernel chi_t3_nonconvex.cl to do the bispectra.
  11. Create new chi_t3_nonconvex.cl kernel which computes the phase uncertainty as described in the first post.

Note, the chi and chi_t3* variant kernels should be able to execute simultaneously.

bkloppenborg commented 12 years ago

Note, programs that derive from this library may also require changes. For instance in SIMTOI the CMinimizer_Bootstrap::MaskRandom() function expects the T3 data are formatted in a specific order. We will need to alert authors of other software.

bkloppenborg commented 12 years ago

The new chi_bispectra*.cl kernels presently assume zero indexing for the bispectra portion of mData_cl. I suggest we partition out mData_cl into [mV2_cl, mT3_cl] using clCreateSubBuffer and pass these around to the individual routines.