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

#ifndef SION_SION_GENERIC_COLL_H
#define SION_SION_GENERIC_COLL_H

/// \cond sion_internal
/// \file

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "sion_filedesc.h"

/* collective I/O */

size_t _sion_coll_fwrite_merge(const void *data, size_t size, size_t nitems, int sid);

/*!\brief checks if environment variables are set to use collective I/O
 *
 * - `SION_COLLSIZE = -1`: number of collector is computed by sionlib and depends on chunksizes and filesystem-blocksize
 * - `SION_COLLSIZE =  0`: collective is not used
 * - `SION_COLLSIZE >  0`: number of task to be collected by one (master) task
 *
 * @param *sion_filedesc sion file description struct (_sion_filedesc)
 *
 */
void _sion_coll_check_env(_sion_filedesc *sion_filedesc);

/* callback functions */
int64_t _sion_generic_collective_process_write(const void *data, int64_t *spec, int sid);
bool _sion_generic_collective_next_write_spec(void *iterator, int64_t *spec);

int64_t _sion_generic_collective_process_read(void *data, int64_t *spec, int sid);
bool _sion_generic_collective_next_read_spec(void *iterator, int64_t *spec);

/// \endcond

#endif
