Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3134106a110c
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f50b3428e7d
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 12, 2016

  1. artiq_run: style

    sbourdeauducq committed Apr 12, 2016
    Copy the full SHA
    0cca2bb View commit details
  2. Copy the full SHA
    3c70bc4 View commit details
  3. Copy the full SHA
    437b37b View commit details
  4. Copy the full SHA
    1f50b34 View commit details
Showing with 55 additions and 10 deletions.
  1. +2 −0 RELEASE_NOTES.rst
  2. +4 −0 artiq/coredevice/comm_generic.py
  3. +9 −2 artiq/frontend/artiq_run.py
  4. +29 −4 artiq/master/worker_db.py
  5. +11 −4 artiq/master/worker_impl.py
2 changes: 2 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ unreleased [2.x]

(you may need to replace python3.5 with python)
Please always include the console output when reporting a GUI crash.
* Closing the core device communications before pausing is done automatically.
Experiments no longer need to do it explicitly.


unreleased [1.0rc3]
4 changes: 4 additions & 0 deletions artiq/coredevice/comm_generic.py
Original file line number Diff line number Diff line change
@@ -87,6 +87,10 @@ def write(self, data):
The channel is assumed to be opened."""
raise NotImplementedError


def pause(self):
self.close()

#
# Reader interface
#
11 changes: 9 additions & 2 deletions artiq/frontend/artiq_run.py
Original file line number Diff line number Diff line change
@@ -20,12 +20,15 @@
from artiq.compiler.targets import OR1KTarget
from artiq.tools import *


logger = logging.getLogger(__name__)


class StubObject:
def __setattr__(self, name, value):
pass


class StubObjectMap:
def __init__(self):
stub_object = StubObject()
@@ -40,6 +43,7 @@ def store(self, value):
self.forward_map[self.next_id] = value
self.next_id -= 1


class FileRunner(EnvExperiment):
def build(self):
self.setattr_device("core")
@@ -54,26 +58,29 @@ def run(self):
self.core.comm.serve(StubObjectMap(),
lambda addresses: self.target.symbolize(kernel_library, addresses))


class ELFRunner(FileRunner):
def compile(self):
with open(self.file, "rb") as f:
return f.read()


class LLVMIRRunner(FileRunner):
def compile(self):
with open(self.file, "r") as f:
llmodule = llvm.parse_assembly(f.read())
llmodule.verify()
return self.target.link([self.target.assemble(llmodule)],
init_fn='__modinit__')
init_fn="__modinit__")


class LLVMBitcodeRunner(FileRunner):
def compile(self):
with open(self.file, "rb") as f:
llmodule = llvm.parse_bitcode(f.read())
llmodule.verify()
return self.target.link([self.target.assemble(llmodule)],
init_fn='__modinit__')
init_fn="__modinit__")


class DummyScheduler:
33 changes: 29 additions & 4 deletions artiq/master/worker_db.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,9 @@ def _create_device(desc, device_mgr):
class DeviceManager:
"""Handles creation and destruction of local device drivers and controller
RPC clients."""
def __init__(self, ddb, virtual_devices=dict()):
def __init__(self, ddb, virtual_devices=None):
if virtual_devices is None:
virtual_devices = dict()
self.ddb = ddb
self.virtual_devices = virtual_devices
self.active_devices = OrderedDict()
@@ -141,17 +143,40 @@ def get(self, name):
self.active_devices[name] = dev
return dev

def pause_devices(self):
"""Pauses all active devices, in the opposite order as they were
requested."""
for dev in reversed(list(self.active_devices.values())):
if hasattr(dev.__class__, "pause"):
try:
dev.pause()
except:
logger.warning("Exception when pausing device %r", dev,
exc_info=True)

def resume_devices(self):
"""Resumes all active devices, in the same order as they were
requested."""
for dev in self.active_devices.values():
if hasattr(dev.__class__, "resume"):
try:
dev.resume()
except:
logger.warning("Exception when resuming device %r", dev,
exc_info=True)

def close_devices(self):
"""Closes all active devices, in the opposite order as they were
requested."""
for dev in reversed(list(self.active_devices.values())):
try:
if isinstance(dev, (Client, BestEffortClient)):
dev.close_rpc()
elif hasattr(dev, "close"):
elif hasattr(dev.__class__, "close"):
dev.close()
except Exception as e:
logger.warning("Exception %r when closing device %r", e, dev)
except:
logger.warning("Exception when closing device %r", dev,
exc_info=True)
self.active_devices.clear()


15 changes: 11 additions & 4 deletions artiq/master/worker_impl.py
Original file line number Diff line number Diff line change
@@ -76,12 +76,19 @@ def __exit__(self, type, value, traceback):


class Scheduler:
def __init__(self, device_mgr):
self.device_mgr = device_mgr

pause_noexc = staticmethod(make_parent_action("pause"))

@host_only
def pause(self):
if self.pause_noexc():
raise TerminationRequested
self.device_mgr.pause_devices()
try:
if self.pause_noexc():
raise TerminationRequested
finally:
self.device_mgr.resume_devices()

submit = staticmethod(make_parent_action("scheduler_submit"))
delete = staticmethod(make_parent_action("scheduler_delete"))
@@ -179,8 +186,8 @@ def main():
exp_inst = None
repository_path = None

device_mgr = DeviceManager(ParentDeviceDB,
virtual_devices={"scheduler": Scheduler()})
device_mgr = DeviceManager(ParentDeviceDB)
device_mgr.virtual_devices["scheduler"] = Scheduler(device_mgr)
dataset_mgr = DatasetManager(ParentDatasetDB)

try: