
/*******************************************************************************
*
* File flags.h
*
* Copyright (C) 2005, 2007 Martin Luescher
*
* This software is distributed under the terms of the GNU General Public
* License (GPL)
*
*******************************************************************************/

#ifndef FLAGS_H
#define FLAGS_H

#ifndef SU3_H
#include "su3.h"
#endif

typedef enum
{
   GCR_BLOCKS,HMC_BLOCKS,DFL_BLOCKS,
   BLK_GRIDS
} blk_grid_t;

typedef enum
{
   ZOPNOHAT_DBLE,ZOPHAT_DBLE,ZOPNOHAT,ZOPHAT,
   ZOPS
} zops_t;

typedef enum
{
   FREED_U,FREED_UD,NEW_U,NEW_UD,ASSIGNED_U2UD,ASSIGNED_UD2U,
   COPIED_BND_U,COPIED_BND_UD,FREED_BNDBUFS_U,FREED_BNDBUFS_UD,
   SHIFTED_U,SHIFTED_UD,FLIPPED_BC,FLIPPED_BCD,
   FREED_SW,FREED_SWD,COMPUTED_SWD,
   ASSIGNED_SWD2SW,INVERTED_SWD_E,INVERTED_SWD_O,
   INVERTED_SW_E,INVERTED_SW_O,
   CHANGED_QUARK_MASS,CHANGED_CSW,
   ALLOCATED_BLOCK_GRID,FREED_BLOCK_GRID,
   ALLOCATED_MSAP_BUFS,FREED_MSAP_BUFS,
   ASSIGNED_U2UBGR,ASSIGNED_UD2UBGR,ASSIGNED_UD2UDBGR,
   NEW_ACTIVE_UD,SWAPPED_ACTIVE,ASSIGNED_UDB2UB,
   ASSIGNED_SWD2SWBGR,ASSIGNED_SWD2SWDBGR,ASSIGNED_SWDBGR2SWD,COMPUTED_SWB,
   NEW_DFLMODES,COMPUTED_ZOPNOHATDBLE,COMPUTED_ZOPHATDBLE,
   COMPUTED_ZOPNOHAT,COMPUTED_ZOPHAT,FREED_ZOPS,
   EVENTS
} event_t;

typedef enum
{
   ACTION,ACTION_DBLE,SW_TERM,SW_TERM_INACTIVE,
   QHAT,QNOHAT,QEO,QOE,
   QHAT_DBLE,QNOHAT_DBLE,QEO_DBLE,QOE_DBLE,
   ASSIGN_U2UD,ASSIGN_UD2U,ASSIGN_SWD2SW,
   SHIFT_U,SHIFT_UD,ASSIGN_U2UBGR,ASSIGN_UD2UBGR,ASSIGN_UD2UDBGR,
   SWAP_ACTIVE,ASSIGN_SWD2SWBGR,ASSIGN_SWD2SWDBGR,
   UPDATE_SWDBGR2SWD,CHMASS_SWDBGR2SWD,
   TASKS
} task_t;

typedef enum
{
   U_ALLOCATED,UD_ALLOCATED,U_MATCH_UD,
   BC_FLIPPED,BCD_FLIPPED,
   UBUF_UP2DATE,UDBUF_UP2DATE,
   UBLK_MATCH_UD,UDBLK_MATCH_UD,
   SW_UP2DATE,SW_E_INVERTED,SW_O_INVERTED,
   SWD_UP2DATE,SWD_E_INVERTED,SWD_O_INVERTED,SWB_UP2DATE,
   DFLMODES_INITIALIZED,DFLMODES_UP2DATE,
   ZOPNOHATDBLE_UP2DATE,ZOPHATDBLE_UP2DATE,
   ZOPNOHAT_UP2DATE,ZOPHAT_UP2DATE,
   QUERIES
} query_t;

#ifndef FLAGS_C
extern void set_flags(event_t event);
extern int check_flags(task_t task);
extern int query_flags(query_t query);
extern void print_flags(void);
extern void set_blk_flags(blk_grid_t grid,event_t event,int nb);
extern int check_blk_flags(blk_grid_t grid,task_t task,int nb);
extern int query_blk_flags(blk_grid_t grid,query_t query,int nb);
extern void print_blk_flags(blk_grid_t grid,int nb);
#endif

typedef struct
{
   double beta,kappa,m0,csw;
} lat_parms_t;

typedef struct
{
   int nb,nmr,ncy,nkv;
} gcr_parms_t;

typedef struct
{
   int nb,bc,N0,N1,N2,dfl,cno0,cno1,cno_blk;
   int nmx_acf,nmx_gcr_acf,nmx_rop;
   int nmx_frf,nmx_gcr_frf;
   double tau;
   double res_acf,res_gcr_acf,res_rop;
   double res_frf,res_gcr_frf;
} hmc_parms_t;

typedef struct
{
   int Ns,rinv,rnmr,rncy,rvnmx;
   int vnkv,vnmx,vdnmx;
   double rkappa,rvres;
   double vres,vdres;
} dfl_parms_t;

#ifndef PARMS_C
extern lat_parms_t set_lat_parms(double beta,double kappa,double csw);
extern lat_parms_t lat_parms(void);
extern gcr_parms_t set_gcr_parms(int *bs,int nmr,int ncy,int nkv);
extern gcr_parms_t gcr_parms(void);
extern hmc_parms_t set_hmc_parms(int *bs,int bc,int N0,int N1,int N2,
                                 int dfl,int cno0,int cno1,int cno_blk,
                                 int nmx_acf,int nmx_gcr_acf,int nmx_rop,
                                 int nmx_frf,int nmx_gcr_frf,
                                 double tau,
                                 double res_acf,double res_gcr_acf,
                                 double res_rop,
                                 double res_frf,double res_gcr_frf);
extern hmc_parms_t hmc_parms(void);
extern dfl_parms_t set_dfl_parms(int *bs,int Ns,int rinv,int rnmr,int rncy,
                                 int rvnmx,int vnkv,int vnmx,int vdnmx,
                                 double rkappa,double rvres,double vres,
                                 double vdres,int no_v,int no_vd);
extern dfl_parms_t dfl_parms(void);
extern void set_dfl_residues(double vres,double vdres);
#endif

#ifndef WSPACE_C
extern spinor **reserve_ws(int n);
extern int release_ws(void);
extern int ws_size(void);
extern spinor_dble **reserve_wsd(int n);
extern int release_wsd(void);
extern int wsd_size(void);
extern complex **reserve_wv(int n);
extern int release_wv(void);
extern int wv_size(void);
extern complex_dble **reserve_wvd(int n);
extern int release_wvd(void);
extern int wvd_size(void);
#endif

#endif
