Skip to content

Commit 1948917

Browse files
committed
add hostGpuInfoArray, hostGpuInfoArray, hostGpuLoadArray
1 parent 3525fc3 commit 1948917

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

examples/disp_gpu_host.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pythonlsf import lsf
2+
if __name__ == '__main__':
3+
if lsf.lsb_init("test") > 0:
4+
exit -1;
5+
num_hosts = lsf.new_intp()
6+
lsf.intp_assign(num_hosts, 0)
7+
hosts = lsf.ls_gethostgpuinfo(None, num_hosts, None, 0, 0)
8+
hostGpuInfos = lsf.hostGpuInfoArray_frompointer(hosts)
9+
for i in range(0, lsf.intp_value(num_hosts)):
10+
hostGpuInfo = hostGpuInfos[i]
11+
print("Host: {}". format(hostGpuInfo.hostName))
12+
numGpus = hostGpuInfos[i].gpuC
13+
if numGpus <= 0:
14+
continue
15+
gpuAttrData = hostGpuInfo.gpuAttrV
16+
gpuLoadData = hostGpuInfo.gpuLoadV
17+
gpuAttrs = lsf.hostGpuAttrArray_frompointer(gpuAttrData)
18+
gpuLoads = lsf.hostGpuLoadArray_frompointer(gpuLoadData)
19+
print(" gBrand gModel gBusId gMode gUsedMem gStatus")
20+
for j in range(0, numGpus):
21+
print(" {} {} {} {} {} {} ". \
22+
format(gpuAttrs[j].gBrand, gpuAttrs[j].gModel, gpuAttrs[j].gBusId,
23+
gpuLoads[j].gMode, gpuLoads[j].gUsedMem, gpuLoads[j].gStatus))

pythonlsf/lsf.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ static void stringArray_setitem(char * *ary, size_t index, char * value) {
200200
%array_class(struct _limitItem, limitItemArray)
201201
%array_class(struct _limitConsumer, limitConsumerArray)
202202
%array_class(struct _limitResource, limitResourceArray)
203+
#ifdef LSF_VERSION_101
204+
%array_class(struct hostGpuInfo, hostGpuInfoArray)
205+
%array_class(struct hostGpuAttr, hostGpuAttrArray)
206+
%array_class(struct hostGpuLoad, hostGpuLoadArray)
207+
#endif
203208

204209
// handle int arrays
205210
%typemap(in) int [ANY] (int temp[$1_dim0]) {

0 commit comments

Comments
 (0)