Beispiel #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))
Beispiel #2
0
      This "stuck" behavior is due to how the Python/C interface protects
      the Python runtime.
"""

import time
import sys
import random
sys.path.append("../../Python/")
import ems

# Initialize EMS: 1 process, no thread-core affinity, user provided parallelism
# Initialize EMS with 1 process, no thread-CPU affinity,
# "user" mode parallelism, and a unique namespace for EMS runtime
# ("pyExample") to keep the JS program distinct from Javascript EMS
# program also running.
ems.initialize(1, False, "user", "pyExample")


# The EMS array attributes must be the same by all programs sharing the array,
# with the exception of the the initial file creation which uses "useExisting:False"
# instead of "useExisting:True"
maxNKeys = 100
bytesPerEntry = 100  # Bytes of storage per key, used for key (dictionary word) itself
shared = ems.new({
    'useExisting': True,        # Connect the EMS memory created by JS, do not create a new memory
    'filename': "/tmp/interlanguage.ems",  # Persistent EMS array's filename
    'dimensions': maxNKeys,   # Maximum # of different keys the array can store
    'heapSize': maxNKeys * 100,  # 100 bytes of storage per key, used for key (dictionary word) itself
    'useMap': True             # Use a key-index mapping, not integer indexes
})
Beispiel #3
0
 |    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   |
 |    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     |
 |    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       |
 |    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             |
 |                                                                             |
 +-----------------------------------------------------------------------------+
"""
import sys
import os
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:
Beispiel #4
0
 |    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             |
 |                                                                             |
 +-----------------------------------------------------------------------------+
"""
import sys
import os
import time
import os

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
Beispiel #5
0
 |    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     |
 |    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       |
 |    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             |
 |                                                                             |
 +-----------------------------------------------------------------------------+
"""
import sys
import time
sys.path.append("../Python/")

nprocs = 2
nelem = 1000
global_str = "The Global String"   # Hardcoded later

import ems
ems.initialize(nprocs, True, 'fj', '/tmp/fj_main.ems')


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)
Beispiel #6
0
    NOTE ABOUT "STUCK" JOBS":
      Python runtime can get "stuck" and may not respond to Control-C
      but can still be interrupted with Control-Z or Control-\
      This "stuck" behavior is due to how the Python/C interface protects
      the Python runtime.
"""

import time
import sys
import random

sys.path.append("../Python/")
import ems

# Initialize EMS: 1 process, no thread-core affinity, user provided parallelism
ems.initialize(1, False, "user")

# The EMS array attributes must be the same by all programs sharing the array,
# with the exception of the the initial file creation which uses "useExisting:False"
# instead of "useExisting:True"
maxNKeys = 100
bytesPerEntry = 100  # Bytes of storage per key, used for key (dictionary word) itself
shared = ems.new({
    'useExisting':
    True,  # Connect the EMS memory created by JS, do not create a new memory
    'filename': "interlanguage.ems",  # Persistent EMS array's filename
    'dimensions': maxNKeys,  # Maximum # of different keys the array can store
    'heapSize': maxNKeys *
    100,  # 100 bytes of storage per key, used for key (dictionary word) itself
    'useMap': True  # Use a key-index mapping, not integer indexes
})