Example #1
0
def node(host):
    """Select a node"""
    if host == 'all':
        for node in lib.get_nodes():
            env.hosts.append(node['littlechef']['nodename'])
        if not len(env.hosts):
            abort('No nodes found')
    else:
        env.hosts = [host]
Example #2
0
def node(host):
    """Select a node"""
    if host == 'all':
        for node in lib.get_nodes():
            env.hosts.append(node['littlechef']['nodename'])
        if not len(env.hosts):
            abort('No nodes found')
    else:
        env.hosts = [host]
Example #3
0
def list_nodes_with_recipe(recipe):
    """Show all nodes which have asigned a given recipe"""
    for node in lib.get_nodes():
        if recipe in lib.get_recipes_in_node(node):
            lib.print_node(node)
        else:
            for role in lib.get_roles_in_node(node):
                with open('roles/' + role + '.json', 'r') as f:
                    roles = json.loads(f.read())
                    # Reuse _get_recipes_in_node to extract recipes in a role
                    if recipe in lib.get_recipes_in_node(roles):
                        lib.print_node(node)
                        break
Example #4
0
def list_nodes_with_recipe(recipe):
    """Show all nodes which have asigned a given recipe"""
    for node in lib.get_nodes():
        if recipe in lib.get_recipes_in_node(node):
            lib.print_node(node)
        else:
            for role in lib.get_roles_in_node(node):
                with open('roles/' + role + '.json', 'r') as f:
                    roles = json.loads(f.read())
                    # Reuse _get_recipes_in_node to extract recipes in a role
                    if recipe in lib.get_recipes_in_node(roles):
                        lib.print_node(node)
                        break
Example #5
0
def benchmark_MNA(df):
    components = get_components(df)
    nodes = get_nodes(components)

    # get unknown ivs
    voltage_sources = get_vs(components)
    num_nodes = len(nodes)

    # generate b matrix, and initialize zero-filled A-matrix
    b = construct_b(voltage_sources, num_nodes)
    A = construct_A(b, components, voltage_sources, num_nodes)

    start_cuda = timer()
    mid_cuda = -1
    try:
        cupy_A = cp_sparse.csr_matrix(A)
        cupy_b = cp.asarray(b)
        mid_cuda = timer()
        cupy_x = cp_sparse.linalg.lsqr(cupy_A, cupy_b)[0]
    except:
        print('failed to solve on gpu')
        mid_cuda = -1
    end_cuda = timer()

    start_cpu = timer()
    A = csr_matrix(A)
    mid_cpu = timer()
    x = lsqr(A, b)
    end_cpu = timer()

    if mid_cuda == -1:
        cuda_trans_diff = ""
        cuda_solve_diff = ""
    else:
        cuda_trans_diff = mid_cuda - start_cuda
        cuda_solve_diff = end_cuda - mid_cuda
    return {
        'matrix_size': A.shape,
        'num_components': len(components),
        'cpu': {
            'total': end_cpu - start_cpu,
            'data transfer': mid_cpu - start_cpu,
            'linear solve': end_cpu - mid_cpu
        },
        'cuda': {
            'total': end_cuda - start_cuda,
            'data transfer': cuda_trans_diff,
            'linear solve': cuda_solve_diff
        }
    }
Example #6
0
def compute_MNA(df, print_eqs=False):
    components = get_components(df)
    nodes = get_nodes(components)

    # get unknown ivs
    voltage_sources = get_vs(components)
    num_nodes = len(nodes)

    # generate b matrix, and initialize zero-filled A-matrix
    b = construct_b(voltage_sources, num_nodes)
    A = construct_A(b, components, voltage_sources, num_nodes)

    cupy_A = cp_sparse.csr_matrix(A)
    cupy_b = cp.asarray(b)
    cupy_x = cp_sparse.linalg.lsqr(cupy_A, cupy_b)[0]

    if print_eqs:
        print("---" * A.shape[0], "\n", cupy_A, "\n", "---" * A.shape[0])
        print(cupy_x)
        print(cupy_b)

    return cp.asnumpy(cupy_x)
Example #7
0
def list_nodes_with_role(role):
    """Show all nodes which have asigned a given role"""
    for node in lib.get_nodes():
        recipename = 'role[' + role + ']'
        if recipename in node.get('run_list'):
            lib.print_node(node)
Example #8
0
def list_nodes():
    """List all nodes"""
    for node in lib.get_nodes():
        lib.print_node(node)
Example #9
0
 def test_list_nodes(self):
     """Should list all configured nodes"""
     expected = [{'name': 'testnode', 'run_list': ['recipe[subversion]']}]
     self.assertEquals(lib.get_nodes(), expected)
Example #10
0
 def test_list_nodes(self):
     """Should list all configured nodes"""
     expected = [{'name': 'testnode', 'run_list': ['recipe[subversion]']}]
     self.assertEquals(lib.get_nodes(), expected)
Example #11
0
def list_nodes_detailed():
    """Show a detailed list of all nodes"""
    for node in lib.get_nodes():
        lib.print_node(node, detailed=True)
Example #12
0
def list_nodes():
    """List all configured nodes"""
    for node in lib.get_nodes():
        lib.print_node(node)
Example #13
0
def list_nodes_with_role(role):
    """Show all nodes which have asigned a given role"""
    for node in lib.get_nodes():
        recipename = 'role[' + role + ']'
        if recipename in node.get('run_list'):
            lib.print_node(node)
Example #14
0
def list_nodes():
    """List all nodes"""
    for node in lib.get_nodes():
        lib.print_node(node)