Exemple #1
0
def set_globals():
    global matrix_a_data, matrix_b_data
    global matrix_a, matrix_b
    matrix_a_data = db.read_data(MATRIX_A_DATA_FILENAME)
    matrix_b_data = db.read_data(MATRIX_B_DATA_FILENAME)
    matrix_a = mp_init_matrix(MATRIX_SIZE, matrix_a_data)
    matrix_b = mp_init_matrix(MATRIX_SIZE, matrix_b_data)
Exemple #2
0
def set_globals():
    global matrix_a_data, matrix_b_data
    global matrix_a, matrix_b
    matrix_a_data = db.read_data(MATRIX_A_DATA_FILENAME)
    matrix_b_data = db.read_data(MATRIX_B_DATA_FILENAME)
    matrix_a = init_matrix(MATRIX_SIZE, matrix_a_data)
    matrix_b = init_matrix(MATRIX_SIZE, matrix_b_data)
Exemple #3
0
import math
import threading
from ppp.utils import db
from ppp.utils.decorators import timing
from ppp.settings import OVERHEAD
from .data.settings import DATA_FILENAME

NUM_THREADS = OVERHEAD.NUM_THREADS

target_list = db.read_data(DATA_FILENAME)
points = {}
distances = {}
lock = threading.Lock()
max_distance = -1
min_distance = -1


def worker(target_slice):
    global max_distance, min_distance
    for row in target_slice:
        # row[0]: origin; row[1]: destination; row[2]: distance
        lock.acquire()
        #print max_distance
        if int(row[2]) > max_distance:
            max_distance = int(row[2])
        if int(row[2]) < min_distance or min_distance == -1:
            min_distance = int(row[2])
        lock.release()

    for row in target_slice:
        lock.acquire()
Exemple #4
0
def main():
    global target_list
    target_list = db.read_data(DATA_FILENAME)
    proc()
    output_filename = db.get_output_path(DATA_FILENAME, 'output_mt')
    db.write_data(output_filename, target_list)
Exemple #5
0
import math
import threading
from ppp.utils import db
from ppp.utils.decorators import timing
from ppp.settings import OVERHEAD
from .data.settings import DATA_FILENAME


NUM_THREADS = OVERHEAD.NUM_THREADS

target_list = db.read_data(DATA_FILENAME)
points = {}
distances = {}
lock = threading.Lock()
max_distance = -1
min_distance = -1


def worker(target_slice):
    global max_distance, min_distance
    for row in target_slice:
        # row[0]: origin; row[1]: destination; row[2]: distance
        lock.acquire()
        #print max_distance
        if int(row[2]) > max_distance:
            max_distance = int(row[2])
        if int(row[2]) < min_distance or min_distance == -1:
            min_distance = int(row[2])
        lock.release()

    for row in target_slice:
Exemple #6
0
def main():
    global target_list
    target_list = db.read_data(DATA_FILENAME)
    proc()
    output_filename = db.get_output_path(DATA_FILENAME, 'output_mt')
    db.write_data(output_filename, target_list)