/* * convert slurm_step_layout_t to perl HV */ int slurm_step_layout_to_hv(slurm_step_layout_t *step_layout, HV *hv) { AV* av, *av2; int i, j; if (step_layout->front_end) STORE_FIELD(hv, step_layout, front_end, charp); STORE_FIELD(hv, step_layout, node_cnt, uint16_t); if (step_layout->node_list) STORE_FIELD(hv, step_layout, node_list, charp); else { Perl_warn(aTHX_ "node_list missing in slurm_step_layout_t"); return -1; } STORE_FIELD(hv, step_layout, plane_size, uint16_t); av = newAV(); for (i = 0; i < step_layout->node_cnt; i ++) av_store_uint16_t(av, i, step_layout->tasks[i]); hv_store_sv(hv, "tasks", newRV_noinc((SV*)av)); STORE_FIELD(hv, step_layout, task_cnt, uint32_t); STORE_FIELD(hv, step_layout, task_dist, uint16_t); av = newAV(); for (i = 0; i < step_layout->node_cnt; i ++) { av2 = newAV(); for (j = 0; j < step_layout->tasks[i]; j ++) av_store_uint32_t(av2, i, step_layout->tids[i][j]); av_store(av, i, newRV_noinc((SV*)av2)); } hv_store_sv(hv, "tids", newRV_noinc((SV*)av)); return 0; }
int report_acct_grouping_to_hv(slurmdb_report_acct_grouping_t* rec, HV* hv) { AV* my_av; HV* rh; slurmdb_report_job_grouping_t* jgr = NULL; slurmdb_tres_rec_t *tres_rec = NULL; ListIterator itr = NULL; STORE_FIELD(hv, rec, acct, charp); STORE_FIELD(hv, rec, count, uint32_t); STORE_FIELD(hv, rec, lft, uint32_t); STORE_FIELD(hv, rec, rgt, uint32_t); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->groups) { itr = slurm_list_iterator_create(rec->groups); while ((jgr = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (report_job_grouping_to_hv(jgr, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a report_job_grouping to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "groups", newRV((SV*)my_av)); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->tres_list) { itr = slurm_list_iterator_create(rec->tres_list); while ((tres_rec = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (tres_rec_to_hv(tres_rec, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a tres_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "tres_list", newRV((SV*)my_av)); return 0; }
/* * convert node_info_msg_t to perl HV */ int node_info_msg_to_hv(node_info_msg_t *node_info_msg, HV *hv) { int i; HV *hv_info; AV *av; STORE_FIELD(hv, node_info_msg, last_update, time_t); STORE_FIELD(hv, node_info_msg, node_scaling, uint16_t); /* * node_info_msg->node_array will have node_records with NULL names for * nodes that are hidden. They are put in the array to preserve the * node_index which will match up with a partiton's node_inx[]. Add * empty hashes for nodes that have NULL names -- hidden nodes. */ av = newAV(); for(i = 0; i < node_info_msg->record_count; i ++) { hv_info =newHV(); if (node_info_msg->node_array[i].name && node_info_to_hv(node_info_msg->node_array + i, node_info_msg->node_scaling, hv_info) < 0) { SvREFCNT_dec((SV*)hv_info); SvREFCNT_dec((SV*)av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "node_array", newRV_noinc((SV*)av)); return 0; }
int report_job_grouping_to_hv(slurmdb_report_job_grouping_t* rec, HV* hv) { AV* my_av; HV* rh; slurmdb_tres_rec_t *tres_rec = NULL; ListIterator itr = NULL; /* FIX ME: include the job list here (is is not NULL, as * previously thought) */ STORE_FIELD(hv, rec, min_size, uint32_t); STORE_FIELD(hv, rec, max_size, uint32_t); STORE_FIELD(hv, rec, count, uint32_t); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->tres_list) { itr = slurm_list_iterator_create(rec->tres_list); while ((tres_rec = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (tres_rec_to_hv(tres_rec, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a tres_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "tres_list", newRV((SV*)my_av)); return 0; }
/* * convert node_info_msg_t to perl HV */ int node_info_msg_to_hv(node_info_msg_t *node_info_msg, HV *hv) { int i; HV *hv_info; AV *av; STORE_FIELD(hv, node_info_msg, last_update, time_t); STORE_FIELD(hv, node_info_msg, node_scaling, uint16_t); /* record_count implied in node_array */ av = newAV(); for(i = 0; i < node_info_msg->record_count; i ++) { if (!node_info_msg->node_array[i].name) continue; hv_info =newHV(); if (node_info_to_hv(node_info_msg->node_array + i, node_info_msg->node_scaling, hv_info) < 0) { SvREFCNT_dec((SV*)hv_info); SvREFCNT_dec((SV*)av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "node_array", newRV_noinc((SV*)av)); return 0; }
/* * convert partition_info_t to perl HV */ int partition_info_to_hv(partition_info_t *part_info, HV *hv) { if (part_info->allow_alloc_nodes) STORE_FIELD(hv, part_info, allow_alloc_nodes, charp); if (part_info->allow_groups) STORE_FIELD(hv, part_info, allow_groups, charp); if (part_info->alternate) STORE_FIELD(hv, part_info, alternate, charp); if (part_info->cr_type) STORE_FIELD(hv, part_info, cr_type, uint16_t); if (part_info->def_mem_per_cpu) STORE_FIELD(hv, part_info, def_mem_per_cpu, uint32_t); STORE_FIELD(hv, part_info, default_time, uint32_t); if (part_info->deny_accounts) STORE_FIELD(hv, part_info, deny_accounts, charp); if (part_info->deny_qos) STORE_FIELD(hv, part_info, deny_qos, charp); STORE_FIELD(hv, part_info, flags, uint16_t); if (part_info->grace_time) STORE_FIELD(hv, part_info, grace_time, uint32_t); if (part_info->max_cpus_per_node) STORE_FIELD(hv, part_info, max_cpus_per_node, uint32_t); if (part_info->max_mem_per_cpu) STORE_FIELD(hv, part_info, max_mem_per_cpu, uint32_t); STORE_FIELD(hv, part_info, max_nodes, uint32_t); STORE_FIELD(hv, part_info, max_share, uint16_t); STORE_FIELD(hv, part_info, max_time, uint32_t); STORE_FIELD(hv, part_info, min_nodes, uint32_t); if (part_info->name) STORE_FIELD(hv, part_info, name, charp); else { Perl_warn(aTHX_ "partition name missing in partition_info_t"); return -1; } /* no store for int pointers yet */ if (part_info->node_inx) { int j; AV* av = newAV(); for(j = 0; ; j += 2) { if(part_info->node_inx[j] == -1) break; av_store(av, j, newSVuv(part_info->node_inx[j])); av_store(av, j+1, newSVuv(part_info->node_inx[j+1])); } hv_store_sv(hv, "node_inx", newRV_noinc((SV*)av)); } if (part_info->nodes) STORE_FIELD(hv, part_info, nodes, charp); STORE_FIELD(hv, part_info, preempt_mode, uint16_t); STORE_FIELD(hv, part_info, priority, uint16_t); if (part_info->qos_char) STORE_FIELD(hv, part_info, qos_char, charp); STORE_FIELD(hv, part_info, state_up, uint16_t); STORE_FIELD(hv, part_info, total_cpus, uint32_t); STORE_FIELD(hv, part_info, total_nodes, uint32_t); return 0; }
/* * convert job_info_msg_t to perl HV */ int job_info_msg_to_hv(job_info_msg_t *job_info_msg, HV *hv) { int i; HV *hv_info; AV *av; _load_node_info(); STORE_FIELD(hv, job_info_msg, last_update, time_t); /* record_count implied in job_array */ av = newAV(); for(i = 0; i < job_info_msg->record_count; i ++) { hv_info = newHV(); if (job_info_to_hv(job_info_msg->job_array + i, hv_info) < 0) { SvREFCNT_dec(hv_info); SvREFCNT_dec(av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "job_array", newRV_noinc((SV*)av)); _free_node_info(); return 0; }
/* * convert job_step_stat_response_msg_t to perl HV */ int job_step_stat_response_msg_to_hv(job_step_stat_response_msg_t *stat_msg, HV *hv) { int i = 0; ListIterator itr; job_step_stat_t *stat; AV *av; HV *hv_stat; STORE_FIELD(hv, stat_msg, job_id, uint32_t); STORE_FIELD(hv, stat_msg, step_id, uint32_t); av = newAV(); itr = slurm_list_iterator_create(stat_msg->stats_list); while((stat = (job_step_stat_t *)slurm_list_next(itr))) { hv_stat = newHV(); if(job_step_stat_to_hv(stat, hv_stat) < 0) { Perl_warn(aTHX_ "failed to convert job_step_stat_t to hv for job_step_stat_response_msg_t"); SvREFCNT_dec(hv_stat); SvREFCNT_dec(av); return -1; } av_store(av, i++, newRV_noinc((SV*)hv_stat)); } slurm_list_iterator_destroy(itr); hv_store_sv(hv, "stats_list", newRV_noinc((SV*)av)); return 0; }
int step_rec_to_hv(slurmdb_step_rec_t *rec, HV* hv) { HV* stats_hv = (HV*)sv_2mortal((SV*)newHV()); stats_to_hv(&rec->stats, stats_hv); hv_store_sv(hv, "stats", newRV((SV*)stats_hv)); STORE_FIELD(hv, rec, elapsed, uint32_t); STORE_FIELD(hv, rec, end, time_t); STORE_FIELD(hv, rec, exitcode, int32_t); STORE_FIELD(hv, rec, nnodes, uint32_t); STORE_FIELD(hv, rec, nodes, charp); STORE_FIELD(hv, rec, ntasks, uint32_t); STORE_FIELD(hv, rec, pid_str, charp); STORE_FIELD(hv, rec, req_cpufreq_min, uint32_t); STORE_FIELD(hv, rec, req_cpufreq_max, uint32_t); STORE_FIELD(hv, rec, req_cpufreq_gov, uint32_t); STORE_FIELD(hv, rec, requid, uint32_t); STORE_FIELD(hv, rec, start, time_t); STORE_FIELD(hv, rec, state, uint32_t); STORE_FIELD(hv, rec, stepid, uint32_t); STORE_FIELD(hv, rec, stepname, charp); STORE_FIELD(hv, rec, suspended, uint32_t); STORE_FIELD(hv, rec, sys_cpu_sec, uint32_t); STORE_FIELD(hv, rec, sys_cpu_usec, uint32_t); STORE_FIELD(hv, rec, task_dist, uint16_t); STORE_FIELD(hv, rec, tot_cpu_sec, uint32_t); STORE_FIELD(hv, rec, tot_cpu_usec, uint32_t); STORE_FIELD(hv, rec, tres_alloc_str, charp); STORE_FIELD(hv, rec, user_cpu_sec, uint32_t); STORE_FIELD(hv, rec, user_cpu_usec, uint32_t); return 0; }
/* convert job_step_pids_t to perl HV */ int job_step_pids_to_hv(job_step_pids_t *pids, HV *hv) { int i; AV *av; STORE_FIELD(hv, pids, node_name, charp); /* pid_cnt implied in pid array */ av = newAV(); for (i = 0; i < pids->pid_cnt; i ++) { av_store_uint32_t(av, i, pids->pid[i]); } hv_store_sv(hv, "pid", newRV_noinc((SV*)av)); return 0; }
/* * convert job_step_stat_t to perl HV */ int job_step_stat_to_hv(job_step_stat_t *stat, HV *hv) { HV *hv_pids; STORE_PTR_FIELD(hv, stat, jobacct, "Slurm::jobacctinfo_t"); STORE_FIELD(hv, stat, num_tasks, uint32_t); STORE_FIELD(hv, stat, return_code, uint32_t); hv_pids = newHV(); if (job_step_pids_to_hv(stat->step_pids, hv_pids) < 0) { Perl_warn(aTHX_ "failed to convert job_step_pids_t to hv for job_step_stat_t"); SvREFCNT_dec(hv_pids); return -1; } hv_store_sv(hv, "step_pids", newRV_noinc((SV*)hv_pids)); return 0; }
/* * convert job_step_info_t to perl HV */ int job_step_info_to_hv(job_step_info_t *step_info, HV *hv) { int j; AV *av; STORE_FIELD(hv, step_info, array_job_id, uint32_t); STORE_FIELD(hv, step_info, array_task_id, uint32_t); if(step_info->ckpt_dir) STORE_FIELD(hv, step_info, ckpt_dir, charp); STORE_FIELD(hv, step_info, ckpt_interval, uint16_t); if(step_info->gres) STORE_FIELD(hv, step_info, gres, charp); STORE_FIELD(hv, step_info, job_id, uint32_t); if(step_info->name) STORE_FIELD(hv, step_info, name, charp); if(step_info->network) STORE_FIELD(hv, step_info, network, charp); if(step_info->nodes) STORE_FIELD(hv, step_info, nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(step_info->node_inx[j] == -1) break; av_store_int(av, j, step_info->node_inx[j]); av_store_int(av, j+1, step_info->node_inx[j+1]); } hv_store_sv(hv, "node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, step_info, num_cpus, uint32_t); STORE_FIELD(hv, step_info, num_tasks, uint32_t); if(step_info->partition) STORE_FIELD(hv, step_info, partition, charp); STORE_FIELD(hv, step_info, profile, uint32_t); if(step_info->resv_ports) STORE_FIELD(hv, step_info, resv_ports, charp); STORE_FIELD(hv, step_info, run_time, time_t); STORE_FIELD(hv, step_info, start_time, time_t); STORE_FIELD(hv, step_info, step_id, uint32_t); STORE_FIELD(hv, step_info, time_limit, uint32_t); STORE_FIELD(hv, step_info, user_id, uint32_t); STORE_FIELD(hv, step_info, state, uint16_t); return 0; }
/* * convert trigger_info_msg_t to perl HV */ int trigger_info_msg_to_hv(trigger_info_msg_t *trigger_info_msg, HV *hv) { int i; HV *hv_info; AV *av; /* record_count implied in node_array */ av = newAV(); for(i = 0; i < trigger_info_msg->record_count; i ++) { hv_info =newHV(); if (trigger_info_to_hv(trigger_info_msg->trigger_array + i, hv_info) < 0) { SvREFCNT_dec((SV*)hv_info); SvREFCNT_dec((SV*)av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "trigger_array", newRV_noinc((SV*)av)); return 0; }
int cluster_accounting_rec_to_hv(slurmdb_cluster_accounting_rec_t* ar, HV* hv) { HV* rh; STORE_FIELD(hv, ar, alloc_secs, uint64_t); STORE_FIELD(hv, ar, down_secs, uint64_t); STORE_FIELD(hv, ar, idle_secs, uint64_t); STORE_FIELD(hv, ar, over_secs, uint64_t); STORE_FIELD(hv, ar, pdown_secs, uint64_t); STORE_FIELD(hv, ar, period_start, time_t); STORE_FIELD(hv, ar, resv_secs, uint64_t); rh = (HV*)sv_2mortal((SV*)newHV()); if (tres_rec_to_hv(&ar->tres_rec, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a tres_rec to a hv"); return -1; } hv_store_sv(hv, "tres_rec", newRV((SV*)rh)); return 0; }
int cluster_rec_to_hv(slurmdb_cluster_rec_t* rec, HV* hv) { AV* my_av; HV* rh; ListIterator itr = NULL; slurmdb_cluster_accounting_rec_t* ar = NULL; my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->accounting_list) { itr = slurm_list_iterator_create(rec->accounting_list); while ((ar = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (cluster_accounting_rec_to_hv(ar, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a cluster_accounting_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "accounting_list", newRV((SV*)my_av)); STORE_FIELD(hv, rec, classification, uint16_t); STORE_FIELD(hv, rec, control_host, charp); STORE_FIELD(hv, rec, control_port, uint32_t); STORE_FIELD(hv, rec, dimensions, uint16_t); STORE_FIELD(hv, rec, flags, uint32_t); STORE_FIELD(hv, rec, name, charp); STORE_FIELD(hv, rec, nodes, charp); STORE_FIELD(hv, rec, plugin_id_select, uint32_t); /* slurmdb_assoc_rec_t* root_assoc; */ STORE_FIELD(hv, rec, rpc_version, uint16_t); STORE_FIELD(hv, rec, tres_str, charp); return 0; }
/* * convert reserve_info_t to perl HV */ int reserve_info_to_hv(reserve_info_t *reserve_info, HV *hv) { if (reserve_info->accounts) STORE_FIELD(hv, reserve_info, accounts, charp); STORE_FIELD(hv, reserve_info, end_time, time_t); if (reserve_info->features) STORE_FIELD(hv, reserve_info, features, charp); STORE_FIELD(hv, reserve_info, flags, uint16_t); if (reserve_info->licenses) STORE_FIELD(hv, reserve_info, licenses, charp); if (reserve_info->name) STORE_FIELD(hv, reserve_info, name, charp); STORE_FIELD(hv, reserve_info, node_cnt, uint32_t); if (reserve_info->node_list) STORE_FIELD(hv, reserve_info, node_list, charp); /* no store for int pointers yet */ if (reserve_info->node_inx) { int j; AV *av = newAV(); for(j = 0; ; j += 2) { if(reserve_info->node_inx[j] == -1) break; av_store(av, j, newSVuv(reserve_info->node_inx[j])); av_store(av, j+1, newSVuv(reserve_info->node_inx[j+1])); } hv_store_sv(hv, "node_inx", newRV_noinc((SV*)av)); } if (reserve_info->partition) STORE_FIELD(hv, reserve_info, partition, charp); STORE_FIELD(hv, reserve_info, start_time, time_t); if (reserve_info->users) STORE_FIELD(hv, reserve_info, users, charp); return 0; }
/* * convert partition_info_msg_t to perl HV */ int partition_info_msg_to_hv(partition_info_msg_t *part_info_msg, HV *hv) { int i; HV *hv_info; AV *av; STORE_FIELD(hv, part_info_msg, last_update, time_t); /* record_count implied in partition_array */ av = newAV(); for(i = 0; i < part_info_msg->record_count; i ++) { hv_info = newHV(); if (partition_info_to_hv(part_info_msg->partition_array + i, hv_info) < 0) { SvREFCNT_dec(hv_info); SvREFCNT_dec(av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "partition_array", newRV_noinc((SV*)av)); return 0; }
/* * convert job_step_info_response_msg_t to perl HV */ int job_step_info_response_msg_to_hv( job_step_info_response_msg_t *job_step_info_msg, HV *hv) { int i; AV* av; HV* hv_info; STORE_FIELD(hv, job_step_info_msg, last_update, time_t); /* job_step_count implied in job_steps */ av = newAV(); for(i = 0; i < job_step_info_msg->job_step_count; i ++) { hv_info = newHV(); if (job_step_info_to_hv( job_step_info_msg->job_steps + i, hv_info) < 0) { SvREFCNT_dec(hv_info); SvREFCNT_dec(av); return -1; } av_store(av, i, newRV_noinc((SV*)hv_info)); } hv_store_sv(hv, "job_steps", newRV_noinc((SV*)av)); return 0; }
/* * convert job_info_t to perl HV */ int job_info_to_hv(job_info_t *job_info, HV *hv) { int j; AV *av; if(job_info->account) STORE_FIELD(hv, job_info, account, charp); if(job_info->alloc_node) STORE_FIELD(hv, job_info, alloc_node, charp); STORE_FIELD(hv, job_info, alloc_sid, uint32_t); STORE_FIELD(hv, job_info, assoc_id, uint32_t); STORE_FIELD(hv, job_info, batch_flag, uint16_t); if(job_info->command) STORE_FIELD(hv, job_info, command, charp); if(job_info->comment) STORE_FIELD(hv, job_info, comment, charp); STORE_FIELD(hv, job_info, contiguous, uint16_t); STORE_FIELD(hv, job_info, cpus_per_task, uint16_t); if(job_info->dependency) STORE_FIELD(hv, job_info, dependency, charp); STORE_FIELD(hv, job_info, derived_ec, uint32_t); STORE_FIELD(hv, job_info, eligible_time, time_t); STORE_FIELD(hv, job_info, end_time, time_t); if(job_info->exc_nodes) STORE_FIELD(hv, job_info, exc_nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->exc_node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->exc_node_inx[j])); av_store(av, j+1, newSVuv(job_info->exc_node_inx[j+1])); } hv_store_sv(hv, "exc_node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, exit_code, uint32_t); if(job_info->features) STORE_FIELD(hv, job_info, features, charp); if(job_info->gres) STORE_FIELD(hv, job_info, gres, charp); STORE_FIELD(hv, job_info, group_id, uint32_t); STORE_FIELD(hv, job_info, job_id, uint32_t); STORE_FIELD(hv, job_info, job_state, uint16_t); if(job_info->licenses) STORE_FIELD(hv, job_info, licenses, charp); STORE_FIELD(hv, job_info, max_cpus, uint32_t); STORE_FIELD(hv, job_info, max_nodes, uint32_t); STORE_FIELD(hv, job_info, sockets_per_node, uint16_t); STORE_FIELD(hv, job_info, cores_per_socket, uint16_t); STORE_FIELD(hv, job_info, threads_per_core, uint16_t); if(job_info->name) STORE_FIELD(hv, job_info, name, charp); if(job_info->network) STORE_FIELD(hv, job_info, network, charp); STORE_FIELD(hv, job_info, nice, uint16_t); if(job_info->nodes) STORE_FIELD(hv, job_info, nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->node_inx[j])); av_store(av, j+1, newSVuv(job_info->node_inx[j+1])); } hv_store_sv(hv, "node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, ntasks_per_core, uint16_t); STORE_FIELD(hv, job_info, ntasks_per_node, uint16_t); STORE_FIELD(hv, job_info, ntasks_per_socket, uint16_t); #ifdef HAVE_BG slurm_get_select_jobinfo(job_info->select_jobinfo, SELECT_JOBDATA_NODE_CNT, &job_info->num_nodes); #endif STORE_FIELD(hv, job_info, num_nodes, uint32_t); STORE_FIELD(hv, job_info, num_cpus, uint32_t); STORE_FIELD(hv, job_info, pn_min_memory, uint32_t); STORE_FIELD(hv, job_info, pn_min_cpus, uint16_t); STORE_FIELD(hv, job_info, pn_min_tmp_disk, uint32_t); if(job_info->partition) STORE_FIELD(hv, job_info, partition, charp); STORE_FIELD(hv, job_info, pre_sus_time, time_t); STORE_FIELD(hv, job_info, priority, uint32_t); if(job_info->qos) STORE_FIELD(hv, job_info, qos, charp); if(job_info->req_nodes) STORE_FIELD(hv, job_info, req_nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->req_node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->req_node_inx[j])); av_store(av, j+1, newSVuv(job_info->req_node_inx[j+1])); } hv_store_sv(hv, "req_node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, req_switch, uint32_t); STORE_FIELD(hv, job_info, requeue, uint16_t); STORE_FIELD(hv, job_info, resize_time, time_t); STORE_FIELD(hv, job_info, restart_cnt, uint16_t); if(job_info->resv_name) STORE_FIELD(hv, job_info, resv_name, charp); STORE_PTR_FIELD(hv, job_info, select_jobinfo, "Slurm::dynamic_plugin_data_t"); STORE_PTR_FIELD(hv, job_info, job_resrcs, "Slurm::job_resources_t"); STORE_FIELD(hv, job_info, shared, uint16_t); STORE_FIELD(hv, job_info, show_flags, uint16_t); STORE_FIELD(hv, job_info, start_time, time_t); if(job_info->state_desc) STORE_FIELD(hv, job_info, state_desc, charp); STORE_FIELD(hv, job_info, state_reason, uint16_t); STORE_FIELD(hv, job_info, submit_time, time_t); STORE_FIELD(hv, job_info, suspend_time, time_t); STORE_FIELD(hv, job_info, time_limit, uint32_t); STORE_FIELD(hv, job_info, time_min, uint32_t); STORE_FIELD(hv, job_info, user_id, uint32_t); STORE_FIELD(hv, job_info, wait4switch, uint32_t); if(job_info->wckey) STORE_FIELD(hv, job_info, wckey, charp); if(job_info->work_dir) STORE_FIELD(hv, job_info, work_dir, charp); 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; }
int job_rec_to_hv(slurmdb_job_rec_t* rec, HV* hv) { slurmdb_step_rec_t *step; ListIterator itr = NULL; AV* steps_av = (AV*)sv_2mortal((SV*)newAV()); HV* stats_hv = (HV*)sv_2mortal((SV*)newHV()); HV* step_hv; stats_to_hv(&rec->stats, stats_hv); hv_store_sv(hv, "stats", newRV((SV*)stats_hv)); if (rec->steps) { itr = slurm_list_iterator_create(rec->steps); while ((step = slurm_list_next(itr))) { step_hv = (HV*)sv_2mortal((SV*)newHV()); step_rec_to_hv(step, step_hv); av_push(steps_av, newRV((SV*)step_hv)); } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "steps", newRV((SV*)steps_av)); STORE_FIELD(hv, rec, account, charp); STORE_FIELD(hv, rec, alloc_gres, charp); STORE_FIELD(hv, rec, alloc_nodes, uint32_t); STORE_FIELD(hv, rec, array_job_id, uint32_t); STORE_FIELD(hv, rec, array_max_tasks, uint32_t); STORE_FIELD(hv, rec, array_task_id, uint32_t); STORE_FIELD(hv, rec, array_task_str, charp); STORE_FIELD(hv, rec, associd, uint32_t); STORE_FIELD(hv, rec, blockid, charp); STORE_FIELD(hv, rec, cluster, charp); STORE_FIELD(hv, rec, derived_ec, uint32_t); STORE_FIELD(hv, rec, derived_es, charp); STORE_FIELD(hv, rec, elapsed, uint32_t); STORE_FIELD(hv, rec, eligible, time_t); STORE_FIELD(hv, rec, end, time_t); STORE_FIELD(hv, rec, exitcode, uint32_t); /*STORE_FIELD(hv, rec, first_step_ptr, void*);*/ STORE_FIELD(hv, rec, gid, uint32_t); STORE_FIELD(hv, rec, jobid, uint32_t); STORE_FIELD(hv, rec, jobname, charp); STORE_FIELD(hv, rec, lft, uint32_t); STORE_FIELD(hv, rec, partition, charp); STORE_FIELD(hv, rec, nodes, charp); STORE_FIELD(hv, rec, priority, uint32_t); STORE_FIELD(hv, rec, qosid, uint32_t); STORE_FIELD(hv, rec, req_cpus, uint32_t); STORE_FIELD(hv, rec, req_gres, charp); STORE_FIELD(hv, rec, req_mem, uint32_t); STORE_FIELD(hv, rec, requid, uint32_t); STORE_FIELD(hv, rec, resvid, uint32_t); STORE_FIELD(hv, rec, resv_name, charp); STORE_FIELD(hv, rec, show_full, uint32_t); STORE_FIELD(hv, rec, start, time_t); STORE_FIELD(hv, rec, state, uint32_t); STORE_FIELD(hv, rec, submit, time_t); STORE_FIELD(hv, rec, suspended, uint32_t); STORE_FIELD(hv, rec, sys_cpu_sec, uint32_t); STORE_FIELD(hv, rec, sys_cpu_usec, uint32_t); STORE_FIELD(hv, rec, timelimit, uint32_t); STORE_FIELD(hv, rec, tot_cpu_sec, uint32_t); STORE_FIELD(hv, rec, tot_cpu_usec, uint32_t); STORE_FIELD(hv, rec, track_steps, uint16_t); STORE_FIELD(hv, rec, tres_alloc_str, charp); STORE_FIELD(hv, rec, uid, uint32_t); STORE_FIELD(hv, rec, used_gres, charp); STORE_FIELD(hv, rec, user, charp); STORE_FIELD(hv, rec, user_cpu_sec, uint32_t); STORE_FIELD(hv, rec, user_cpu_usec, uint32_t); STORE_FIELD(hv, rec, wckey, charp); STORE_FIELD(hv, rec, wckeyid, uint32_t); return 0; }
int report_cluster_rec_to_hv(slurmdb_report_cluster_rec_t* rec, HV* hv) { AV* my_av; HV* rh; slurmdb_report_assoc_rec_t* ar = NULL; slurmdb_report_user_rec_t* ur = NULL; slurmdb_tres_rec_t *tres_rec = NULL; ListIterator itr = NULL; /* FIXME: do the accounting_list (add function to parse * slurmdb_accounting_rec_t) */ my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->assoc_list) { itr = slurm_list_iterator_create(rec->assoc_list); while ((ar = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (report_assoc_rec_to_hv(ar, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a report_assoc_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "assoc_list", newRV((SV*)my_av)); STORE_FIELD(hv, rec, name, charp); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->tres_list) { itr = slurm_list_iterator_create(rec->tres_list); while ((tres_rec = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (tres_rec_to_hv(tres_rec, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a tres_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "tres_list", newRV((SV*)my_av)); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->user_list) { itr = slurm_list_iterator_create(rec->user_list); while ((ur = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (report_user_rec_to_hv(ur, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a report_user_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "user_list", newRV((SV*)my_av)); return 0; }
int report_user_rec_to_hv(slurmdb_report_user_rec_t* rec, HV* hv) { AV* my_av; HV* rh; char* acct; slurmdb_report_assoc_rec_t* ar = NULL; slurmdb_tres_rec_t *tres_rec = NULL; ListIterator itr = NULL; my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->acct_list) { itr = slurm_list_iterator_create(rec->acct_list); while ((acct = slurm_list_next(itr))) { av_push(my_av, newSVpv(acct, strlen(acct))); } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "acct_list", newRV((SV*)my_av)); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->assoc_list) { itr = slurm_list_iterator_create(rec->assoc_list); while ((ar = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (report_assoc_rec_to_hv(ar, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a report_assoc_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "assoc_list", newRV((SV*)my_av)); STORE_FIELD(hv, rec, acct, charp); STORE_FIELD(hv, rec, name, charp); my_av = (AV*)sv_2mortal((SV*)newAV()); if (rec->tres_list) { itr = slurm_list_iterator_create(rec->tres_list); while ((tres_rec = slurm_list_next(itr))) { rh = (HV*)sv_2mortal((SV*)newHV()); if (tres_rec_to_hv(tres_rec, rh) < 0) { Perl_warn(aTHX_ "Failed to convert a tres_rec to a hv"); slurm_list_iterator_destroy(itr); return -1; } else { av_push(my_av, newRV((SV*)rh)); } } slurm_list_iterator_destroy(itr); } hv_store_sv(hv, "tres_list", newRV((SV*)my_av)); STORE_FIELD(hv, rec, uid, uid_t); return 0; }