Beispiel #1
0
int calculate_and_add_load(

  dynamic_string         *status,
  struct COI_ENGINE_INFO *mic_stat)

  {
  double   load_normalized = 0.0;
  uint32_t i;
  double   load = 0;
  char     status_buf[MAXLINE * 2];
  
  for (i = 0; i < mic_stat->NumCores; i++)
    {
    load += mic_stat->Load[i];
    }

  load = load / 100.0;
  load_normalized = load / mic_stat->NumCores;

  snprintf(status_buf, sizeof(status_buf), "load=%f", (float)load);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "normalized_load=%f", (float)load_normalized);
  copy_to_end_of_dynamic_string(status, status_buf);

  return(PBSE_NONE);
  } /* END calculate_and_add_load() */
dynamic_string *get_status_info(

  struct tcp_chan *chan)

  {
  dynamic_string *ds = get_dynamic_string(-1, NULL);
  char           *ret_info;
  int             rc;

  if (ds == NULL)
    return(NULL);
  
  while (((ret_info = disrst(chan, &rc)) != NULL) && 
         (rc == DIS_SUCCESS))
    {
    if (!strcmp(ret_info, IS_EOL_MESSAGE))
      {
      free(ret_info);
      break;
      }

    copy_to_end_of_dynamic_string(ds, ret_info);
    free(ret_info);
    }

  return(ds);
  } /* END get_status_info() */
Beispiel #3
0
int add_mic_status(

  dynamic_string *status)

  {
  COIENGINE                engine[MAX_ENGINES];
  uint32_t                 num_engines = 0;
  uint32_t                 i;

  struct COI_ENGINE_INFO   mic_stat[MAX_ENGINES];

  if (COIEngineGetCount(COI_ISA_MIC, &num_engines) != COI_SUCCESS)
    {
    log_err(-1, __func__, "Mics are present but apparently not configured correctly - can't get count");
    return(PBSE_SYSTEM);
    }

  copy_to_end_of_dynamic_string(status, START_MIC_STATUS);

  for (i = 0; i < num_engines; i++)
    {
    if (COIEngineGetHandle(COI_ISA_MIC, i, &engine[i]) != COI_SUCCESS)
      {
      snprintf(log_buffer, sizeof(log_buffer), "Can't get handle for mic index %d", (int)i);
      log_err(-1, __func__, log_buffer);

      copy_to_end_of_dynamic_string(status, END_MIC_STATUS);
      return(PBSE_SYSTEM);
      }

    if (COIEngineGetInfo(engine[i], sizeof(struct COI_ENGINE_INFO), &mic_stat[i]) != COI_SUCCESS)
      {
      snprintf(log_buffer, sizeof(log_buffer), "Can't get information for mic index %d", (int)i);
      log_err(-1, __func__, log_buffer);

      copy_to_end_of_dynamic_string(status, END_MIC_STATUS);
      return(PBSE_SYSTEM);
      }

    add_single_mic_info(status, &mic_stat[i]);
    }

  copy_to_end_of_dynamic_string(status, END_MIC_STATUS);

  return(PBSE_NONE);
  } /* END add_mic_status() */
int process_accelerator_array(

  dynamic_string *status,
  xmlNode        *node)

  {
  xmlNode       *child;
  char          *attr_value;
  char          *attr_value2;
  char           buf[MAXLINE];

  copy_to_end_of_dynamic_string(status, CRAY_GPU_STATUS_START);

  for (child = node->children; child != NULL; child = child->next)
    {
    if (!strcmp((const char *)child->name, accelerator))
      {
      /* write the gpu id */
      attr_value = (char *)xmlGetProp(child, (const xmlChar *)type);
      attr_value2 = (char *)xmlGetProp(child, (const xmlChar *)ordinal);
      snprintf(buf, sizeof(buf), "%s-%d", attr_value, atoi(attr_value2));
      copy_to_end_of_dynamic_string(status, "gpu_id=");
      append_dynamic_string(status, buf);
      free(attr_value);
      free(attr_value2);

      attr_value = (char *)xmlGetProp(child, (const xmlChar *)state);
      copy_to_end_of_dynamic_string(status, "state=");
      append_dynamic_string(status, attr_value);
      free(attr_value);

      attr_value = (char *)xmlGetProp(child, (const xmlChar *)family);
      copy_to_end_of_dynamic_string(status, "family=");
      append_dynamic_string(status, attr_value);
      free(attr_value);

      attr_value = (char *)xmlGetProp(child, (const xmlChar *)memory_mb);
      copy_to_end_of_dynamic_string(status, "memory=");
      append_dynamic_string(status, attr_value);
      append_dynamic_string(status, "mb");
      free(attr_value);

      attr_value = (char *)xmlGetProp(child, (const xmlChar *)clock_mhz);
      copy_to_end_of_dynamic_string(status, "clock_mhz=");
      append_dynamic_string(status, attr_value);
      free(attr_value);
      }
    }
  
  copy_to_end_of_dynamic_string(status, CRAY_GPU_STATUS_END);

  return(PBSE_NONE);
  } /* END process_accelerator_array() */
