 
   , int timesteps
   , int channels
+  , bool is_half_gcf
   >
 __inline__ __device__
 // grid must be initialized to 0s.

  , int baselines
  , int timesteps
  , int channels
  , bool use_permutations
  >
__device__ __inline__ void addBaselinesToGrid(

#define TIMESTEPS 200
#define CHANNELS 1

#define addBaselineToGrid(suff, ishalf)                                    \
__global__ void addBaselineToGrid##suff(                                   \
    double scale                                                           \
  , int max_supp                                                           \
  , Double4c grid[GRID_SIZE][GRID_SIZE]                                    \
  , const complexd * gcf_layers[WPLANES]                                   \
  , const double3 uvw[TIMESTEPS]                                           \
  , const Double4c vis[TIMESTEPS]                                          \
  ) {                                                                      \
  addBaselineToGrid<OVER, WPLANES, GRID_SIZE, TIMESTEPS, CHANNELS, ishalf> \
    ( scale                                                                \
    , max_supp                                                             \
    , grid                                                                 \
    , gcf_layers                                                           \
    , uvw                                                                  \
    , vis                                                                  \
    );                                                                     \
}
addBaselineToGrid(HalfGCF, true)
addBaselineToGrid(FullGCF, false)

#define addBaselinesToGridSkaMid(suff, ishalf)                                                \
__global__ void addBaselinesToGridSkaMid##suff(                                               \
    double scale                                                                              \
  , const BlWMap permutations[BASELINES]                                                      \
  , Double4c grid[GRID_SIZE][GRID_SIZE]                                                       \
  , const complexd * gcf_layers[WPLANES]                                                      \
  , const double3 uvw[BASELINES][TIMESTEPS]                                                   \
  , const Double4c vis[BASELINES][TIMESTEPS]                                                  \
  ) {                                                                                         \
  addBaselinesToGrid<OVER, WPLANES, GRID_SIZE, BASELINES, TIMESTEPS, CHANNELS, ishalf, false> \
    ( scale                                                                                   \
    , permutations                                                                            \
    , grid                                                                                    \
    , gcf_layers                                                                              \
    , uvw                                                                                     \
    , vis                                                                                     \
    );                                                                                        \
}
addBaselinesToGridSkaMid(HalfGCF, true)
addBaselinesToGridSkaMid(FullGCF, false)

#define addBaselinesToGridSkaMidUsingPermutations(suff, ishalf)                              \
__global__ void addBaselinesToGridSkaMidUsingPermutations##suff(                             \
    double scale                                                                             \
  , const BlWMap permutations[BASELINES]                                                     \
  , Double4c grid[GRID_SIZE][GRID_SIZE]                                                      \
  , const complexd * gcf_layers[WPLANES]                                                     \
  , const double3 uvw[BASELINES][TIMESTEPS]                                                  \
  , const Double4c vis[BASELINES][TIMESTEPS]                                                 \
  ) {                                                                                        \
  addBaselinesToGrid<OVER, WPLANES, GRID_SIZE, BASELINES, TIMESTEPS, CHANNELS, ishalf, true> \
    ( scale                                                                                  \
    , permutations                                                                           \
    , grid                                                                                   \
    , gcf_layers                                                                             \
    , uvw                                                                                    \
    , vis                                                                                    \
    );                                                                                       \
}
addBaselinesToGridSkaMidUsingPermutations(HalfGCF, true)
addBaselinesToGridSkaMidUsingPermutations(FullGCF, false)

__global__ void  extractPolarization(
    int pol
