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: return right * left else: return str(right) + str(left) def target(idx): return idx + (ems.myID * nelem)
# 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 }) # ------------------------------------------------------------------------------------------ # Begin Main Program print """Start this program after the JS program. If this Python appears hung and does not respond to ^C, also try ^\ and ^Z ---------------------------------------------------------------------------- """ # Initial synchronization with JS # Write a value to empty memory and mark it full shared.writeEF("Py hello", "from Python")
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 else: return str(right) + str(left) def target(idx): return idx + (ems.myID * nelem)