/****************************************************************************
**  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       **
****************************************************************************/

/*!
 * \cond sion_internal
 * \file
 */

#ifndef SION_SION_INTERNAL_STARTPTR_H
#define SION_SION_INTERNAL_STARTPTR_H

#include <stdint.h>

#include "sion_filedesc.h"
#include "sion_internal_collstat.h"

/*!\brief Calculates the size of the first meta data block
 *
 * @param  *sion_filedesc                       sion file description struct (_sion_filedesc)
 * @param mapping_size number of entries in the mapping information
 *
 * @retval size if ok, otherwise -1
 */
int _sion_get_size_metadatablock1(_sion_filedesc *sion_filedesc, int32_t mapping_size);

/*!\brief Calculate the start pointers
 *
 * @param  *sion_filedesc                       sion file description struct (_sion_filedesc)
 * @param mapping_size number of entries in the mapping information
 *
 * @retval SION_SUCCESS if ok
 */
int _sion_calculate_startpointers(_sion_filedesc *sion_filedesc, int32_t mapping_size);

/*!\brief Calculate the start pointers for collective operations
 *
 * @param  *sion_filedesc                       sion file description struct (_sion_filedesc)
 * @param mapping_size number of entries in the mapping information
 *
 * @retval SION_SUCCESS if ok
 */
int _sion_calculate_startpointers_collective(_sion_filedesc *sion_filedesc, int32_t mapping_size);

/*!\brief Calculate the start pointers for collective operations using special merge mode
 *
 * @param  *sion_filedesc                       sion file description struct (_sion_filedesc)
 * @param mapping_size number of entries in the mapping information
 *
 * @retval SION_SUCCESS if ok
 */
int _sion_calculate_startpointers_collective_merge(_sion_filedesc *sion_filedesc, int32_t mapping_size);

/*!\brief Implements a heuiristic to determine the number of collectors per file
 *
 * @param  *sion_filedesc                       sion file description struct (_sion_filedesc)
 * @param  *collstat
 * @param  *num_collectors
 *
 * @retval SION_SUCCESS if ok
 */
int _sion_calculate_num_collector(_sion_filedesc *sion_filedesc, _sion_collstat *collstat, int *num_collectors);
#endif

/// \endcond
