Unverified Commit 0d0c5e29 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

make KOKKOS and KSPACE FFT3d code more consistent and remove redundant code

parent 99cfc9e6
Loading
Loading
Loading
Loading
+6 −31
Original line number Diff line number Diff line
@@ -147,11 +147,11 @@ public:

  KOKKOS_INLINE_FUNCTION
  void operator() (const int &i) const {
#if defined(FFT_FFTW3) || defined(FFT_CUFFT) || defined(FFT_MKL)
#if defined(FFT_FFTW3) || defined(FFT_CUFFT)
    FFT_SCALAR* out_ptr = (FFT_SCALAR *)(d_out.data()+i);
    *(out_ptr++) *= norm;
    *(out_ptr++) *= norm;
#else
#else    /* FFT_MKL or FFT_KISS */
    d_out(i,0) *= norm;
    d_out(i,1) *= norm;
#endif
@@ -634,15 +634,6 @@ struct fft_plan_3d_kokkos<DeviceType>* FFT3dKokkos<DeviceType>::fft_3d_create_pl
#endif
  DftiCommitDescriptor(plan->handle_slow);

  if (scaled == 0)
    plan->scaled = 0;
  else {
    plan->scaled = 1;
    plan->norm = 1.0/(nfast*nmid*nslow);
    plan->normnum = (out_ihi-out_ilo+1) * (out_jhi-out_jlo+1) *
      (out_khi-out_klo+1);
  }

#elif defined(FFT_FFTW3)

#if defined (FFT_FFTW_THREADS)
@@ -689,16 +680,8 @@ struct fft_plan_3d_kokkos<DeviceType>* FFT3dKokkos<DeviceType>::fft_3d_create_pl
                       NULL,&nslow,1,plan->length3,
                       FFTW_BACKWARD,FFTW_ESTIMATE);

  if (scaled == 0)
    plan->scaled = 0;
  else {
    plan->scaled = 1;
    plan->norm = 1.0/(nfast*nmid*nslow);
    plan->normnum = (out_ihi-out_ilo+1) * (out_jhi-out_jlo+1) *
      (out_khi-out_klo+1);
  }

#elif defined(FFT_CUFFT)

  cufftPlanMany(&(plan->plan_fast), 1, &nfast,
    &nfast,1,plan->length1,
    &nfast,1,plan->length1,
@@ -714,16 +697,8 @@ struct fft_plan_3d_kokkos<DeviceType>* FFT3dKokkos<DeviceType>::fft_3d_create_pl
    &nslow,1,plan->length3,
    CUFFT_TYPE,plan->total3/plan->length3);

  if (scaled == 0)
    plan->scaled = 0;
  else {
    plan->scaled = 1;
    plan->norm = 1.0/(nfast*nmid*nslow);
    plan->normnum = (out_ihi-out_ilo+1) * (out_jhi-out_jlo+1) *
      (out_khi-out_klo+1);
  }
#else  /* FFT_KISS */

#else
  kissfftKK = new KissFFTKokkos<DeviceType>();

  plan->cfg_fast_forward = KissFFTKokkos<DeviceType>::kiss_fft_alloc_kokkos(nfast,0,NULL,NULL);
@@ -751,6 +726,8 @@ struct fft_plan_3d_kokkos<DeviceType>* FFT3dKokkos<DeviceType>::fft_3d_create_pl
    plan->cfg_slow_backward = KissFFTKokkos<DeviceType>::kiss_fft_alloc_kokkos(nslow,1,NULL,NULL);
  }

#endif

  if (scaled == 0)
    plan->scaled = 0;
  else {
@@ -760,8 +737,6 @@ struct fft_plan_3d_kokkos<DeviceType>* FFT3dKokkos<DeviceType>::fft_3d_create_pl
      (out_khi-out_klo+1);
  }

#endif

  return plan;
}

+5 −21
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan)
      *(out_ptr++) *= norm;
#elif defined(FFT_MKL)
      out[i] *= norm;
#else
#else  /* FFT_KISS */
      out[i].re *= norm;
      out[i].im *= norm;
#endif
@@ -516,15 +516,6 @@ struct fft_plan_3d *fft_3d_create_plan(
#endif
  DftiCommitDescriptor(plan->handle_slow);

  if (scaled == 0)
    plan->scaled = 0;
  else {
    plan->scaled = 1;
    plan->norm = 1.0/(nfast*nmid*nslow);
    plan->normnum = (out_ihi-out_ilo+1) * (out_jhi-out_jlo+1) *
      (out_khi-out_klo+1);
  }

#elif defined(FFT_FFTW3)
#if defined(FFT_FFTW_THREADS)
  if (nthreads > 1) {
@@ -564,15 +555,8 @@ struct fft_plan_3d *fft_3d_create_plan(
                            NULL,&nslow,1,plan->length3,
                            FFTW_BACKWARD,FFTW_ESTIMATE);

  if (scaled == 0)
    plan->scaled = 0;
  else {
    plan->scaled = 1;
    plan->norm = 1.0/(nfast*nmid*nslow);
    plan->normnum = (out_ihi-out_ilo+1) * (out_jhi-out_jlo+1) *
      (out_khi-out_klo+1);
  }
#else
#else /* FFT_KISS */

  plan->cfg_fast_forward = kiss_fft_alloc(nfast,0,NULL,NULL);
  plan->cfg_fast_backward = kiss_fft_alloc(nfast,1,NULL,NULL);

@@ -598,6 +582,8 @@ struct fft_plan_3d *fft_3d_create_plan(
    plan->cfg_slow_backward = kiss_fft_alloc(nslow,1,NULL,NULL);
  }

#endif

  if (scaled == 0)
    plan->scaled = 0;
  else {
@@ -607,8 +593,6 @@ struct fft_plan_3d *fft_3d_create_plan(
      (out_khi-out_klo+1);
  }

#endif

  return plan;
}