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

Commits on Oct 11, 2014

  1. Copy the full SHA
    3ee9a87 View commit details
  2. Copy the full SHA
    9925568 View commit details
  3. Copy the full SHA
    8feb141 View commit details
  4. Copy the full SHA
    77967f6 View commit details
1 change: 1 addition & 0 deletions artiq/devices/runtime.py
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ def init_module(self, module):
func_type = lc.Type.function(lc.Type.int(), [lc.Type.pointer(lc.Type.int(8))])
function = self.llvm_module.add_function(func_type, "__eh_setjmp")
function.add_attribute(lc.ATTR_NO_UNWIND)
function.add_attribute(lc.ATTR_RETURNS_TWICE)

func_type = lc.Type.function(lc.Type.pointer(lc.Type.int(8)), [])
self.llvm_module.add_function(func_type, "__eh_push")
31 changes: 20 additions & 11 deletions artiq/transforms/lower_time.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,15 @@ def _time_to_cycles(ref_period, node):
divided)


def _time_to_cycles_opt(ref_period, node):
if (isinstance(node, ast.Call)
and isinstance(node.func, ast.Name)
and node.func.id == "cycles_to_time"):
return node.args[0]
else:
return _time_to_cycles(ref_period, node)


def _cycles_to_time(ref_period, node):
return ast.copy_location(
ast.BinOp(left=node,
@@ -52,27 +61,27 @@ def visit_Call(self, node):
return node

def visit_Expr(self, node):
self.generic_visit(node)
r = node
if (isinstance(node.value, ast.Call)
and isinstance(node.value.func, ast.Name)):
funcname = node.value.func.id
if funcname == "delay":
return ast.copy_location(
r = ast.copy_location(
ast.AugAssign(target=ast.Name("now", ast.Store()),
op=ast.Add(),
value=_time_to_cycles(self.ref_period,
node.value.args[0])),
value=_time_to_cycles_opt(
self.ref_period,
node.value.args[0])),
node)
elif funcname == "at":
return ast.copy_location(
r = ast.copy_location(
ast.Assign(targets=[ast.Name("now", ast.Store())],
value=_time_to_cycles(self.ref_period,
node.value.args[0])),
value=_time_to_cycles_opt(
self.ref_period,
node.value.args[0])),
node)
else:
return node
else:
return node
self.generic_visit(r)
return r


def lower_time(func_def, initial_time, ref_period):
2 changes: 1 addition & 1 deletion doc/manual/core_reference.rst
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ Core language reference
:members:

:mod:`artiq.language.units` module
---------------------------------
----------------------------------

.. automodule:: artiq.language.units
:members:
6 changes: 3 additions & 3 deletions doc/manual/installing.rst
Original file line number Diff line number Diff line change
@@ -72,13 +72,13 @@ The main dependency of ARTIQ is LLVM and its Python bindings (http://llvmpy.org)
$ git clone https://github.com/openrisc/llvm-or1k
$ cd llvm-or1k
$ git checkout b3a48efb2c05ed6cedc5395ae726c6a6573ef3ba
$ patch -p1 < /path_to/ARTIQ/patches/llvm/*
$ cat /path_to/artiq/patches/llvm/* | patch -p1

$ cd tools
$ git clone https://github.com/openrisc/clang-or1k clang
$ cd clang
$ git checkout 02d831c7e7dc1517abed9cc96abdfb937af954eb
$ patch -p1 < /path_to/ARTIQ/patches/clang/*
$ cat /path_to/artiq/patches/clang/* | patch -p1

$ cd ../..
$ mkdir build && cd build
@@ -90,7 +90,7 @@ The main dependency of ARTIQ is LLVM and its Python bindings (http://llvmpy.org)
$ git clone https://github.com/llvmpy/llvmpy
$ cd llvmpy
$ git checkout 7af2f7140391d4f708adf2721e84f23c1b89e97a
$ patch -p1 < /path_to/ARTIQ/patches/llvmpy/*
$ cat /path_to/artiq/patches/llvmpy/* | patch -p1
$ LLVM_CONFIG_PATH=/usr/local/llvm-or1k/bin/llvm-config sudo -E python setup.py install

.. note::
34 changes: 34 additions & 0 deletions examples/pulse_performance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from artiq import *
from artiq.devices import corecom_serial, core, rtio_core
from artiq.devices.runtime_exceptions import RTIOUnderflow


def print_min_period(p):
print("Minimum square wave output period: {} ns".format(p))


class PulsePerformance(AutoContext):
parameters = "o"

@kernel
def run(self):
T = time_to_cycles(100*ns)
while True:
try:
for i in range(1000):
self.o.pulse(cycles_to_time(T))
delay(cycles_to_time(T))
except RTIOUnderflow:
T += 1
delay(1*ms)
else:
print_min_period(int(cycles_to_time(2*T)/(1*ns)))
break


if __name__ == "__main__":
with corecom_serial.CoreCom() as com:
coredev = core.Core(com)
exp = PulsePerformance(core=coredev,
o=rtio_core.RTIOOut(core=coredev, channel=1))
exp.run()
12 changes: 12 additions & 0 deletions patches/llvmpy/0002-add-returns-twice-attribute.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/llvm/core.py b/llvm/core.py
index 20ad062..245ac65 100644
--- a/llvm/core.py
+++ b/llvm/core.py
@@ -379,6 +379,7 @@ class AttrEnum(Enum):
ATTR_NAKED = AttrVal.Naked
ATTR_INLINE_HINT = AttrVal.InlineHint
ATTR_STACK_ALIGNMENT = AttrVal.StackAlignment
+ ATTR_RETURNS_TWICE = AttrVal.ReturnsTwice

AttrEnum.declare()