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: 1d34c06d797b
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: 6b98f867de14
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 29, 2015

  1. Copy the full SHA
    a8c13cb View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    86fef7b View commit details
  3. add speed benchmark

    sbourdeauducq committed Jul 29, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1ddb192 View commit details
  4. Copy the full SHA
    6b98f86 View commit details
Showing with 149 additions and 1 deletion.
  1. +4 −0 artiq/__init__.py
  2. +1 −1 artiq/gui/explorer.py
  3. +2 −0 artiq/master/worker_impl.py
  4. +142 −0 examples/master/repository/speed_benchmark.py
4 changes: 4 additions & 0 deletions artiq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from artiq import language
from artiq.language import *
from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE,
PHASE_MODE_TRACKING)

__all__ = []
__all__.extend(language.__all__)
__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE",
"PHASE_MODE_TRACKING"]
2 changes: 1 addition & 1 deletion artiq/gui/explorer.py
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ def __init__(self, procdesc):
if procdesc["min"] is not None:
self.setMinimum(procdesc["min"])
if procdesc["max"] is not None:
self.setMinimum(procdesc["max"])
self.setMaximum(procdesc["max"])
if procdesc["unit"]:
self.setSuffix(" " + procdesc["unit"])
if "default" in procdesc:
2 changes: 2 additions & 0 deletions artiq/master/worker_impl.py
Original file line number Diff line number Diff line change
@@ -138,6 +138,8 @@ def set(self, name, value):
def examine(dmgr, pdb, rdb, file):
module = file_import(file)
for class_name, exp_class in module.__dict__.items():
if class_name[0] == "_":
continue
if is_experiment(exp_class):
if exp_class.__doc__ is None:
name = class_name
142 changes: 142 additions & 0 deletions examples/master/repository/speed_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import time

from artiq import *


class _PayloadNOP(EnvExperiment):
def build(self):
pass

def run(self):
pass


class _PayloadCoreNOP(EnvExperiment):
def build(self):
self.attr_device("core")

@kernel
def run(self):
pass


class _PayloadCoreSend100Ints(EnvExperiment):
def build(self):
self.attr_device("core")

def devnull(self, d):
pass

@kernel
def run(self):
for i in range(100):
self.devnull(42)


class _PayloadCoreSend1MB(EnvExperiment):
def build(self):
self.attr_device("core")

def devnull(self, d):
pass

@kernel
def run(self):
# FIXME: make this a single list
# affected by issue #82 at the moment
data = [0 for _ in range(20000//4)]
for i in range(50):
self.devnull(data)


class _PayloadCorePrimes(EnvExperiment):
def build(self):
self.attr_device("core")

def devnull(self, d):
pass

@kernel
def run(self):
for x in range(1, 1000):
d = 2
prime = True
while d*d <= x:
if x % d == 0:
prime = False
break
d += 1
if prime:
self.devnull(x)


class SpeedBenchmark(EnvExperiment):
"""Speed benchmark"""
def build(self):
self.attr_argument("mode", EnumerationValue(["Single experiment",
"With pause",
"With scheduler"]))
self.attr_argument("payload", EnumerationValue(["NOP",
"CoreNOP",
"CoreSend100Ints",
"CoreSend1MB",
"CorePrimes"]))
self.attr_argument("nruns", NumberValue(10, min=1, max=1000))
self.attr_device("core")
self.attr_device("scheduler")

def run_with_scheduler(self):
nruns = int(self.nruns)

donop_expid = dict(self.scheduler.expid)
donop_expid["class_name"] = "_Payload" + self.payload
donop_expid["arguments"] = {}
for i in range(nruns):
self.scheduler.submit(self.scheduler.pipeline_name, donop_expid,
self.scheduler.priority, None, False)

report_expid = dict(self.scheduler.expid)
report_expid["class_name"] = "_Report"
report_expid["arguments"] = {
"start_time": time.monotonic(),
"nruns": nruns}
self.scheduler.submit(self.scheduler.pipeline_name, report_expid,
self.scheduler.priority, None, False)

def run_without_scheduler(self, pause):
payload = globals()["_Payload" + self.payload](*self.dbs())

start_time = time.monotonic()
for i in range(int(self.nruns)):
payload.run()
if pause:
self.core.comm.close()
self.scheduler.pause()
end_time = time.monotonic()

self.set_result("benchmark_run_time",
(end_time-start_time)/self.nruns,
realtime=True)


def run(self):
if self.mode == "Single experiment":
self.run_without_scheduler(False)
elif self.mode == "With pause":
self.run_without_scheduler(True)
elif self.mode == "With scheduler":
self.run_with_scheduler()
else:
raise ValueError


class _Report(EnvExperiment):
def build(self):
self.attr_argument("start_time")
self.attr_argument("nruns")

def run(self):
end_time = time.monotonic()
self.set_result("benchmark_run_time",
(end_time-self.start_time)/self.nruns,
realtime=True)