Пример #1
0
def emsThreadStub(conn, taskn):
    """Function that receives EMS fork-join functions, executes them,
       and returns the results."""
    sys.path.append("../Python/")
    global ems
    import ems
    ems.initialize(taskn, True, 'fj', '/tmp/fj_main.ems')
    print("STUB: This is the start of it", taskn)
    ems.myID = taskn
    ems.diag("Stub diag.  Taskn=" + str(taskn) + "   myid=" + str(ems.myID))
    while True:
        msg = conn.recv()
        print("CONN RECV ON", taskn)
        func = msg['func']
        args = msg['args']
        if func is None:
            print("Farewell!!!!!!!!  from ", taskn)
            conn.close()
            exit(0)
        ems.diag("func=" + str(func) + "   args=" + str(args))
        # print("func=" + str(func) + "   args=" + str(args))
        retval = func(*args)
        conn.send(str(retval))
Пример #2
0
import time
sys.path.append("../Python/ems/")  # Path to EMS Python Module
import ems

nprocs = 12
nelem = 1000
ems.initialize(nprocs, False, 'bsp', '/tmp/pyems_foo_test.ems')
time.sleep(ems.myID/5)
assert ems.barrier()


various_consts = ["簣ひょ갤妣ゃキェぱ覣.𐤦ぴ盥", -99999, 1 << 35, 9821.3456, "bar", False]
unmapped_fname = '/tmp/py_unmapped.ems'
#  TODO: 3D array
unmapped = ems.new(nelem * nprocs, nprocs * nelem * 100, unmapped_fname)
ems.diag("=============== INIT COMPLETE ======================")


def sum(left, right):
    if type(left) == int:
        return right + left
    if type(left) == float:
        return right * left
    else:
        return str(right) + str(left)


def target(idx):
    return idx + (ems.myID * nelem)

Пример #3
0
THIS_DIR = os.path.realpath(os.path.dirname(__file__))
sys.path.append(os.path.realpath(os.path.join(THIS_DIR, "../Python/ems")))
import ems

nprocs = 12
nelem = 1000
ems.initialize(nprocs, False, 'bsp', '/tmp/pyems_foo_test.ems')
time.sleep(ems.myID / 5)
assert ems.barrier()

various_consts = ["簣ひょ갤妣ゃキェぱ覣.𐤦ぴ盥", -99999, 1 << 35, 9821.3456, "bar", False]
unmapped_fname = '/tmp/py_unmapped.ems'
#  TODO: 3D array
unmapped = ems.new(nelem * nprocs, nprocs * nelem * 100, unmapped_fname)
ems.diag("=============== INIT COMPLETE ======================")


def sum(left, right):
    if type(left) == int:
        return right + left
    if type(left) == float:
        return right * left
    else:
        return str(right) + str(left)


def target(idx):
    return idx + (ems.myID * nelem)

Пример #4
0
def fj_test(a, b, c, taskN=None):
    global global_str, nprocs, ems
    global_str = "The new globstrrrrrr"
    # import ems
    # ems.initialize(nprocs, True, 'fj', '/tmp/fj_main.ems')
    ems.diag("FJ0")
    assert taskN == None
    ems.diag("FJ1")
    ems.barrier()
    ems.diag("FJ2")
    # assert(typeof local_str === "undefined", "The local string did not stay local");
    # ems.diag("global_str=" + global_str + " a =" + a + "  b=" + b + "  c=" + c)
    ems.diag("global_str=" + global_str + " a =" + a + "  b=" + b + "  c=" + c)
    ems.diag("FJ3")
    assert a == "The Global String"   # Hardcoded due to no closures
    assert b == 'two'
    assert c == 'three'
    ems.diag("FJ4")
Пример #5
0

def fj_test(a, b, c, taskN=None):
    global global_str, nprocs, ems
    global_str = "The new globstrrrrrr"
    # import ems
    # ems.initialize(nprocs, True, 'fj', '/tmp/fj_main.ems')
    ems.diag("FJ0")
    assert taskN == None
    ems.diag("FJ1")
    ems.barrier()
    ems.diag("FJ2")
    # assert(typeof local_str === "undefined", "The local string did not stay local");
    # ems.diag("global_str=" + global_str + " a =" + a + "  b=" + b + "  c=" + c)
    ems.diag("global_str=" + global_str + " a =" + a + "  b=" + b + "  c=" + c)
    ems.diag("FJ3")
    assert a == "The Global String"   # Hardcoded due to no closures
    assert b == 'two'
    assert c == 'three'
    ems.diag("FJ4")
    # global_str += "Updated by process " + str(ems.myID)

ems.diag("Entering first parallel region")
ems.parallel(fj_test, global_str, 'two', 'three', 'taaaaaasdasdasda')
ems.diag("globstr=" + global_str)

ems.diag("This side")
time.sleep(ems.myID/2)
ems.parallel(ems.barrier)
ems.diag("That side")