/*--------------------------------------------------------------------
  
  NAS Parallel Benchmarks 2.3 CGD C++ versions - FT
  
  The CGD version was developed at Princeton Univ, derived from the
  OpenMP C version. Info about the CGD project available at:

  http://cs.princeton.edu/~asoviani/CGD/

  ----------------
  
  The OpenMP C versions  are developed by RWCP and derived from the
  serial Fortran versions in "NPB 2.3-serial" developed by NAS.

  Permission to use, copy, distribute and modify this software for any
  purpose with or without fee is hereby granted. This software is
  provided "as is" without express or implied warranty.
  
  Send comments on the OpenMP C versions to pdp-openmp@rwcp.or.jp

  Information on OpenMP activities at RWCP is available at:

           http://pdplab.trc.rwcp.or.jp/pdperf/Omni/
  
  Information on NAS Parallel Benchmarks 2.3 is available at:
  
           http://www.nas.nasa.gov/NAS/NPB/

--------------------------------------------------------------------

  Authors: D. Bailey
           W. Saphir

  OpenMP C version: S. Satoh

  CGD C++ version : A. Soviani
  
--------------------------------------------------------------------*/

#include <unistd.h>
#include "ft_sl.h"

#include "init_sl.c"
#include "fft.c"
#include "aux.c"
#include "other.c"

#include "ft_sl_auto2.cc"

void body (PreEnv *penv)
{
  Alias (int, pe, penv->pe);
  Env *env = new Env; env->pre = *penv;

  compute_setup (*env);

  dpcmBarrier();
  clock_begin(T_TOTAL,pe); clock_begin(T_SETUP,pe); clock_begin(T_MAX,pe);

  compute_setup (*env);

  clock_end(T_MAX,pe); clock_end(T_SETUP,pe); clock_end(T_TOTAL,pe);
  dpcmBarrier();

  boolean succ;
  mainloop (succ, *env);
  finish (env->sp, succ);
}

const char* ck_nm[] = { "total", "setup", "fft", "evolve", "checksum", "fftlow", "fftcopy", "max"};
int ck_fl[] = { 1, 1, 1, 1, 1, 1, 1, 1}; int ck_gr[NOUSRCLKS];

int main (int argc, char **argv)
{
  int c, np = 1;
  dpcmArgs (argc, argv);

  while ((c = getopt (argc, argv, "n:")) != -1) {
    switch(c) {
    case 'n': np = atoi(optarg); break;
    }
  }
  for (int i=0; i<NOUSRCLKS; i++) ck_gr[i] = GR_USR;
  gr1_fl[GR_HPC] = 0; // gr1_fl[GR_LIB] = 0;

  dpcmInit (np); dpcmInitConst ();
  dpcmInitClock (NOUSRCLKS, ck_nm, ck_gr, ck_fl);
  dpcmRun (body);
}

