def bind(*nodes): nodes = list(set(nodes)) res = ",".join(list(map(str, nodes))) c_string = bytes(res, "ascii") bitmask = LIBNUMA.numa_parse_nodestring(c_string) LIBNUMA.numa_run_on_node_mask(bitmask) LIBNUMA.numa_set_membind(bitmask)
def run_on_nodes(*nodes): """ :param nodes: numa node to run :return: """ nodes = list(set(nodes)) if len(nodes) == 0: bitmask = LIBNUMA.numa_parse_nodestring(b"all") op_res = LIBNUMA.numa_run_on_node_mask(bitmask) if op_res == -1: raise Exception("attempt to run on all nodes failed") else: res = ",".join(list(map(str, nodes))) c_string = bytes(res, "ascii") bitmask = LIBNUMA.numa_parse_nodestring(c_string) op_res = LIBNUMA.numa_run_on_node_mask(bitmask) if op_res == -1: raise Exception(f"attempt to run on {res} failed")