<commit_before>#include "config.h"
#include "limits.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "t3pio.h"
#include "t3pio_internal.h"
#include <math.h>

#define min(x,y) (x) > (y) ? y : x;
#define max(x,y) (x) > (y) ? x : y;

#define prt(x) if (myProc == 0) printf("%s:%d: %s: %d\n",__FILE__,__LINE__,#x,x)

int t3pio_set_info(MPI_Comm comm, MPI_Info info, const char* dir, ...)
{

  T3Pio_t t3;
  int     argType;
  int     ierr = 0;
  va_list ap;
  int     nProcs, myProc;
  char    buf[128];
  int     mStripeSz     = -1;
  int     remoteFile    = 0;
  int     maxWritersPer = INT_MAX;
  int*    pNodes        = NULL;

  T3PIO_results_t *results = NULL;


  t3pio_init(&t3);
  
  va_start(ap, dir);

  while ( (argType = va_arg(ap, int)) != 0)
    {
      if (argType <= T3PIO_START_RANGE || argType >= T3PIO_END_RANGE )
        break;

      switch(argType)
        {
        case T3PIO_GLOBAL_SIZE:
          t3.globalSz   = va_arg(ap,int);
          break;
        case T3PIO_MAX_STRIPES:
          t3.maxStripes = va_arg(ap,int);
          break;
        case T3PIO_FACTOR:
          t3.factor = va_arg(ap,int);
          break;
        case T3PIO_MAX_WRITERS:
          t3.maxWriters = va_arg(ap,int);
          break;
        case T3PIO_NUM_NODES:
          pNodes = va_arg(ap, int*);
          break;
        case T3PIO_MAX_WRITER_PER_NODE:
          maxWritersPer = va_arg(ap,int);
          break;
        case T3PIO_MAX_STRIPE_SIZE:
          mStripeSz = va_arg(ap,int);
          break;
        case T3PIO_FILE:
          t3.fn = va_arg(ap,char *);
          break;
        case T3PIO_RESULTS:
          results = va_arg(ap, T3PIO_results_t *);
          break;
        }
    }
  va_end(ap);

  /* Check for valid maxWritersPer */
  if (maxWritersPer < 0)
    maxWritersPer = INT_MAX;

  /* Set max Stripe Sz to make sense:
     a) value 0 or 1 => 1MByte
     b) value > 1    => (value)*1 Mbyte
     c) value < 0    -> INT_MAX  (this means no limitations)
     */

  if (mStripeSz == 0)
    mStripeSz = 1;

  if (mStripeSz > 0)
    mStripeSz = 1 << (19 + mStripeSz);

  if (mStripeSz < 0)
    mStripeSz = INT_MAX;

  MPI_Comm_rank(comm, &myProc);
  MPI_Comm_size(comm, &nProcs);
  
  /* Set factor to 1 unless the user specified something different*/
  if (t3.factor < 0 || t3.factor > 4)
    t3.factor = 1;


  t3pio_numComputerNodes(comm, nProcs, &t3.numNodes, &t3.numCoresPer, &t3.maxCoresPer);
  t3.nodeMem    = t3pio_nodeMemory(comm, myProc);
  t3.stripeSz   = 1024 * 1024;
  if (pNodes) 
    *pNodes     = t3.numNodes;
  
  if (t3.fn && t3.fn[0])
    {
      /* Check for user supplied file for reading */<commit_msg>set stripe size correctly<commit_after>#include "config.h"
#include "limits.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "t3pio.h"
#include "t3pio_internal.h"
#include <math.h>

#define min(x,y) (x) > (y) ? y : x;
#define max(x,y) (x) > (y) ? x : y;

#define prt(x) if (myProc == 0) printf("%s:%d: %s: %d\n",__FILE__,__LINE__,#x,x)

int t3pio_set_info(MPI_Comm comm, MPI_Info info, const char* dir, ...)
{

  T3Pio_t t3;
  int     argType;
  int     ierr = 0;
  va_list ap;
  int     nProcs, myProc;
  char    buf[128];
  int     mStripeSz     = -1;
  int     remoteFile    = 0;
  int     maxWritersPer = INT_MAX;
  int*    pNodes        = NULL;

  T3PIO_results_t *results = NULL;


  t3pio_init(&t3);
  
  va_start(ap, dir);

  while ( (argType = va_arg(ap, int)) != 0)
    {
      if (argType <= T3PIO_START_RANGE || argType >= T3PIO_END_RANGE )
        break;

      switch(argType)
        {
        case T3PIO_GLOBAL_SIZE:
          t3.globalSz   = va_arg(ap,int);
          break;
        case T3PIO_MAX_STRIPES:
          t3.maxStripes = va_arg(ap,int);
          break;
        case T3PIO_FACTOR:
          t3.factor = va_arg(ap,int);
          break;
        case T3PIO_MAX_WRITERS:
          t3.maxWriters = va_arg(ap,int);
          break;
        case T3PIO_NUM_NODES:
          pNodes = va_arg(ap, int*);
          break;
        case T3PIO_MAX_WRITER_PER_NODE:
          maxWritersPer = va_arg(ap,int);
          break;
        case T3PIO_MAX_STRIPE_SIZE:
          mStripeSz = va_arg(ap,int);
          break;
        case T3PIO_FILE:
          t3.fn = va_arg(ap,char *);
          break;
        case T3PIO_RESULTS:
          results = va_arg(ap, T3PIO_results_t *);
          break;
        }
    }
  va_end(ap);

  /* Check for valid maxWritersPer */
  if (maxWritersPer < 0)
    maxWritersPer = INT_MAX;

  /* Set max Stripe Sz to make sense:
     a) value 0 or 1 => 1MByte
     b) value > 1    => (value)*1 Mbyte
     c) value < 0    -> INT_MAX  (this means no limitations)
     */

  if (mStripeSz == 0)
    mStripeSz = 1;

  if (mStripeSz > 0)
    mStripeSz = (1 << 20) * mStripeSz;

  if (mStripeSz < 0)
    mStripeSz = INT_MAX;

  MPI_Comm_rank(comm, &myProc);
  MPI_Comm_size(comm, &nProcs);
  
  /* Set factor to 1 unless the user specified something different*/
  if (t3.factor < 0 || t3.factor > 4)
    t3.factor = 1;


  t3pio_numComputerNodes(comm, nProcs, &t3.numNodes, &t3.numCoresPer, &t3.maxCoresPer);
  t3.nodeMem    = t3pio_nodeMemory(comm, myProc);
  t3.stripeSz   = 1024 * 1024;
  if (pNodes) 
    *pNodes     = t3.numNodes;
  
  if (t3.fn && t3.fn[0])
    {
      /* Check for user supplied file for reading */
{'fraction_non_alphanumeric': 0.12771535580524346, 'fraction_numerical': 0.027340823970037453, 'mean_word_length': 2.17538644470868, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2598630', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2184, 'n_words': 471}