Beispiel #1
0
static void _state_write_buf(Buf buffer)
{
    pack16(SLURM_PROTOCOL_VERSION, buffer);
    pack32(MIN_PORT, buffer);
    pack32(MAX_PORT, buffer);

    pthread_mutex_lock(&port_mutex);

    pack32(last_alloc_port, buffer);
    pack_bit_str(port_resv, buffer);

    pthread_mutex_unlock(&port_mutex);
}
Beispiel #2
0
extern void pack_job_resources(job_resources_t *job_resrcs_ptr, Buf buffer,
			       uint16_t protocol_version)
{
	uint32_t cluster_flags = slurmdb_setup_cluster_flags();

	if (protocol_version >= SLURM_2_5_PROTOCOL_VERSION) {
		if (job_resrcs_ptr == NULL) {
			uint32_t empty = NO_VAL;
			pack32(empty, buffer);
			return;
		}

		pack32(job_resrcs_ptr->nhosts, buffer);
		pack32(job_resrcs_ptr->ncpus, buffer);
		pack32(job_resrcs_ptr->node_req, buffer);
		packstr(job_resrcs_ptr->nodes, buffer);

		if (job_resrcs_ptr->cpu_array_reps)
			pack32_array(job_resrcs_ptr->cpu_array_reps,
				     job_resrcs_ptr->cpu_array_cnt, buffer);
		else
			pack32_array(job_resrcs_ptr->cpu_array_reps, 0, buffer);

		if (job_resrcs_ptr->cpu_array_value)
			pack16_array(job_resrcs_ptr->cpu_array_value,
				     job_resrcs_ptr->cpu_array_cnt, buffer);
		else
			pack16_array(job_resrcs_ptr->cpu_array_value,
				     0, buffer);

		if (job_resrcs_ptr->cpus)
			pack16_array(job_resrcs_ptr->cpus,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack16_array(job_resrcs_ptr->cpus, 0, buffer);

		if (job_resrcs_ptr->cpus_used)
			pack16_array(job_resrcs_ptr->cpus_used,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack16_array(job_resrcs_ptr->cpus_used, 0, buffer);

		if (job_resrcs_ptr->memory_allocated)
			pack32_array(job_resrcs_ptr->memory_allocated,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack32_array(job_resrcs_ptr->memory_allocated,
				     0, buffer);

		if (job_resrcs_ptr->memory_used)
			pack32_array(job_resrcs_ptr->memory_used,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack32_array(job_resrcs_ptr->memory_used, 0, buffer);
		if (!(cluster_flags & CLUSTER_FLAG_BG)) {
			int i;
			uint32_t core_cnt = 0, sock_recs = 0;
			xassert(job_resrcs_ptr->cores_per_socket);
			xassert(job_resrcs_ptr->sock_core_rep_count);
			xassert(job_resrcs_ptr->sockets_per_node);

			for (i=0; i<job_resrcs_ptr->nhosts; i++) {
				core_cnt += job_resrcs_ptr->sockets_per_node[i]
					* job_resrcs_ptr->cores_per_socket[i] *
					job_resrcs_ptr->sock_core_rep_count[i];
				sock_recs += job_resrcs_ptr->
					     sock_core_rep_count[i];
				if (sock_recs >= job_resrcs_ptr->nhosts)
					break;
			}
			i++;
			pack16_array(job_resrcs_ptr->sockets_per_node,
				     (uint32_t) i, buffer);
			pack16_array(job_resrcs_ptr->cores_per_socket,
				     (uint32_t) i, buffer);
			pack32_array(job_resrcs_ptr->sock_core_rep_count,
				     (uint32_t) i, buffer);

			xassert(job_resrcs_ptr->core_bitmap);
			xassert(job_resrcs_ptr->core_bitmap_used);
			pack_bit_str(job_resrcs_ptr->core_bitmap, buffer);
			pack_bit_str(job_resrcs_ptr->core_bitmap_used, buffer);
		}
	} else if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {
		uint8_t tmp_8;
		if (job_resrcs_ptr == NULL) {
			uint32_t empty = NO_VAL;
			pack32(empty, buffer);
			return;
		}

		pack32(job_resrcs_ptr->nhosts, buffer);
		pack32(job_resrcs_ptr->ncpus, buffer);
		tmp_8 = job_resrcs_ptr->node_req;	/* 32-bit in v2.5 */
		pack8(tmp_8, buffer);
		packstr(job_resrcs_ptr->nodes, buffer);

		if (job_resrcs_ptr->cpu_array_reps)
			pack32_array(job_resrcs_ptr->cpu_array_reps,
				     job_resrcs_ptr->cpu_array_cnt, buffer);
		else
			pack32_array(job_resrcs_ptr->cpu_array_reps, 0, buffer);

		if (job_resrcs_ptr->cpu_array_value)
			pack16_array(job_resrcs_ptr->cpu_array_value,
				     job_resrcs_ptr->cpu_array_cnt, buffer);
		else
			pack16_array(job_resrcs_ptr->cpu_array_value,
				     0, buffer);

		if (job_resrcs_ptr->cpus)
			pack16_array(job_resrcs_ptr->cpus,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack16_array(job_resrcs_ptr->cpus, 0, buffer);

		if (job_resrcs_ptr->cpus_used)
			pack16_array(job_resrcs_ptr->cpus_used,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack16_array(job_resrcs_ptr->cpus_used, 0, buffer);

		if (job_resrcs_ptr->memory_allocated)
			pack32_array(job_resrcs_ptr->memory_allocated,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack32_array(job_resrcs_ptr->memory_allocated,
				     0, buffer);

		if (job_resrcs_ptr->memory_used)
			pack32_array(job_resrcs_ptr->memory_used,
				     job_resrcs_ptr->nhosts, buffer);
		else
			pack32_array(job_resrcs_ptr->memory_used, 0, buffer);
		if (!(cluster_flags & CLUSTER_FLAG_BG)) {
			int i;
			uint32_t core_cnt = 0, sock_recs = 0;
			xassert(job_resrcs_ptr->cores_per_socket);
			xassert(job_resrcs_ptr->sock_core_rep_count);
			xassert(job_resrcs_ptr->sockets_per_node);

			for (i=0; i<job_resrcs_ptr->nhosts; i++) {
				core_cnt += job_resrcs_ptr->sockets_per_node[i]
					* job_resrcs_ptr->cores_per_socket[i] *
					job_resrcs_ptr->sock_core_rep_count[i];
				sock_recs += job_resrcs_ptr->
					     sock_core_rep_count[i];
				if (sock_recs >= job_resrcs_ptr->nhosts)
					break;
			}
			i++;
			pack16_array(job_resrcs_ptr->sockets_per_node,
				     (uint32_t) i, buffer);
			pack16_array(job_resrcs_ptr->cores_per_socket,
				     (uint32_t) i, buffer);
			pack32_array(job_resrcs_ptr->sock_core_rep_count,
				     (uint32_t) i, buffer);

			xassert(job_resrcs_ptr->core_bitmap);
			xassert(job_resrcs_ptr->core_bitmap_used);
			pack_bit_str(job_resrcs_ptr->core_bitmap, buffer);
			pack_bit_str(job_resrcs_ptr->core_bitmap_used, buffer);
		}
	} else {
		error("pack_job_resources: protocol_version %hu not supported",
		      protocol_version);
	}
}