Beispiel #5
0
int add_isa(

  dynamic_string         *status,
  struct COI_ENGINE_INFO *mic_stat)

  {
  char     status_buf[MAXLINE];
  int      rc = PBSE_NONE;
  
  switch (mic_stat->ISA)
    {
    case COI_ISA_x86_64:

      snprintf(status_buf, sizeof(status_buf), "isa=COI_ISA_x86_64");
      break;

    case COI_ISA_MIC:

      snprintf(status_buf, sizeof(status_buf), "isa=COI_ISA_MIC");
      break;

    case COI_ISA_KNF:

      snprintf(status_buf, sizeof(status_buf), "isa=COI_ISA_KNF");
      break;

    case COI_ISA_KNC:

      snprintf(status_buf, sizeof(status_buf), "isa=COI_ISA_KNC");
      break;

    default:

      rc = PBSE_SYSTEM;

    }

  if (rc == PBSE_NONE)
    copy_to_end_of_dynamic_string(status, status_buf);

  return(rc);
  } /* END add_isa() */
Beispiel #6
0
int add_single_mic_info(

  dynamic_string         *status,
  struct COI_ENGINE_INFO *mic_stat)

  {
  char     status_buf[MAXLINE * 2];

  snprintf(status_buf, sizeof(status_buf), "mic_id=%u", mic_stat->DeviceId);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "num_cores=%u", mic_stat->NumCores);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "num_threads=%u", mic_stat->NumThreads);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "physmem=%lu", mic_stat->PhysicalMemory);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "free_physmem=%lu", mic_stat->PhysicalMemoryFree);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "swap=%lu", mic_stat->SwapMemory);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "free_swap=%lu", mic_stat->SwapMemoryFree);
  copy_to_end_of_dynamic_string(status, status_buf);

  snprintf(status_buf, sizeof(status_buf), "max_frequency=%u", mic_stat->CoreMaxFrequency);
  copy_to_end_of_dynamic_string(status, status_buf);

  add_isa(status, mic_stat);

  calculate_and_add_load(status, mic_stat);

  return(PBSE_NONE);
  } /* END add_single_mic_info() */
Beispiel #7
0
int add_mic_status(

  dynamic_string *status)

  {
  COIENGINE                engine[MAX_ENGINES];
  uint32_t                 num_engines = 0;
  uint32_t                 i;

  struct COI_ENGINE_INFO   mic_stat[MAX_ENGINES];

#ifdef NUMA_SUPPORT
  /* does this node board have mics configured? */
  if (node_boards[numa_index].mic_end_index < 0)
    return(PBSE_NONE);
#endif

  if (COIEngineGetCount(COI_ISA_MIC, &num_engines) != COI_SUCCESS)
    {
    log_err(-1, __func__, "Mics are present but apparently not configured correctly - can't get count");
    return(PBSE_SYSTEM);
    }

  copy_to_end_of_dynamic_string(status, START_MIC_STATUS);

#ifdef NUMA_SUPPORT
  if (num_engines < node_boards[numa_index].mic_end_index)
    {
    snprintf(log_buffer, sizeof(log_buffer),
      "node board %d is supposed to have mic range %d-%d but there are only %d mics",
      numa_index, node_boards[numa_index].mic_start_index,
      node_boards[numa_index].mic_end_index, num_engines);
    log_err(-1, __func__, log_buffer);
    return(PBSE_SYSTEM);
    }

  for (i = node_boards[numa_index].mic_start_index; i <= node_boards[numa_index].mic_end_index; i++)
#else
  for (i = 0; i < num_engines; i++)
#endif
    {
    if (COIEngineGetHandle(COI_ISA_MIC, i, &engine[i]) != COI_SUCCESS)
      {
      snprintf(log_buffer, sizeof(log_buffer), "Can't get handle for mic index %d", (int)i);
      log_err(-1, __func__, log_buffer);

      copy_to_end_of_dynamic_string(status, END_MIC_STATUS);
      return(PBSE_SYSTEM);
      }

    if (COIEngineGetInfo(engine[i], sizeof(struct COI_ENGINE_INFO), &mic_stat[i]) != COI_SUCCESS)
      {
      snprintf(log_buffer, sizeof(log_buffer), "Can't get information for mic index %d", (int)i);
      log_err(-1, __func__, log_buffer);

      copy_to_end_of_dynamic_string(status, END_MIC_STATUS);
      return(PBSE_SYSTEM);
      }

    add_single_mic_info(status, &mic_stat[i]);
    }

  copy_to_end_of_dynamic_string(status, END_MIC_STATUS);

  return(PBSE_NONE);
  } /* END add_mic_status() */
