<commit_before>// Copyright 2017 - , Dr.-Ing. <NAME>
// SPDX-License-Identifier: BSD-2-Clause

#if MACOS
#  include <sys/param.h>
#  include <sys/sysctl.h>
#endif
#include <sys/utsname.h>    /* for uname */
#include <unistd.h>         /* for getopt */
#include <getopt.h>         /* for getopt_long; standard getopt is in unistd.h */
#include <stdio.h>          /* for printf */
#include <stdlib.h>         /* for atoi */
#include <string.h>         /* for strcmp */
#include "config.h"
#include "check_hw.h"
#include "kernel.h"

#define elemsof( x )        (sizeof( (x) ) / sizeof( (x)[0] ))

unsigned sym_kern_c = 0;
sym_kernel_t* sym_kern[32];

void default_values( config_t * config ) {
  config->width     = 2300;
  config->height    = 748;
  config->timesteps = 100;
  config->pulseY    = config->height / 2;
  config->pulseX    = config->width / 2;
  config->variant   = sym_kern[0];
  config->threads   = 1;

  config->output    = 0;
  config->ascii     = 0; // will also be used for scale!
  config->verbose   = 1;
}

void print_usage( const char * argv0 ) {
  config_t c;
  default_values( &c );

  printf("\n"
         "usage: %s [options] \n"
         "\n"
         "  --width \t( -y )                    Default: %u\n"
         "  \t Define vertical matrix size.\n"
         "  --height \t( -x )                    Default: %u\n"
         "  \t Define horizontal matrix size.\n"
         "  --pulseY \t( -i )                    Default: %u\n"
         "  \t y coordinate of pulse offset.\n"
         "  --pulseX \t( -j )                    Default: %u\n"
         "  \t x coordinate of pulse offset.\n"
         "  --timesteps \t( -t )                    Default: %u\n"
         "  \t Determine number of timesteps.\n"
         "  --kernel \t( -k )                    Default: %s\n",
          argv0, c.height, c.width, c.pulseY, c.pulseX, c.timesteps, sym_kern[0]->name );

  archfeatures cap = check_hw_capabilites();
  unsigned i;
  for( i = 0; i < sym_kern_c; i++ )
    if( ! (sym_kern[i]->cap.bits & ~cap.bits) )
      printf("  \t %s\n", sym_kern[i]->name );

  printf("  --threads \t( -p )                    Default: %u\n"
         "  \t Number of threads.\n"
         "  --output \t( -o )                    Default: \"output.bin\"\n"
         "  \t Write output to file 'file'.\n"
         "  --ascii\t( -a ) <scale>            Default: %u\n"
         "  \t Print an ascii image.\n"
         "  \t Parameter will be used as scale.\n"
         "  --quite\t( -q)\n"
         "  \t Run without verbose output.\n"
         "  --help \t( -h )\n"
         "  \t Show this help page.\n", c.threads, c.ascii );
}

unsigned long round_and_get_unit( unsigned long mem, char * type ) {
  char types[] = { ' ', 'K', 'M', 'G', 'T' };

  unsigned i;
  for( i = 0; i < elemsof(types); i++ ) {
    if( mem < (1<<10) ) {
      *type = types[i];
      return mem;
    }
    mem >>= 10;
  }

  *type = 'P';
  return mem;
}

