示例#1
0
void numa_node::parse_cpu_string(

    std::string &line)

{
    std::vector<int> indices;

    this->total_cpus = 0;
    this->available_cpus = 0;

    translate_range_string_to_vector(line.c_str(), indices);

    for (int i = 0; i < indices.size(); i++)
    {
#ifdef PENABLE_LINUX26_CPUSETS
        if ((MOMConfigUseSMT == 1) ||
                (is_physical_core(indices[i]) == true))
#endif
        {
            this->cpu_indices.push_back(indices[i]);
            this->cpu_avail.push_back(true);
            this->total_cpus++;
            this->available_cpus++;
        }
    }

} /* END parse_cpu_string */
示例#2
0
void numa_node::recover_reservation(

    int            num_cpus,
    unsigned long  memory,
    const char    *jobid,
    allocation    &alloc)

{
    char             cpuset_buf[MAXPATHLEN + 1];
    std::vector<int> indices;
    bool             matches_this_numa_node = false;

    alloc.jobid = jobid;

#ifdef PENABLE_LINUX26_CPUSETS
    get_cpu_list(jobid, cpuset_buf, sizeof(cpuset_buf));
#endif

    translate_range_string_to_vector(cpuset_buf, indices);

    for (int i = 0; i < indices.size(); i++)
    {
#ifdef PENABLE_LINUX26_CPUSETS
        if ((MOMConfigUseSMT == 1) ||
                (is_physical_core(indices[i]) == true))
#endif
        {
            int my_index = in_this_numa_node(indices[i]);

            if (my_index == -1)
                continue;

            matches_this_numa_node = true;

            if (this->cpu_avail[my_index] == true)
            {
                mark_cpu_as_in_use(my_index, alloc);
            }
        }
    }

    if (matches_this_numa_node == true)
    {
        mark_memory_as_in_use(memory, alloc);

        this->allocations.push_back(alloc);
    }
} /* END recover_reservation() */
示例#3
0
int process_system(

  xmlNode *node)

  {
  std::string cpus_per_cu;
  xmlNode        *child;
  alps_node_info  ani;
	  
  for (child = node->children; child != NULL; child = child->next)
    {
    if (!strcmp((const char *)child->name, nodes_element))
      {
      // Get information for this batch of nodes
      get_node_info(child, ani);

      // Get the range of nodes this information applies to
      char *content = (char *)xmlNodeGetContent(child);
      if (content != NULL)
        {
        std::vector<int> node_ids;
        translate_range_string_to_vector(content, node_ids);

        for (unsigned int i = 0; i < node_ids.size(); i++)
          {
          if (alps_nodes.find(node_ids[i]) != alps_nodes.end())
            {
            alps_nodes[node_ids[i]].os = ani.os;
            alps_nodes[node_ids[i]].hbm = ani.hbm;
            }
          else
            alps_nodes[node_ids[i]] = ani;
          }

        free(content);
        }
      }
    }
  
  return(PBSE_NONE);  
  } // END process_system()
host_req_list *parse_exec_hosts(

  char *exec_hosts_param,
  const char *mppnodes)

  {
  char            *slash;
  char            *host_tok;
  char            *exec_hosts = strdup(exec_hosts_param);
  char            *str_ptr = exec_hosts;
  const char     *delims = "+";
  host_req        *hr;
  host_req_list   *list = new host_req_list();

  while ((host_tok = threadsafe_tokenizer(&str_ptr, delims)) != NULL)
    {
    if ((slash = strchr(host_tok, '/')) != NULL)
      *slash = '\0';

    /* skip this host - the login shouldn't be part of the alps reservation */
    if ((strcmp(mom_host, host_tok)) &&
        (strcmp(mom_alias, host_tok)))
      {
      std::vector<int> indices;

      if (slash != NULL)
        {
        translate_range_string_to_vector(slash + 1, indices);
        hr = get_host_req(host_tok, indices.size());
        }
      else
        hr = get_host_req(host_tok, 1);

      list->push_back(hr);
      }
    }

  free(exec_hosts);
  return(sort_exec_hosts(list,mppnodes));
  } /* END parse_exec_hosts() */
