forked from M-Labs/artiq
tests: add lit tests for subkernels
This commit is contained in:
parent
0a750c77e8
commit
8d7194941e
|
@ -0,0 +1,15 @@
|
|||
# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: type annotation for argument 'x', '1', is not an ARTIQ type
|
||||
@subkernel(destination=1)
|
||||
def foo(x: 1) -> TNone:
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK-L: ${LINE:+1}: note: in subkernel call here
|
||||
foo()
|
|
@ -0,0 +1,15 @@
|
|||
# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: type annotation for return type, '1', is not an ARTIQ type
|
||||
@subkernel(destination=1)
|
||||
def foo() -> 1:
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK-L: ${LINE:+1}: note: in subkernel call here
|
||||
foo()
|
|
@ -0,0 +1,18 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK-NOT: call void @subkernel_send_message\(.*\), !dbg !.
|
||||
no_arg()
|
||||
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-NOT-L: declare void @subkernel_send_message(i32, { i8*, i32 }*, i8**) local_unnamed_addr
|
||||
@subkernel(destination=1)
|
||||
def no_arg() -> TStr:
|
||||
pass
|
|
@ -0,0 +1,22 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK-NOT: call void @subkernel_send_message\(.*\), !dbg !.
|
||||
returning()
|
||||
# CHECK: call i8 @subkernel_await_message\(i32 1, i64 10000, i8 1, i8 1\), !dbg !.
|
||||
# CHECK: call void @subkernel_await_finish\(i32 1, i64 10000\), !dbg !.
|
||||
subkernel_await(returning)
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-NOT-L: declare void @subkernel_send_message(i32, i8, { i8*, i32 }*, i8**) local_unnamed_addr
|
||||
# CHECK-L: declare i8 @subkernel_await_message(i32, i64, i8, i8) local_unnamed_addr
|
||||
# CHECK-L: declare void @subkernel_await_finish(i32, i64) local_unnamed_addr
|
||||
@subkernel(destination=1)
|
||||
def returning() -> TInt32:
|
||||
return 1
|
|
@ -0,0 +1,22 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK-NOT: call void @subkernel_send_message\(.*\), !dbg !.
|
||||
returning_none()
|
||||
# CHECK: call void @subkernel_await_finish\(i32 1, i64 10000\), !dbg !.
|
||||
# CHECK-NOT: call void @subkernel_await_message\(i32 1, i64 10000\), !dbg !.
|
||||
subkernel_await(returning_none)
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-NOT-L: declare void @subkernel_send_message(i32, { i8*, i32 }*, i8**) local_unnamed_addr
|
||||
# CHECK-L: declare void @subkernel_await_finish(i32, i64) local_unnamed_addr
|
||||
# CHECK-NOT-L: declare void @subkernel_await_message(i32, i64) local_unnamed_addr
|
||||
@subkernel(destination=1)
|
||||
def returning_none() -> TNone:
|
||||
pass
|
|
@ -0,0 +1,25 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
class A:
|
||||
@subkernel(destination=1)
|
||||
def sk(self):
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def kernel_entrypoint(self):
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK-NOT: call void @subkernel_send_message\(.*\), !dbg !.
|
||||
self.sk()
|
||||
|
||||
a = A()
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
a.kernel_entrypoint()
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-NOT-L: declare void @subkernel_send_message(i32, i8, { i8*, i32 }*, i8**) local_unnamed_addr
|
|
@ -0,0 +1,25 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
class A:
|
||||
@subkernel(destination=1)
|
||||
def sk(self, a):
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def kernel_entrypoint(self):
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK: call void @subkernel_send_message\(i32 1, i8 1, .*\), !dbg !.
|
||||
self.sk(1)
|
||||
|
||||
a = A()
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
a.kernel_entrypoint()
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-L: declare void @subkernel_send_message(i32, i8, { i8*, i32 }*, i8**) local_unnamed_addr
|
|
@ -0,0 +1,18 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK: call void @subkernel_send_message\(i32 ., i8 1, .*\), !dbg !.
|
||||
accept_arg(1)
|
||||
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-L: declare void @subkernel_send_message(i32, i8, { i8*, i32 }*, i8**) local_unnamed_addr
|
||||
@subkernel(destination=1)
|
||||
def accept_arg(arg: TInt32) -> TNone:
|
||||
pass
|
|
@ -0,0 +1,21 @@
|
|||
# RUN: env ARTIQ_DUMP_LLVM=%t %python -m artiq.compiler.testbench.embedding +compile %s
|
||||
# RUN: OutputCheck %s --file-to-check=%t.ll
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK: call void @subkernel_send_message\(i32 ., i8 1, .*\), !dbg !.
|
||||
accept_arg(1)
|
||||
# CHECK: call void @subkernel_load_run\(i32 1, i1 true\), !dbg !.
|
||||
# CHECK: call void @subkernel_send_message\(i32 ., i8 2, .*\), !dbg !.
|
||||
accept_arg(1, 2)
|
||||
|
||||
|
||||
# CHECK-L: declare void @subkernel_load_run(i32, i1) local_unnamed_addr
|
||||
# CHECK-L: declare void @subkernel_send_message(i32, i8, { i8*, i32 }*, i8**) local_unnamed_addr
|
||||
@subkernel(destination=1)
|
||||
def accept_arg(arg_a, arg_b=5) -> TNone:
|
||||
pass
|
Loading…
Reference in New Issue