def printLimit(): if lsf.lsb_init("test") > 0: return -1 req = lsf.limitInfoReq() req.name = " " pp_ents = lsf.calloc_limitInfoEntPtrPtr() intp_size = lsf.copy_intp(0) lsinfo = lsf.lsInfo() rc = lsf.lsb_limitInfo(req, pp_ents, intp_size, lsinfo) if rc == -1: print('call lsf failed') return -1 ents = lsf.limitInfoEntPtrPtr_value(pp_ents) size = lsf.intp_value(intp_size) print("{} limits in the cluster.".format(size)) for i in range(size): ent = lsf.limitInfoEntArray_getitem(ents, i) print('No.{} limit name : {}'.format(i, ent.name)) return 0
def read_all_jobs(count): jobs = [] more = lsf.new_intp() while count > 0: jobp = lsf.lsb_readjobinfo(more) #create a copy of data job = JobInfo(jobp) jobs.append(job) count = lsf.intp_value(more) lsf.delete_intp(more) return jobs
def read_all_jobs(count): jobs = [] more = lsf.new_intp() while count > 0: jobp = lsf.lsb_readjobinfo(more) #create a copy of data job = JobInfo(jobp) jobs.append(job) #print job count = lsf.intp_value(more) lsf.delete_intp(more) return jobs
def printAppInfo(): if lsf.lsb_init("test") > 0: return -1 intp_nent = lsf.new_intp() ents = lsf.lsb_appInfo(intp_nent) nent = lsf.intp_value(intp_nent) print("{} apps in the cluster.".format(nent)) for i in range(nent): ent = lsf.appInfoEntArray_getitem(ents, i) print('No.{} app name : {}, description: {}'.format( i, ent.name, ent.description)) return 0
def printHostInfo(): if lsf.lsb_init("test") > 0: return -1 intp_nhosts = lsf.new_intp() lsf.intp_assign(intp_nhosts, 0) all_lsload_data = lsf.ls_load_py(None, intp_nhosts, 0, None) nhosts = lsf.intp_value(intp_nhosts) print("{} hosts in the cluster.".format(nhosts)) for i in range(nhosts): host = all_lsload_data[i] print('No.{} host name : {}'.format(i, host.hostName)) return 0
def printHostInfo(): if lsf.lsb_init("test") > 0: return -1; intp_nhosts = lsf.new_intp() lsf.intp_assign(intp_nhosts, 0) hostsdata = lsf.ls_load(None, intp_nhosts, 0, None) nhosts = lsf.intp_value(intp_nhosts) all_lsload_data = lsf.hostLoadArray_frompointer(hostsdata) print("{} hosts in the cluster.".format(nhosts)) for i in range(nhosts) : host = all_lsload_data[i] hostname = ctypes.cast( host.hostName, ctypes.c_char_p) print('No.{} host name : {}'.format(i, hostname.value)) return 0
def printLimit(): if lsf.lsb_init("test") > 0: return -1 req = lsf.limitInfoReq() req.name = " " pp_ents = lsf.calloc_limitInfoEntPtrPtr() intp_size = lsf.copy_intp(0) lsinfo = lsf.lsInfo() rc = lsf.lsb_limitInfo(req, pp_ents, intp_size, lsinfo) if rc == -1: print('call lsf failed') return -1 ents = lsf.limitInfoEntPtrPtr_value(pp_ents) size = lsf.intp_value(intp_size) print("{} limits in the cluster.".format(size)) for i in range(size): ent = lsf.limitInfoEntArray_getitem(ents, i) # print limit name print('Limit No.{} : {}'.format(i, ent.name)) # print confInfo in the limit printLimitItem('confInfo', ent.confInfo) # print usageC in the limit print('usageC : {}'.format(ent.usageC)) # print usageInfo in the limit all_usageInfo = lsf.limitItemArray_frompointer(ent.usageInfo) for j in range(ent.usageC): printLimitItem('usageInfo', all_usageInfo[j]) # print ineligible in the limit print('ineligible : {}\n\n'.format(ent.ineligible)) return 0
from pythonlsf import lsf if __name__ == '__main__': print("LSF Clustername is : {}".format(lsf.ls_getclustername())) if lsf.lsb_init("test") > 0: exit -1; host_names = None num_hosts = lsf.new_intp() lsf.intp_assign(num_hosts, 0) host_data = lsf.lsb_hostinfo_ex(host_names, num_hosts, "", 4096) all_host_data = lsf.hostInfoEntArray_frompointer(host_data) for i in range(0, lsf.intp_value(num_hosts)): hostname = all_host_data[i].host print(hostname) gpudata = all_host_data[i].gpuData print("ngpus avail_shared_gpus avail_excl_gpus") print(" {} {} {}". \ format(gpudata.ngpus, gpudata.avail_shared_ngpus, gpudata.avail_excl_ngpus))