Skip to content

Commit 85df65d

Browse files
author
liubo
committed
add lsf.get_host_load_from_batch()
1 parent d684853 commit 85df65d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/disp_gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
host_names = None
77
num_hosts = lsf.new_intp()
88
lsf.intp_assign(num_hosts, 0)
9-
host_data = lsf.lsb_hostinfo_ex(host_names, num_hosts, "", 4096)
9+
host_data = lsf.lsb_hostinfo_ex(host_names, num_hosts, "", 0)
1010
all_host_data = lsf.hostInfoEntArray_frompointer(host_data)
1111
for i in range(0, lsf.intp_value(num_hosts)):
1212
hostname = all_host_data[i].host

pythonlsf/lsf.i

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,24 @@ PyObject * get_host_load(char *resreq, int index) {
416416
return result;
417417
}
418418

419+
PyObject * get_host_load_from_batch (
420+
char * resreq,
421+
int index) {
422+
423+
int numhosts = 0;
424+
struct hostInfoEnt * hinfo = NULL;
425+
426+
hinfo = lsb_hostinfo_ex (NULL, &numhosts, resreq, 0);
427+
if (hinfo == NULL || numhosts > 1) {
428+
lsb_perror("lsb_hostinfo_ex");
429+
exit(-1);
430+
}
431+
432+
PyObject *result = PyFloat_FromDouble(hinfo[0].load[index]);
433+
return result;
434+
}
435+
436+
419437
PyObject * ls_load_py(char *resreq, int *numhosts, int options, char *fromhost) {
420438

421439
struct hostLoad * hosts = NULL;

0 commit comments

Comments
 (0)