int qos_rec_to_hv(slurmdb_qos_rec_t* rec, HV* hv, List all_qos) { char *preempt = NULL; preempt = slurmdb_get_qos_complete_str_bitstr(all_qos, rec->preempt_bitstr); hv_store_charp(hv, "preempt", preempt); STORE_FIELD(hv, rec, description, charp); STORE_FIELD(hv, rec, id, uint32_t); STORE_FIELD(hv, rec, flags, uint32_t); STORE_FIELD(hv, rec, grace_time, uint32_t); STORE_FIELD(hv, rec, grp_jobs, uint32_t); STORE_FIELD(hv, rec, grp_submit_jobs, uint32_t); STORE_FIELD(hv, rec, grp_tres, charp); STORE_FIELD(hv, rec, grp_tres_mins, charp); STORE_FIELD(hv, rec, grp_tres_run_mins, charp); STORE_FIELD(hv, rec, grp_wall, uint32_t); STORE_FIELD(hv, rec, max_jobs_pu, uint32_t); STORE_FIELD(hv, rec, max_submit_jobs_pu, uint32_t); STORE_FIELD(hv, rec, max_tres_mins_pj, charp); STORE_FIELD(hv, rec, max_tres_pj, charp); STORE_FIELD(hv, rec, max_tres_pn, charp); STORE_FIELD(hv, rec, max_tres_pu, charp); STORE_FIELD(hv, rec, max_tres_run_mins_pu,charp); STORE_FIELD(hv, rec, max_wall_pj, uint32_t); STORE_FIELD(hv, rec, min_tres_pj, charp); STORE_FIELD(hv, rec, name, charp); STORE_FIELD(hv, rec, preempt_mode, uint16_t); STORE_FIELD(hv, rec, priority, uint32_t); STORE_FIELD(hv, rec, usage_factor, double); STORE_FIELD(hv, rec, usage_thres, double); return 0; }
static int _job_resrcs_to_hv(job_info_t *job_info, HV *hv) { AV *av; HV *nr_hv; bitstr_t *cpu_bitmap; int sock_inx, sock_reps, last, cnt = 0, i, j, k; char tmp1[128], tmp2[128]; char *host; job_resources_t *job_resrcs = job_info->job_resrcs; int bit_inx, bit_reps; int abs_node_inx, rel_node_inx; uint64_t *last_mem_alloc_ptr = NULL; uint64_t last_mem_alloc = NO_VAL64; char *last_hosts; hostlist_t hl, hl_last; uint32_t threads; if (!job_resrcs || !job_resrcs->core_bitmap || ((last = slurm_bit_fls(job_resrcs->core_bitmap)) == -1)) return 0; if (!(hl = slurm_hostlist_create(job_resrcs->nodes))) return 1; if (!(hl_last = slurm_hostlist_create(NULL))) return 1; av = newAV(); bit_inx = 0; i = sock_inx = sock_reps = 0; abs_node_inx = job_info->node_inx[i]; /* tmp1[] stores the current cpu(s) allocated */ tmp2[0] = '\0'; /* stores last cpu(s) allocated */ for (rel_node_inx=0; rel_node_inx < job_resrcs->nhosts; rel_node_inx++) { if (sock_reps >= job_resrcs->sock_core_rep_count[sock_inx]) { sock_inx++; sock_reps = 0; } sock_reps++; bit_reps = job_resrcs->sockets_per_node[sock_inx] * job_resrcs->cores_per_socket[sock_inx]; host = slurm_hostlist_shift(hl); threads = _threads_per_core(host); cpu_bitmap = slurm_bit_alloc(bit_reps * threads); for (j = 0; j < bit_reps; j++) { if (slurm_bit_test(job_resrcs->core_bitmap, bit_inx)){ for (k = 0; k < threads; k++) slurm_bit_set(cpu_bitmap, (j * threads) + k); } bit_inx++; } slurm_bit_fmt(tmp1, sizeof(tmp1), cpu_bitmap); FREE_NULL_BITMAP(cpu_bitmap); /* * If the allocation values for this host are not the same as the * last host, print the report of the last group of hosts that had * identical allocation values. */ if (strcmp(tmp1, tmp2) || (last_mem_alloc_ptr != job_resrcs->memory_allocated) || (job_resrcs->memory_allocated && (last_mem_alloc != job_resrcs->memory_allocated[rel_node_inx]))) { if (slurm_hostlist_count(hl_last)) { last_hosts = slurm_hostlist_ranged_string_xmalloc( hl_last); nr_hv = newHV(); hv_store_charp(nr_hv, "nodes", last_hosts); hv_store_charp(nr_hv, "cpu_ids", tmp2); hv_store_uint64_t(nr_hv, "mem", last_mem_alloc_ptr ? last_mem_alloc : 0); av_store(av, cnt++, newRV_noinc((SV*)nr_hv)); xfree(last_hosts); slurm_hostlist_destroy(hl_last); hl_last = slurm_hostlist_create(NULL); } strcpy(tmp2, tmp1); last_mem_alloc_ptr = job_resrcs->memory_allocated; if (last_mem_alloc_ptr) last_mem_alloc = job_resrcs-> memory_allocated[rel_node_inx]; else last_mem_alloc = NO_VAL64; } slurm_hostlist_push_host(hl_last, host); free(host); if (bit_inx > last) break; if (abs_node_inx > job_info->node_inx[i+1]) { i += 2; abs_node_inx = job_info->node_inx[i]; } else { abs_node_inx++; } } if (slurm_hostlist_count(hl_last)) { last_hosts = slurm_hostlist_ranged_string_xmalloc(hl_last); nr_hv = newHV(); hv_store_charp(nr_hv, "nodes", last_hosts); hv_store_charp(nr_hv, "cpu_ids", tmp2); hv_store_uint64_t(nr_hv, "mem", last_mem_alloc_ptr ? last_mem_alloc : 0); av_store(av, cnt++, newRV_noinc((SV*)nr_hv)); xfree(last_hosts); } slurm_hostlist_destroy(hl); slurm_hostlist_destroy(hl_last); hv_store_sv(hv, "node_resrcs", newRV_noinc((SV*)av)); return 0; }