示例#5
0
END_TEST


START_TEST(test_translate_range_string_to_vector)
  {
  std::vector<int> indices;

  translate_range_string_to_vector("1\n", indices);
  fail_unless(indices.size() == 1);
  fail_unless(indices[0] == 1);

  indices.clear();
  translate_range_string_to_vector("0-1\n", indices);
  fail_unless(indices.size() == 2);
  fail_unless(indices[0] == 0);
  fail_unless(indices[1] == 1);

  indices.clear();
  translate_range_string_to_vector("1-4", indices);
  fail_unless(indices.size() == 4);
  fail_unless(indices[0] == 1);
  fail_unless(indices[1] == 2);
  fail_unless(indices[2] == 3);
  fail_unless(indices[3] == 4);
  
  indices.clear();
  translate_range_string_to_vector("0-2,6-8", indices);
  fail_unless(indices.size() == 6);
  fail_unless(indices[0] == 0);
  fail_unless(indices[1] == 1);
  fail_unless(indices[2] == 2);
  fail_unless(indices[3] == 6);
  fail_unless(indices[4] == 7);
  fail_unless(indices[5] == 8);

  indices.clear();
  translate_range_string_to_vector("qt32", indices);
  // Invalid, should give us a vector of 0
  fail_unless(indices.size() == 0);

  indices.clear();
  translate_range_string_to_vector("\n       6142-6143\n     ", indices);
  fail_unless(indices.size() == 2);
  fail_unless(indices[0] == 6142);
  fail_unless(indices[1] == 6143);
  }
示例#6
0
void allocation::initialize_from_string(

  const std::string &task_info)

  {
  std::string  cpus;
  std::string  mems;
  char        *work_str = strdup(task_info.c_str());
  char        *val = work_str;
  char        *ptr = strstr(work_str, "cpu_list\":");
  std::string  storage;

/* The order these are evaluated makes a difference */
  if (ptr != NULL)
    {
    val = ptr + strlen("cpu_list\":") + 1; // add 1 for the open quote
    capture_until_close_character(&val, storage, '"');
    if (this->cpu_indices.size() == 0)
      translate_range_string_to_vector(storage.c_str(), this->cpu_indices);
    }

  if ((ptr = strstr(val, "mem_list\":")) != NULL)
    {
    val = ptr + strlen("mem_list\":") + 1; // add 1 for the open quote
    capture_until_close_character(&val, storage, '"');
    if (this->mem_indices.size() == 0)
      translate_range_string_to_vector(storage.c_str(), this->mem_indices);
    }
  
  if ((ptr = strstr(val, "cpu_time_used\":")) != NULL)
    {
    val = ptr + strlen("cpu_time_used\":");
    this->task_cput_used = strtol(val, &val, 10);
    }

  if ((ptr = strstr(val, "memory_used\":")) != NULL)
    {
    val = ptr + strlen("memory_used\":");
    this->task_memory_used = strtoll(val, &val, 10);
    }

  if ((ptr = strstr(val, "cores\":")) != NULL)
    {
    int new_val;

    val = ptr + strlen("cores\":");
    new_val = strtol(val, &val, 10);

    /* check for non-zero. Default values are 0. Don't set default
       values because they tend to overwrite exising valid values
       in the attr_atomic_set function */
    if (new_val != 0)
      this->cores = new_val;
    }

  if ((ptr = strstr(val, "threads\":")) != NULL)
    {
    int new_val;

    val = ptr + strlen("threads\":");
    new_val = strtol(val, &val, 10);

     /* check for non-zero. Default values are 0. Don't set default
       values because they tend to overwrite exising valid values
       in the attr_atomic_set function */
    if (new_val != 0)
      this->threads = new_val;
    }


  if ((ptr = strstr(val, "host\":")) != NULL)
    {
    val = ptr + strlen("host\":") + 1;
    storage.clear();
    capture_until_close_character(&val, storage, '"');
    if (storage.size() != 0)
      this->hostname = storage;
    }

  free(work_str);
  } // END initialize_from_string()