def _do_inversion(com, rws):
    """
    Print formatting messages and call gauss elimination
    :param com: communicator
    :param rws: rows
    :return: inversed rows
    """
    print(formatting(com.rank, format_action('receive', rows=rws)))

    inv = gauss(np.array(rws, dtype=np.float64), com, n)

    print(formatting(com.rank, format_action('inverse', rows=inv)))

    return inv
Exemple #2
0
def callProcedureSh1():
    content = request.json
    db_query = "declare begin salemap_stuff.shw1('%s', '%s'); END;" % (
        content['product_group'], content['mod'])
    cursor.execute(db_query)
    db_result = dbGetAnswer()
    return {"result": formatting(db_result)}
Exemple #3
0
def callProcedureSh2():
    content = request.json
    query = 'declare begin salemap_stuff.shw2(%d); END;' % (int(content['q']))
    cursor.execute(query)
    db_result = dbGetAnswer()
    return {"result": formatting(db_result)}
Exemple #4
0
        totalTimer = Timer('master')

        comm.bcast(n, root=MASTER)

        step = n // comm.size
        master_count = step + n % comm.size

        rows = [A[i] + [b[i], i] for i in range(master_count)]

        cur = master_count
        for proc in range(1, comm.size):
            for i in range(step):
                comm.send(A[cur + i] + [b[cur + i], cur + i], dest=proc)  # send row with index as last element
            cur += step

        print(formatting(comm.rank, format_action('receive', rows=rows)))

        g = GaussSolver(np.array(rows), comm, n)
        res = g.calc()

        print(formatting(comm.rank, format_action('result', rows=res)))

        for proc in range(1, comm.size):
            res += comm.recv(source=proc)

        res.sort(key=lambda row: row[-1])

        x = []
        for row in res:
            x.append(row[0])
    t = Timer('TOTAL')
    n = int(inp.readline())

    for line in inp:
        A.append(str_to_row(line))
        b.append(int(line[-2:-1]))

    a = np.array(A, dtype=np.float64)
    det = la.det(np.array(A))

    t_inv = Timer('inversion')

    if not det:
        print(
            formatting(
                comm.rank,
                'ERROR! det A = {} - there is no inversion'.format(det)))
        comm.bcast(0, root=master)
        sys.exit()

    comm.bcast(n, root=master)

    step, master_count = get_step_and_master_count(n, comm.size)

    rows = [A[i] + [i] for i in range(master_count)]

    cur = master_count
    for proc in range(1, comm.size):
        for i in range(step):
            comm.send(A[cur + i] + [cur + i],
                      dest=proc)  # send row with index as last element
 def __str__(self):
     return 'Destination MAC : ' + formatting(self.src_mac) + \
            ' Source MAC : ' + formatting(self.dst_mac) + \
            ' Protocol : ' + str(self.ether_type)
Exemple #7
0
from mpi4py import MPI

from task import Point, Index, ProcSquare, Region
from utils import formatting, Timer, get_dimensions

comm = MPI.COMM_WORLD
master = 0
top, right = 1.0, 1.0
rows, cols = int(sys.argv[1]), int(sys.argv[2])
min_diff = float('inf')
epsilon = 10.0 ** (-7)

if comm.rank == master:
    t = Timer('TOTAL')
    t_init = Timer('initialization')
    print formatting(comm.rank, 'Calculate differential equation with {0} processes'.format(comm.size))

comm.bcast(rows, root=master)
comm.bcast(cols, root=master)

comm_rows, comm_cols = get_dimensions(rows, comm.size)

if comm.rank == master:
    print formatting(comm.rank, 'with {0}D topology: {1}x{2}'.format(
        2 if comm_cols > 1 else 1, comm_rows, comm_cols))

topo = comm.Create_cart(dims=[comm_rows, comm_cols], periods=[0, 0], reorder=True)
cart_comm = MPI.Cartcomm(topo)
coords = cart_comm.Get_coords(comm.rank)
comm_i, comm_j = coords