|
Lines 675-682
static int _cyclic_sync_core_bitmap(struct job_record *job_ptr,
Link Here
|
| 675 |
bool *sock_used, *sock_avoid; |
675 |
bool *sock_used, *sock_avoid; |
| 676 |
bool alloc_cores = false, alloc_sockets = false; |
676 |
bool alloc_cores = false, alloc_sockets = false; |
| 677 |
uint16_t ntasks_per_core = 0xffff, ntasks_per_socket = 0xffff; |
677 |
uint16_t ntasks_per_core = 0xffff, ntasks_per_socket = 0xffff; |
| 678 |
int error_code = SLURM_SUCCESS, socket_best_fit; |
678 |
int error_code = SLURM_SUCCESS; |
| 679 |
uint32_t total_cpus, *cpus_cnt; |
|
|
| 680 |
|
679 |
|
| 681 |
if ((job_res == NULL) || (job_res->core_bitmap == NULL)) |
680 |
if ((job_res == NULL) || (job_res->core_bitmap == NULL)) |
| 682 |
return error_code; |
681 |
return error_code; |
|
Lines 749-796
static int _cyclic_sync_core_bitmap(struct job_record *job_ptr,
Link Here
|
| 749 |
core_cnt = 0; |
748 |
core_cnt = 0; |
| 750 |
cpus = job_res->cpus[i]; |
749 |
cpus = job_res->cpus[i]; |
| 751 |
|
750 |
|
| 752 |
/* Pack job onto socket(s) with best fit */ |
751 |
if (ntasks_per_socket != 0xffff) { |
| 753 |
socket_best_fit = -1; |
752 |
int x_cpus; |
| 754 |
total_cpus = 0; |
753 |
uint32_t total_cpus = 0; |
| 755 |
cpus_cnt = xmalloc(sizeof(uint32_t)* sockets); |
754 |
uint32_t *cpus_cnt = xmalloc(sizeof(uint32_t)* sockets); |
| 756 |
for (s = 0; s < sockets; s++) { |
|
|
| 757 |
for (j = sock_start[s]; j < sock_end[s]; j++) { |
| 758 |
if (bit_test(core_map, j)) |
| 759 |
cpus_cnt[s] += vpus; |
| 760 |
} |
| 761 |
total_cpus += cpus_cnt[s]; |
| 762 |
} |
| 763 |
for (s = 0; s < sockets && total_cpus > cpus; s++) { |
| 764 |
if ((ntasks_per_socket != 0xffff) && |
| 765 |
(cpus_cnt[s] > ntasks_per_socket)) { |
| 766 |
int x_cpus = cpus_cnt[s] - ntasks_per_socket; |
| 767 |
x_cpus = MIN(x_cpus, (total_cpus - cpus)); |
| 768 |
cpus_cnt[s] -= x_cpus; |
| 769 |
total_cpus -= x_cpus; |
| 770 |
} |
| 771 |
if ((cpus_cnt[s] >= cpus) && |
| 772 |
((socket_best_fit == -1) || |
| 773 |
(cpus_cnt[s] < cpus_cnt[socket_best_fit]))) |
| 774 |
socket_best_fit = s; |
| 775 |
} |
| 776 |
if (socket_best_fit != -1) { |
| 777 |
/* Use one socket with best fit, avoid all others */ |
| 778 |
for (s = 0; s < sockets; s++) { |
755 |
for (s = 0; s < sockets; s++) { |
| 779 |
if (s != socket_best_fit) |
756 |
for (j = sock_start[s]; j < sock_end[s]; j++) { |
| 780 |
sock_avoid[s] = true; |
757 |
if (bit_test(core_map, j)) |
|
|
758 |
cpus_cnt[s] += vpus; |
| 759 |
} |
| 760 |
total_cpus += cpus_cnt[s]; |
| 761 |
} |
| 762 |
for (s = 0; s < sockets && total_cpus > cpus; s++) { |
| 763 |
if (cpus_cnt[s] > ntasks_per_socket) { |
| 764 |
x_cpus = cpus_cnt[s] -ntasks_per_socket; |
| 765 |
cpus_cnt[s] = ntasks_per_socket; |
| 766 |
total_cpus -= x_cpus; |
| 767 |
} |
| 781 |
} |
768 |
} |
| 782 |
total_cpus = cpus; |
|
|
| 783 |
} else if (ntasks_per_socket != 0xffff) { |
| 784 |
/* Avoid sockets that can't start ntasks */ |
| 785 |
for (s = 0; s < sockets && total_cpus > cpus; s++) { |
769 |
for (s = 0; s < sockets && total_cpus > cpus; s++) { |
| 786 |
if ((cpus_cnt[s] <= ntasks_per_socket) && |
770 |
if ((cpus_cnt[s] <= ntasks_per_socket) && |
| 787 |
((total_cpus - cpus_cnt[s]) >= cpus)) { |
771 |
(total_cpus - cpus_cnt[s] >= cpus)) { |
| 788 |
sock_avoid[s] = true; |
772 |
sock_avoid[s] = true; |
| 789 |
total_cpus -= cpus_cnt[s]; |
773 |
total_cpus -= cpus_cnt[s]; |
| 790 |
} |
774 |
} |
| 791 |
} |
775 |
} |
|
|
776 |
xfree(cpus_cnt); |
| 792 |
} |
777 |
} |
| 793 |
xfree(cpus_cnt); |
|
|
| 794 |
|
778 |
|
| 795 |
while (cpus > 0) { |
779 |
while (cpus > 0) { |
| 796 |
uint16_t prev_cpus = cpus; |
780 |
uint16_t prev_cpus = cpus; |
| 797 |
- |
|
|