/****************************************************************************
**  SIONLIB     http://www.fz-juelich.de/jsc/sionlib                       **
*****************************************************************************
**  Copyright (c) 2008-2009                                                **
**  Forschungszentrum Juelich, Juelich Supercomputing Centre               **
**                                                                         **
**  See the file COPYRIGHT in the package base directory for details       **
****************************************************************************/

#ifndef PARTEST_H_
#define PARTEST_H_
/* Enable or disable the checksum */
#define CHECKSUM
#define FNAMELEN 255
#define MB *1024*1024
#define MAXPE 72*4*1024
#define MAXCHARLEN 256

#define WAKEUP   102
#define COLPRINT 103

struct _test_communicators_struct {
  MPI_Comm all;             /* all tasks in mpi program */
  MPI_Comm work;            /* all working tasks, e.g. if bluegene_np is used */
  MPI_Comm workread;        /* all working tasks, shifted by read_task_offset, e.g. if bluegene_np is used */
  MPI_Comm local;           /* tasks which should work on the same file */
  int all_size, all_rank, work_size, work_rank, workread_size, workread_rank, local_size, local_rank;
  int file_number, ionode_number;
};

typedef struct _test_communicators_struct _test_communicators;

int test_paropen_multi_mpi (char *filename,
			    int numfiles,
			    char *localbuffer,
			    sion_int64  bufsize,
			    sion_int64  totalsize,
			    sion_int64  chunksize,
			    sion_int32  fsblksize,
			    int   startoffset,
			    int   verbose,
			    int   debug,
			    int   Debug,
                            _test_communicators *communicators,
			    int collectiveread,
			    int idletask, 
			    int unlink_files);

int test_mpiio_multi_mpi (char *filename,
			  int numfiles,
			  char *localbuffer,
			  sion_int64  bufsize,
			  sion_int64  totalsize,
			  sion_int64  chunksize,
			  sion_int32  fsblksize,
			  int   verbose,
			  int   debug,
			  int   Debug,
                          _test_communicators *communicators,
			  int collectiveread,
			  int idletask,
			  int mpiio_lb,
			  int mpiio_bs,
			  int mpiio_sa, 
			  int unlink_files
			  );

int test_single_mpi (char *filename,
                     int numfiles,
                     char *localbuffer,
                     sion_int64  bufsize,
                     sion_int64  totalsize,
                     sion_int64  chunksize,
                     sion_int32  fsblksize,
                     int   verbose,
                     int   debug,
                     int   Debug,
                     _test_communicators *communicators,
                     int collectiveread,
                     int idletask, 
		     int unlink_files
                     );

int barrier_after_start (MPI_Comm comm);
int barrier_after_malloc(MPI_Comm comm);
int barrier_after_open  (MPI_Comm comm);
int barrier_after_write (MPI_Comm comm);
int barrier_after_read  (MPI_Comm comm);
int barrier_after_close (MPI_Comm comm);
int barrier_before_unlink (MPI_Comm comm);
int barrier_after_unlink (MPI_Comm comm);

int collective_print_gather ( char* cbuffer, MPI_Comm comm);
int collective_print ( char* cbuffer, MPI_Comm comm);

#endif /* PARTEST_H_ */
