Ejemplo n.º 1
0
def recvMatrice(s, i):

    data = helper.recv_msg(s)
    result = pickle.loads(data)

    t1 = time.time()
    print("Time to multiply matrices", i, " of size ", result.getSize(), ": ",
          t1 - result.getTime())

    exec_time.append(t1 - result.getTime())
Ejemplo n.º 2
0
def receiveRequest(conn, addr):
    while 1:
        data = helper.recv_msg(conn)
        if not data:
            continue

        x = pickle.loads(data)
        if type(x) == helper.MatrixCouple:
            print("Matrix ", x.getSize(), " received from ", addr)
            x.setUser(addr)
            matrix_couple_queue.append(x)

        elif type(x) == helper.ResultMatrix:
            print("Recieved Result from: ", addr[0])
            needJob(addr[0])
            return_queue.append(x)

        elif type(x) == helper.CPUSpecifications:
            updateSpecs(addr, x)

        else:
            print("ERROR")
Ejemplo n.º 3
0
# ONLY FOR TESTING PURPOSES
# cpus = random.randint(1, int(hw_specs.num_CPUs))
# cores = random.randint(1, int(hw_specs.num_cores))
# freq = random.randint(0, int(100.0 * hw_specs.frequency))
# freq = float(freq) / 100.0
# rand_hw_specs = helper.CPUSpecifications(cpus, cores, freq)
#
# helper.send_msg(s, pickle.dumps(rand_hw_specs))

# Get specifications
# Load into class
# Send to director so that it may update the log

while 1:
    data = helper.recv_msg(s)

    print("recieved data")
    matrix_couple = pickle.loads(data)

    if not type(matrix_couple) == helper.MatrixCouple:
        print("Received garbage")
        exit()

    result = multiplyMatrices(matrix_couple)
    return_val = helper.ResultMatrix(result, matrix_couple.getSize(),
                                     matrix_couple.getLabel,
                                     matrix_couple.getUser())
    return_val.setTime(matrix_couple.getTime())

    helper.send_msg(s, pickle.dumps(return_val))
Ejemplo n.º 4
0

# Init server socket
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serversocket.bind((config.ADDRESS, config.PORT))
serversocket.listen(config.MAX_CONNECTIONS)
connection, address = serversocket.accept()

# Connnect ws2811 LEDs
strip = Strip(
    config.MAX_PIXEL_INDEX,
    config.LED_PIN,
    config.LED_FREQ_HZ,
    config.LED_DMA,
    config.LED_INVERT,
    config.BRIGHTNESS,
    config.LED_CHANNEL,
    ws.WS2811_STRIP_GRB
)
strip.begin()

while True:
    buf = recv_msg(connection)
    if buf is not None:
        pixels = buf_to_colors(buf)
        strip.set_pixels(pixels)
    else:
        # Reconnect after a disconnect
        connection, address = serversocket.accept()