void get_config( int argc, char * argv[], config_t * config ) {

  if( ! sym_kern_c ) {
    fprintf(stderr, "ERROR: no kernels compiled into!\n");
    exit(EXIT_FAILURE);
  }

  default_values( config );

/*** Getopt ***/
  struct option long_options[] = {
//  name            has_arg             flag            var
    {"height",      required_argument,  NULL,           'x'},
    {"width",       required_argument,  NULL,           'y'},
    {"pulseY",      required_argument,  NULL,           'i'},
    {"pulseX",      required_argument,  NULL,           'j'},
    {"timesteps",   required_argument,  NULL,           't'},
    {"kernel",      required_argument,  NULL,           'k'},
    {"threads",     required_argument,  NULL,           'p'},
    {"output",      no_argument,        NULL,           'o'},
    {"ascii",       required_argument,  NULL,           'a'},
    {"help",        no_argument,        NULL,           'h'},
    {"quite",       no_argument,        NULL,           'q'},

    {NULL,          0,                  NULL,            0 }
  };

  archfeatures cap = check_hw_capabilites();
  while( 1 ) {
    int option_index = 0;
    int opt = getopt_long( argc, argv, "x:y:i:j:t:k:p:hq", long_options, &option_index );
    if( opt == -1 )
      break;

    switch (opt) {
      case 'y':
        config->width = atoi( optarg );<commit_msg>Fix short parameters 'o' and 'a'<commit_after>// Copyright 2017 - , Dr.-Ing. <NAME>
// SPDX-License-Identifier: BSD-2-Clause

#if MACOS
#  include <sys/param.h>
#  include <sys/sysctl.h>
#endif
#include <sys/utsname.h>    /* for uname */
#include <unistd.h>         /* for getopt */
#include <getopt.h>         /* for getopt_long; standard getopt is in unistd.h */
#include <stdio.h>          /* for printf */
#include <stdlib.h>         /* for atoi */
#include <string.h>         /* for strcmp */
#include "config.h"
#include "check_hw.h"
#include "kernel.h"

#define elemsof( x )        (sizeof( (x) ) / sizeof( (x)[0] ))

unsigned sym_kern_c = 0;
sym_kernel_t* sym_kern[32];

void default_values( config_t * config ) {
  config->width     = 2300;
  config->height    = 748;
  config->timesteps = 100;
  config->pulseY    = config->height / 2;
  config->pulseX    = config->width / 2;
  config->variant   = sym_kern[0];
  config->threads   = 1;

  config->output    = 0;
  config->ascii     = 0; // will also be used for scale!
  config->verbose   = 1;
}

void print_usage( const char * argv0 ) {
  config_t c;
  default_values( &c );

  printf("\n"
         "usage: %s [options] \n"
         "\n"
         "  --width \t( -y )                    Default: %u\n"
         "  \t Define vertical matrix size.\n"
         "  --height \t( -x )                    Default: %u\n"
         "  \t Define horizontal matrix size.\n"
         "  --pulseY \t( -i )                    Default: %u\n"
         "  \t y coordinate of pulse offset.\n"
         "  --pulseX \t( -j )                    Default: %u\n"
         "  \t x coordinate of pulse offset.\n"
         "  --timesteps \t( -t )                    Default: %u\n"
         "  \t Determine number of timesteps.\n"
         "  --kernel \t( -k )                    Default: %s\n",
          argv0, c.height, c.width, c.pulseY, c.pulseX, c.timesteps, sym_kern[0]->name );

  archfeatures cap = check_hw_capabilites();
  unsigned i;
  for( i = 0; i < sym_kern_c; i++ )
    if( ! (sym_kern[i]->cap.bits & ~cap.bits) )
      printf("  \t %s\n", sym_kern[i]->name );

  printf("  --threads \t( -p )                    Default: %u\n"
         "  \t Number of threads.\n"
         "  --output \t( -o )                    Default: \"output.bin\"\n"
         "  \t Write output to file 'file'.\n"
         "  --ascii\t( -a ) <scale>            Default: %u\n"
         "  \t Print an ascii image.\n"
         "  \t Parameter will be used as scale.\n"
         "  --quite\t( -q)\n"
         "  \t Run without verbose output.\n"
         "  --help \t( -h )\n"
         "  \t Show this help page.\n", c.threads, c.ascii );
}

unsigned long round_and_get_unit( unsigned long mem, char * type ) {
  char types[] = { ' ', 'K', 'M', 'G', 'T' };

  unsigned i;
  for( i = 0; i < elemsof(types); i++ ) {
    if( mem < (1<<10) ) {
      *type = types[i];
      return mem;
    }
    mem >>= 10;
  }

  *type = 'P';
  return mem;
}

void get_config( int argc, char * argv[], config_t * config ) {

  if( ! sym_kern_c ) {
    fprintf(stderr, "ERROR: no kernels compiled into!\n");
    exit(EXIT_FAILURE);
  }

  default_values( config );

/*** Getopt ***/
  struct option long_options[] = {
//  name            has_arg             flag            var
    {"height",      required_argument,  NULL,           'x'},
    {"width",       required_argument,  NULL,           'y'},
    {"pulseY",      required_argument,  NULL,           'i'},
    {"pulseX",      required_argument,  NULL,           'j'},
    {"timesteps",   required_argument,  NULL,           't'},
    {"kernel",      required_argument,  NULL,           'k'},
    {"threads",     required_argument,  NULL,           'p'},
    {"output",      no_argument,        NULL,           'o'},
    {"ascii",       required_argument,  NULL,           'a'},
    {"help",        no_argument,        NULL,           'h'},
    {"quite",       no_argument,        NULL,           'q'},

    {NULL,          0,                  NULL,            0 }
  };

  archfeatures cap = check_hw_capabilites();
  while( 1 ) {
    int option_index = 0;
    int opt = getopt_long( argc, argv, "x:y:i:j:t:k:p:oa:hq", long_options, &option_index );
    if( opt == -1 )
      break;

    switch (opt) {
      case 'y':
        config->width = atoi( optarg );
{'fraction_non_alphanumeric': 0.16538819153881915, 'fraction_numerical': 0.009530450953045095, 'mean_word_length': 1.6202801461632157, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 59, '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': '2428014', 'n_tokens_mistral': 3084, 'n_tokens_neox': 2953, 'n_words': 771}