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

#include <config.h>

#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>

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

#include <sys/rset.h>

static void
look_rset(int sdl, enum topo_obj_type_e type, struct topo_topology *topology)
{
  rsethandle_t rset, rad;
  int r,i,maxcpus,j;
  unsigned nbnodes;
  struct topo_obj *rad_level;

  rset = rs_alloc(RS_PARTITION);
  rad = rs_alloc(RS_EMPTY);
  nbnodes = rs_numrads(rset, sdl, 0);
  if (nbnodes == -1) {
    perror("rs_numrads");
    return;
  }

  rad_level=malloc((nbnodes+1)*sizeof(*rad_level));

  for (r = 0, i = 0; i < nbnodes; i++) {
    if (rs_getrad(rset, rad, sdl, i, 0)) {
      fprintf(stderr,"rs_getrad(%d) failed: %s\n", i, strerror(errno));
      continue;
    }
    if (!rs_getinfo(rad, R_NUMPROCS, 0))
      continue;

    topo_setup_object(&rad_level[r], type, r);
    switch(type) {
      case TOPO_OBJ_NODE:
	rad_level[r].memory_kB = 0; /* TODO */
	rad_level[r].huge_page_free = 0;
	break;
      case TOPO_OBJ_CACHE:
	rad_level[r].memory_kB = 0; /* TODO */
	rad_level[r].cache_depth = 2;
	break;
      default:
	break;
    }
    maxcpus = rs_getinfo(rad, R_MAXPROCS, 0);
    for (j = 0; j < maxcpus; j++) {
      if (rs_op(RS_TESTRESOURCE, rad, NULL, R_PROCS, j))
	topo_cpuset_set(&rad_level[r].cpuset,j);
    }
    topo_debug("node %d has cpuset %"TOPO_PRIxCPUSET"\n",
	       r, TOPO_CPUSET_PRINTF_VALUE(rad_level[r].cpuset));
    r++;
  }

  topo_cpuset_zero(&rad_level[r].cpuset);

  topology->level_nbitems[topology->nb_levels] = nbnodes;
  topology->levels[topology->nb_levels++] = rad_level;
  rs_free(rset);
  rs_free(rad);
}

void
look_aix(struct topo_topology *topology)
{
  unsigned i;
  for (i=0; i<=rs_getinfo(NULL, R_MAXSDL, 0); i++)
    {
      if (i == rs_getinfo(NULL, R_MCMSDL, 0))
	{
	  topo_debug("looking AIX node sdl %d\n", i);
	  look_rset(i, TOPO_OBJ_NODE, topology);
	}
#      ifdef R_L2CSDL
      if (i == rs_getinfo(NULL, R_L2CSDL, 0))<commit_msg>TODO<commit_after>/* Copyright 2009 INRIA, Université Bordeaux 1  */

#include <config.h>

#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>

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

#include <sys/rset.h>

static void
look_rset(int sdl, enum topo_obj_type_e type, struct topo_topology *topology)
{
  rsethandle_t rset, rad;
  int r,i,maxcpus,j;
  unsigned nbnodes;
  struct topo_obj *rad_level;

  rset = rs_alloc(RS_PARTITION);
  rad = rs_alloc(RS_EMPTY);
  nbnodes = rs_numrads(rset, sdl, 0);
  if (nbnodes == -1) {
    perror("rs_numrads");
    return;
  }

  rad_level=malloc((nbnodes+1)*sizeof(*rad_level));

  for (r = 0, i = 0; i < nbnodes; i++) {
    if (rs_getrad(rset, rad, sdl, i, 0)) {
      fprintf(stderr,"rs_getrad(%d) failed: %s\n", i, strerror(errno));
      continue;
    }
    if (!rs_getinfo(rad, R_NUMPROCS, 0))
      continue;

    topo_setup_object(&rad_level[r], type, r);
    switch(type) {
      case TOPO_OBJ_NODE:
	rad_level[r].memory_kB = 0; /* TODO */
	rad_level[r].huge_page_free = 0;
	break;
      case TOPO_OBJ_CACHE:
	rad_level[r].memory_kB = 0; /* TODO */
	rad_level[r].cache_depth = 2;
	break;
      default:
	break;
    }
    maxcpus = rs_getinfo(rad, R_MAXPROCS, 0);
    for (j = 0; j < maxcpus; j++) {
      if (rs_op(RS_TESTRESOURCE, rad, NULL, R_PROCS, j))
	topo_cpuset_set(&rad_level[r].cpuset,j);
    }
    topo_debug("node %d has cpuset %"TOPO_PRIxCPUSET"\n",
	       r, TOPO_CPUSET_PRINTF_VALUE(rad_level[r].cpuset));
    r++;
  }

  topo_cpuset_zero(&rad_level[r].cpuset);

  topology->level_nbitems[topology->nb_levels] = nbnodes;
  topology->levels[topology->nb_levels++] = rad_level;
  rs_free(rset);
  rs_free(rad);
}

void
look_aix(struct topo_topology *topology)
{
  unsigned i;
    /* TODO: R_LGPGDEF/R_LGPGFREE */

  for (i=0; i<=rs_getinfo(NULL, R_MAXSDL, 0); i++)
    {
      if (i == rs_getinfo(NULL, R_MCMSDL, 0))
	{
	  topo_debug("looking AIX node sdl %d\n", i);
	  look_rset(i, TOPO_OBJ_NODE, topology);
	}
#      ifdef R_L2CSDL
      if (i == rs_getinfo(NULL, R_L2CSDL, 0))
{'fraction_non_alphanumeric': 0.16049102068651966, 'fraction_numerical': 0.01091157081154808, 'mean_word_length': 3.819277108433735, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, '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': '465781', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1925, 'n_words': 363}