int process_node(

  dynamic_string *status,
  xmlNode        *node)

  {
  char               *attr_value;
  char               *role_value;
  xmlNode            *child;
  xmlNode            *segments;
  xmlNode            *segment_child;
  dynamic_string     *features;
  char                buf[MAXLINE];
  int                 num_procs     = 0;
  int                 avail_procs   = 0;
  unsigned long       memory        = 0;
  unsigned long long  mem_kb;
  char               *rsv_id        = NULL;

  if ((features = get_dynamic_string(-1, NULL)) == NULL)
    return(ENOMEM);

  copy_to_end_of_dynamic_string(status, "node=");
  attr_value = (char *)xmlGetProp(node, (const xmlChar *)node_id);
  append_dynamic_string(status, attr_value);
  free(attr_value);

  /* check to see if the role is interactive - report these as down */
  role_value = (char *)xmlGetProp(node, (const xmlChar *)role);

  copy_to_end_of_dynamic_string(status, "ARCH=");
  attr_value = (char *)xmlGetProp(node, (const xmlChar *)architecture);
  append_dynamic_string(status, attr_value);
  free(attr_value);

  copy_to_end_of_dynamic_string(status, "name=");
  attr_value = (char *)xmlGetProp(node, (const xmlChar *)name);
  append_dynamic_string(status, attr_value);
  free(attr_value);

  /* process the children */
  for (child = node->children; child != NULL; child = child->next)
    {
    if (!strcmp((const char *)child->name, segment_array))
      {
      for (segments = child->children; segments != NULL; segments = segments->next)
        {
        for (segment_child = segments->children; segment_child != NULL; segment_child = segment_child->next)
          {
          if (!strcmp((const char *)segment_child->name, processor_array))
            process_processor_array(segment_child, &num_procs, &avail_procs, &rsv_id);
          else if (!strcmp((const char *)segment_child->name, memory_array))
            process_memory_array(segment_child, &memory);
          else if (!strcmp((const char *)segment_child->name, label_array))
            process_label_array(features, segment_child);
          }
        }
      }
    else if (!strcmp((const char *)child->name, processor_array))
      {
      process_processor_array(child, &num_procs, &avail_procs, &rsv_id);
      }
    else if (!strcmp((const char *)child->name, memory_array))
      {
      process_memory_array(child, &memory);
      }
    else if (!strcmp((const char *)child->name, label_array))
      {
      process_label_array(features, child);
      }
    else if (!strcmp((const char *)child->name, accelerator_array))
      {
      process_accelerator_array(status, child);
      }
    } /* END the loop for processing the children */

  /* once done, add the procs, available procs, memory info, reservation, and features */
  snprintf(buf, sizeof(buf), "CPROC=%d", num_procs);
  copy_to_end_of_dynamic_string(status, buf);

  snprintf(buf, sizeof(buf), "APROC=%d", avail_procs);
  copy_to_end_of_dynamic_string(status, buf);

  snprintf(buf, sizeof(buf), "CMEMORY=%lu", memory);
  copy_to_end_of_dynamic_string(status, buf);

  mem_kb = memory * 1024;

  snprintf(buf, sizeof(buf), "totmem=%llukb", mem_kb);
  copy_to_end_of_dynamic_string(status, buf);

  snprintf(buf, sizeof(buf), "physmem=%llukb", mem_kb);
  copy_to_end_of_dynamic_string(status, buf);

  if (rsv_id != NULL)
    {
    /* don't write the reservation id if we're in interactive mode */
    if ((role_value == NULL) ||
        (strcmp(role_value, interactive_caps)))
      {
      copy_to_end_of_dynamic_string(status, "reservation_id=");
      append_dynamic_string(status, rsv_id);
      }

    free(rsv_id);

    /* if there's a reservation on this node, the state is busy */
    copy_to_end_of_dynamic_string(status, "state=BUSY");
    
    snprintf(buf, sizeof(buf), "availmem=0kb");
    copy_to_end_of_dynamic_string(status, buf);
    }
  else
    {
    /* no reservation, evaluate the state normally */
    copy_to_end_of_dynamic_string(status, "state=");
    attr_value = (char *)xmlGetProp(node, (const xmlChar *)state);
    
    if ((role_value != NULL) &&
        (!strcmp(role_value, interactive_caps)))
      {
      append_dynamic_string(status, "DOWN");
      
      snprintf(buf, sizeof(buf), "availmem=0kb");
      copy_to_end_of_dynamic_string(status, buf);
      }
    else
      {
      append_dynamic_string(status, attr_value);
     
      snprintf(buf, sizeof(buf), "availmem=%llukb", mem_kb);
      copy_to_end_of_dynamic_string(status, buf);
      }

    free(attr_value);
    }

  if (role_value != NULL)
    free(role_value);

  if (features->used > 0)
    {
    copy_to_end_of_dynamic_string(status, "feature_list=");
    append_dynamic_string(status, features->str);
    }

  free_dynamic_string(features);

  return(PBSE_NONE);
  } /* END process_node() */