<commit_before>#include "config.h"

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#ifdef _OPENMP
#include <omp.h>
#endif

void
timer_start (struct timespec *const start_time)
{
  clock_gettime(CLOCKTYPE, start_time);
}

void
timer_stop (struct timespec *const end_time)
{
  clock_gettime(CLOCKTYPE, end_time);
}

double
timer_get (const struct timespec *const start_time,
    const struct timespec *const end_time)
{
  return end_time->tv_sec + end_time->tv_nsec/1.0e9
    - (start_time->tv_sec + start_time->tv_nsec/1.0e9);
}

void
work (void)
{
#pragma omp parallel for default(none)
  for(size_t i = 0; i < 100000000; i++)
  {
    double x = sin(i/1.0e-2);
    if(x < -2)
    {
      exit(1);
    }
  }
}

int
main ()
{
  struct timespec start_time;
  struct timespec end_time;

  double elapsed;

#ifdef _OPENMP
#pragma omp parallel
  printf("starting thread %d\n", omp_get_thread_num());
#endif

#ifdef _OPENMP
  printf("%d threads: ", omp_get_max_threads());
#endif
  timer_start(&start_time); work(); timer_stop(&end_time);
  elapsed = timer_get(&start_time, &end_time);
  printf("%e seconds", elapsed);

#ifdef _OPENMP
  printf(", %e seconds serial\n", elapsed*omp_get_max_threads());
#else
  printf(" in serial\n");
#endif

#ifdef _OPENMP
  omp_set_num_threads(1);
  printf("%d threads: ", omp_get_max_threads());
  timer_start(&start_time); work(); timer_stop(&end_time);
  elapsed = timer_get(&start_time, &end_time);
  printf("%e seconds\n", elapsed);
#endif
}<commit_msg>Added command line argument to OpenMP tester.<commit_after>#include "config.h"

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#ifdef _OPENMP
#include <omp.h>
#endif

void
timer_start (struct timespec *const start_time)
{
  clock_gettime(CLOCKTYPE, start_time);
}

void
timer_stop (struct timespec *const end_time)
{
  clock_gettime(CLOCKTYPE, end_time);
}

double
timer_get (const struct timespec *const start_time,
    const struct timespec *const end_time)
{
  return end_time->tv_sec + end_time->tv_nsec/1.0e9
    - (start_time->tv_sec + start_time->tv_nsec/1.0e9);
}

void
work (void)
{
#pragma omp parallel for default(none)
  for(size_t i = 0; i < 100000000; i++)
  {
    double x = sin(i/1.0e-2);
    if(x < -2)
    {
      exit(1);
    }
  }
}

int
main (const int argc, char **argv)
{
  struct timespec start_time;
  struct timespec end_time;

  double elapsed;
  int max_threads = 1;

#ifdef _OPENMP
  if(argc > 1)
  {
    max_threads = strtol(argv[1], NULL, 10);
    omp_set_num_threads(max_threads);
  }

  else
  {
    max_threads = omp_get_max_threads();
  }
#endif

#ifdef _OPENMP
#pragma omp parallel
  printf("starting thread %d\n", omp_get_thread_num());
#endif

  printf("%d threads: ", max_threads);
  timer_start(&start_time); work(); timer_stop(&end_time);
  elapsed = timer_get(&start_time, &end_time);
  printf("%e seconds", elapsed);

#ifdef _OPENMP
  printf(", %e seconds serial\n", elapsed*max_threads);
#else
  printf(" in serial\n");
#endif

#ifdef _OPENMP
  if(max_threads > 1)
  {
    omp_set_num_threads(1);
    printf("%d threads: ", omp_get_max_threads());
    timer_start(&start_time); work(); timer_stop(&end_time);
    elapsed = timer_get(&start_time, &end_time);
    printf("%e seconds\n", elapsed);
  }
#endif
}
{'fraction_non_alphanumeric': 0.1448087431693989, 'fraction_numerical': 0.015179113539769277, 'mean_word_length': 4.4194078947368425, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '242272', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1262, 'n_words': 288}