/* * srun_allocate - notify srun of a resource allocation * IN job_id - id of the job allocated resource */ extern void srun_allocate (uint32_t job_id) { struct job_record *job_ptr = find_job_record (job_id); xassert(job_ptr); if (job_ptr && job_ptr->alloc_resp_port && job_ptr->alloc_node && job_ptr->resp_host && job_ptr->job_resrcs && job_ptr->job_resrcs->cpu_array_cnt) { slurm_addr_t * addr; resource_allocation_response_msg_t *msg_arg; job_resources_t *job_resrcs_ptr = job_ptr->job_resrcs; addr = xmalloc(sizeof(struct sockaddr_in)); slurm_set_addr(addr, job_ptr->alloc_resp_port, job_ptr->resp_host); msg_arg = xmalloc(sizeof(resource_allocation_response_msg_t)); msg_arg->job_id = job_ptr->job_id; msg_arg->node_list = xstrdup(job_ptr->nodes); msg_arg->alias_list = xstrdup(job_ptr->alias_list); msg_arg->num_cpu_groups = job_resrcs_ptr->cpu_array_cnt; msg_arg->cpus_per_node = xmalloc(sizeof(uint16_t) * job_resrcs_ptr->cpu_array_cnt); if (job_ptr->details) { msg_arg->pn_min_memory = job_ptr->details-> pn_min_memory; } memcpy(msg_arg->cpus_per_node, job_resrcs_ptr->cpu_array_value, (sizeof(uint16_t) * job_resrcs_ptr->cpu_array_cnt)); msg_arg->cpu_count_reps = xmalloc(sizeof(uint32_t) * job_resrcs_ptr->cpu_array_cnt); memcpy(msg_arg->cpu_count_reps, job_resrcs_ptr->cpu_array_reps, (sizeof(uint32_t) * job_resrcs_ptr->cpu_array_cnt)); msg_arg->node_cnt = job_ptr->node_cnt; msg_arg->select_jobinfo = select_g_select_jobinfo_copy( job_ptr->select_jobinfo); msg_arg->error_code = SLURM_SUCCESS; _srun_agent_launch(addr, job_ptr->alloc_node, RESPONSE_RESOURCE_ALLOCATION, msg_arg); } }
/* * Create an srun job structure from a resource allocation response msg */ extern srun_job_t * job_create_allocation(resource_allocation_response_msg_t *resp) { srun_job_t *job; allocation_info_t *i = xmalloc(sizeof(*i)); i->nodelist = _normalize_hostlist(resp->node_list); i->nnodes = resp->node_cnt; i->jobid = resp->job_id; i->stepid = NO_VAL; i->num_cpu_groups = resp->num_cpu_groups; i->cpus_per_node = resp->cpus_per_node; i->cpu_count_reps = resp->cpu_count_reps; i->select_jobinfo = select_g_select_jobinfo_copy(resp->select_jobinfo); job = _job_create_structure(i); xfree(i->nodelist); xfree(i); return (job); }