static int _get_node_cnt(job_info_t * job) { int node_cnt = 0; /* For PENDING jobs, return the maximum of the requested nodelist, * requested maximum number of nodes, or requested CPUs rounded * to nearest node. * * For COMPLETING jobs, the job->nodes nodelist has already been * altered to list only the nodes still in the comp state, and * thus we count only those nodes toward the total nodes still * allocated to this job. */ if (IS_JOB_PENDING(job)) { node_cnt = _nodes_in_list(job->req_nodes); node_cnt = MAX(node_cnt, job->num_nodes); if ((node_cnt == 1) && (job->num_cpus > 1) && job->ntasks_per_node && (job->ntasks_per_node != (uint16_t) NO_VAL)) { int num_tasks = job->num_cpus; if (job->cpus_per_task != (uint16_t) NO_VAL) num_tasks /= job->cpus_per_task; node_cnt = (num_tasks + 1) / job->ntasks_per_node; if (node_cnt > num_tasks) node_cnt = num_tasks; else if (!node_cnt) node_cnt = 1; } } else node_cnt = _nodes_in_list(job->nodes); return node_cnt; }
static int _get_node_cnt(job_info_t * job) { int node_cnt = 0, round; /* For PENDING jobs, return the maximum of the requested nodelist, * requested maximum number of nodes, or requested CPUs rounded * to nearest node. * * For COMPLETING jobs, the job->nodes nodelist has already been * altered to list only the nodes still in the comp state, and * thus we count only those nodes toward the total nodes still * allocated to this job. */ if (IS_JOB_PENDING(job)) { node_cnt = _nodes_in_list(job->req_nodes); node_cnt = MAX(node_cnt, job->num_nodes); round = job->num_cpus + params.max_cpus - 1; round /= params.max_cpus; /* round up */ node_cnt = MAX(node_cnt, round); } else node_cnt = _nodes_in_list(job->nodes); return node_cnt; }
/* * slurm_sprint_job_step_info - output information about a specific Slurm * job step based upon message as loaded using slurm_get_job_steps * IN job_ptr - an individual job step information record pointer * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char * slurm_sprint_job_step_info ( job_step_info_t * job_step_ptr, int one_liner ) { char tmp_node_cnt[40]; char time_str[32]; char limit_str[32]; char tmp_line[128]; char *out = NULL; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); /****** Line 1 ******/ slurm_make_time_str ((time_t *)&job_step_ptr->start_time, time_str, sizeof(time_str)); if (job_step_ptr->time_limit == INFINITE) sprintf(limit_str, "UNLIMITED"); else secs2time_str ((time_t)job_step_ptr->time_limit * 60, limit_str, sizeof(limit_str)); snprintf(tmp_line, sizeof(tmp_line), "StepId=%u.%u UserId=%u StartTime=%s TimeLimit=%s", job_step_ptr->job_id, job_step_ptr->step_id, job_step_ptr->user_id, time_str, limit_str); out = xstrdup(tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 2 ******/ snprintf(tmp_line, sizeof(tmp_line), "State=%s ", job_state_string(job_step_ptr->state)); xstrcat(out, tmp_line); if (cluster_flags & CLUSTER_FLAG_BG) { char *io_nodes; select_g_select_jobinfo_get(job_step_ptr->select_jobinfo, SELECT_JOBDATA_IONODES, &io_nodes); if (io_nodes) { snprintf(tmp_line, sizeof(tmp_line), "Partition=%s MidplaneList=%s[%s] Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, io_nodes, job_step_ptr->gres); xfree(io_nodes); } else snprintf(tmp_line, sizeof(tmp_line), "Partition=%s MidplaneList=%s Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, job_step_ptr->gres); } else { snprintf(tmp_line, sizeof(tmp_line), "Partition=%s NodeList=%s Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, job_step_ptr->gres); } xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 3 ******/ if (cluster_flags & CLUSTER_FLAG_BGQ) { uint32_t nodes = 0; select_g_select_jobinfo_get(job_step_ptr->select_jobinfo, SELECT_JOBDATA_NODE_CNT, &nodes); convert_num_unit((float)nodes, tmp_node_cnt, sizeof(tmp_node_cnt), UNIT_NONE); } else { convert_num_unit((float)_nodes_in_list(job_step_ptr->nodes), tmp_node_cnt, sizeof(tmp_node_cnt), UNIT_NONE); } snprintf(tmp_line, sizeof(tmp_line), "Nodes=%s Tasks=%u Name=%s Network=%s", tmp_node_cnt, job_step_ptr->num_tasks, job_step_ptr->name, job_step_ptr->network); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 4 ******/ snprintf(tmp_line, sizeof(tmp_line), "ResvPorts=%s Checkpoint=%u CheckpointDir=%s", job_step_ptr->resv_ports, job_step_ptr->ckpt_interval, job_step_ptr->ckpt_dir); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 5 ******/ if (job_step_ptr->cpu_freq == NO_VAL) { snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=Default\n\n"); } else if (job_step_ptr->cpu_freq & CPU_FREQ_RANGE_FLAG) { switch (job_step_ptr->cpu_freq) { case CPU_FREQ_LOW : snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=Low\n\n"); break; case CPU_FREQ_MEDIUM : snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=Medium\n\n"); break; case CPU_FREQ_HIGH : snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=High\n\n"); break; default : snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=Unknown\n\n"); } } else { snprintf(tmp_line, sizeof(tmp_line), "CPUFreqReq=%u\n\n", job_step_ptr->cpu_freq); } xstrcat(out, tmp_line); return out; }
/* * slurm_sprint_job_step_info - output information about a specific Slurm * job step based upon message as loaded using slurm_get_job_steps * IN job_ptr - an individual job step information record pointer * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char * slurm_sprint_job_step_info ( job_step_info_t * job_step_ptr, int one_liner ) { char tmp_node_cnt[40]; char time_str[32]; char limit_str[32]; char tmp_line[128]; char *out = NULL; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); /****** Line 1 ******/ slurm_make_time_str ((time_t *)&job_step_ptr->start_time, time_str, sizeof(time_str)); if (job_step_ptr->time_limit == INFINITE) sprintf(limit_str, "UNLIMITED"); else secs2time_str ((time_t)job_step_ptr->time_limit * 60, limit_str, sizeof(limit_str)); if (job_step_ptr->array_job_id) { if (job_step_ptr->step_id == INFINITE) { /* Pending */ snprintf(tmp_line, sizeof(tmp_line), "StepId=%u_%u.TBD ", job_step_ptr->array_job_id, job_step_ptr->array_task_id); } else { snprintf(tmp_line, sizeof(tmp_line), "StepId=%u_%u.%u ", job_step_ptr->array_job_id, job_step_ptr->array_task_id, job_step_ptr->step_id); } out = xstrdup(tmp_line); } else { if (job_step_ptr->step_id == INFINITE) { /* Pending */ snprintf(tmp_line, sizeof(tmp_line), "StepId=%u.TBD ", job_step_ptr->job_id); } else { snprintf(tmp_line, sizeof(tmp_line), "StepId=%u.%u ", job_step_ptr->job_id, job_step_ptr->step_id); } out = xstrdup(tmp_line); } snprintf(tmp_line, sizeof(tmp_line), "UserId=%u StartTime=%s TimeLimit=%s", job_step_ptr->user_id, time_str, limit_str); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 2 ******/ snprintf(tmp_line, sizeof(tmp_line), "State=%s ", job_state_string(job_step_ptr->state)); xstrcat(out, tmp_line); if (cluster_flags & CLUSTER_FLAG_BG) { char *io_nodes = NULL; select_g_select_jobinfo_get(job_step_ptr->select_jobinfo, SELECT_JOBDATA_IONODES, &io_nodes); if (io_nodes) { snprintf(tmp_line, sizeof(tmp_line), "Partition=%s MidplaneList=%s[%s] Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, io_nodes, job_step_ptr->gres); xfree(io_nodes); } else snprintf(tmp_line, sizeof(tmp_line), "Partition=%s MidplaneList=%s Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, job_step_ptr->gres); } else { snprintf(tmp_line, sizeof(tmp_line), "Partition=%s NodeList=%s Gres=%s", job_step_ptr->partition, job_step_ptr->nodes, job_step_ptr->gres); } xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 3 ******/ if (cluster_flags & CLUSTER_FLAG_BGQ) { uint32_t nodes = 0; select_g_select_jobinfo_get(job_step_ptr->select_jobinfo, SELECT_JOBDATA_NODE_CNT, &nodes); convert_num_unit((float)nodes, tmp_node_cnt, sizeof(tmp_node_cnt), UNIT_NONE, CONVERT_NUM_UNIT_EXACT); } else { convert_num_unit((float)_nodes_in_list(job_step_ptr->nodes), tmp_node_cnt, sizeof(tmp_node_cnt), UNIT_NONE, CONVERT_NUM_UNIT_EXACT); } snprintf(tmp_line, sizeof(tmp_line), "Nodes=%s CPUs=%u Tasks=%u Name=%s Network=%s", tmp_node_cnt, job_step_ptr->num_cpus, job_step_ptr->num_tasks, job_step_ptr->name, job_step_ptr->network); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 4 ******/ snprintf(tmp_line, sizeof(tmp_line), "TRES=%s", job_step_ptr->tres_alloc_str); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 5 ******/ snprintf(tmp_line, sizeof(tmp_line), "ResvPorts=%s Checkpoint=%u CheckpointDir=%s", job_step_ptr->resv_ports, job_step_ptr->ckpt_interval, job_step_ptr->ckpt_dir); xstrcat(out, tmp_line); if (one_liner) xstrcat(out, " "); else xstrcat(out, "\n "); /****** Line 6 ******/ if (cpu_freq_debug(NULL, NULL, tmp_line, sizeof(tmp_line), job_step_ptr->cpu_freq_gov, job_step_ptr->cpu_freq_min, job_step_ptr->cpu_freq_max, NO_VAL) != 0) { xstrcat(out, tmp_line); } else { xstrcat(out, "CPUFreqReq=Default"); } xstrfmtcat(out, " Dist=%s", slurm_step_layout_type_name(job_step_ptr->task_dist)); xstrcat(out, "\n\n"); return out; }