<commit_before>/* Copyright 2009 INRIA, Université Bordeaux 1  */

#define _ATFILE_SOURCE
#define _GNU_SOURCE
#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <libtopology.h>
#include <libtopology/debug.h>


static void
lt_print_level_description(lt_level_t *l, FILE *output, int verbose_mode)
{
  unsigned long type = l->type;
  const char * separator = " + ";
  const char * current_separator = ""; /* not prefix for the first one */

#define lt_print_level_description_level(_l) \
    {									\
      if (type == _l) \
	{	      \
	  fprintf(output, "%s%s", current_separator, lt_level_string(_l)); \
	  current_separator = separator;				\
	}								\
    }

  lt_print_level_description_level(LT_LEVEL_MACHINE)
#  ifdef LT__NUMA
  lt_print_level_description_level(LT_LEVEL_FAKE)
  lt_print_level_description_level(LT_LEVEL_NODE)
  lt_print_level_description_level(LT_LEVEL_DIE)
  lt_print_level_description_level(LT_LEVEL_L3)
  lt_print_level_description_level(LT_LEVEL_L2)
  lt_print_level_description_level(LT_LEVEL_CORE)
  lt_print_level_description_level(LT_LEVEL_L1)
  lt_print_level_description_level(LT_LEVEL_PROC)
#  endif
  lt_print_level_description_level(LT_LEVEL_VP)
}

#define lt_memory_size_printf_value(_size) \
  (_size)%1024 ? (_size) : (_size)%(1024*1024) ? (_size)>>10 : (_size)>>20
#define lt_memory_size_printf_unit(_size) \
  (_size)%1024 ? "kB" : (_size)%(1024*1024) ? "MB" : "GB"

void
lt_print_level(lt_topo_t *topology, lt_level_t *l, FILE *output, int verbose_mode, const char *separator,
	       const char *indexprefix, const char* labelseparator, const char* levelterm)
{
  lt_print_level_description(l, output, verbose_mode);
  fprintf(output, "%s", labelseparator);
#ifdef LT__NUMA
  if (l->os_node != -1) fprintf(output, "%sNode%s%u(%ld%s)", separator, indexprefix, l->os_node,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_NODE]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_NODE]));
  if (l->os_die != -1)  fprintf(output, "%sDie%s%u", separator, indexprefix, l->os_die);
  if (l->os_l3 != -1)   fprintf(output, "%sL3%s%u(%ld%s)", separator, indexprefix, l->os_l3,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L3]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L3]));
  if (l->os_l2 != -1)   fprintf(output, "%sL2%s%u(%ld%s)", separator, indexprefix, l->os_l2,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L2]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L2]));
  if (l->os_core != -1) fprintf(output, "%sCore%s%u", separator, indexprefix, l->os_core);
  if (l->os_l1 != -1)   fprintf(output, "%sL1%s%u(%ld%s)", separator, indexprefix, l->os_l1,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L1]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L1]));
  if (l->os_cpu != -1)  fprintf(output, "%sCPU%s%u", separator, indexprefix, l->os_cpu);
#endif
  if (l->level == topology->nb_levels-1) {
    fprintf(output, "%sVP %s%u", separator, indexprefix, l->number);
  }
  fprintf(output,"%s\n", levelterm);
}<commit_msg>report the whole machine memory size at the mac...<commit_after>/* Copyright 2009 INRIA, Université Bordeaux 1  */

#define _ATFILE_SOURCE
#define _GNU_SOURCE
#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <libtopology.h>
#include <libtopology/debug.h>


static void
lt_print_level_description(lt_level_t *l, FILE *output, int verbose_mode)
{
  unsigned long type = l->type;
  const char * separator = " + ";
  const char * current_separator = ""; /* not prefix for the first one */

#define lt_print_level_description_level(_l) \
    {									\
      if (type == _l) \
	{	      \
	  fprintf(output, "%s%s", current_separator, lt_level_string(_l)); \
	  current_separator = separator;				\
	}								\
    }

  lt_print_level_description_level(LT_LEVEL_MACHINE)
#  ifdef LT__NUMA
  lt_print_level_description_level(LT_LEVEL_FAKE)
  lt_print_level_description_level(LT_LEVEL_NODE)
  lt_print_level_description_level(LT_LEVEL_DIE)
  lt_print_level_description_level(LT_LEVEL_L3)
  lt_print_level_description_level(LT_LEVEL_L2)
  lt_print_level_description_level(LT_LEVEL_CORE)
  lt_print_level_description_level(LT_LEVEL_L1)
  lt_print_level_description_level(LT_LEVEL_PROC)
#  endif
  lt_print_level_description_level(LT_LEVEL_VP)
}

#define lt_memory_size_printf_value(_size) \
  (_size)%1024 ? (_size) : (_size)%(1024*1024) ? (_size)>>10 : (_size)>>20
#define lt_memory_size_printf_unit(_size) \
  (_size)%1024 ? "kB" : (_size)%(1024*1024) ? "MB" : "GB"

void
lt_print_level(lt_topo_t *topology, lt_level_t *l, FILE *output, int verbose_mode, const char *separator,
	       const char *indexprefix, const char* labelseparator, const char* levelterm)
{
  lt_print_level_description(l, output, verbose_mode);
  fprintf(output, "%s", labelseparator);
#ifdef LT__NUMA
  if (l->type == LT_LEVEL_MACHINE) fprintf(output, "%sMachine(%ld%s)", separator,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_MACHINE]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_MACHINE]));
  if (l->os_node != -1) fprintf(output, "%sNode%s%u(%ld%s)", separator, indexprefix, l->os_node,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_NODE]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_NODE]));
  if (l->os_die != -1)  fprintf(output, "%sDie%s%u", separator, indexprefix, l->os_die);
  if (l->os_l3 != -1)   fprintf(output, "%sL3%s%u(%ld%s)", separator, indexprefix, l->os_l3,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L3]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L3]));
  if (l->os_l2 != -1)   fprintf(output, "%sL2%s%u(%ld%s)", separator, indexprefix, l->os_l2,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L2]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L2]));
  if (l->os_core != -1) fprintf(output, "%sCore%s%u", separator, indexprefix, l->os_core);
  if (l->os_l1 != -1)   fprintf(output, "%sL1%s%u(%ld%s)", separator, indexprefix, l->os_l1,
				lt_memory_size_printf_value(l->memory_kB[LT_LEVEL_MEMORY_L1]),
				lt_memory_size_printf_unit(l->memory_kB[LT_LEVEL_MEMORY_L1]));
  if (l->os_cpu != -1)  fprintf(output, "%sCPU%s%u", separator, indexprefix, l->os_cpu);
#endif
  if (l->level == topology->nb_levels-1) {
    fprintf(output, "%sVP %s%u", separator, indexprefix, l->number);
  }
  fprintf(output,"%s\n", levelterm);
}
{'fraction_non_alphanumeric': 0.14537444933920704, 'fraction_numerical': 0.017924958225732947, 'mean_word_length': 5.829875518672199, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 82, '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': '3774985', 'n_tokens_mistral': 2810, 'n_tokens_neox': 2578, 'n_words': 404}