mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 11:18:27 +08:00
tests: add lit tests for subkernels
This commit is contained in:
parent
0a750c77e8
commit
8d7194941e
15
artiq/test/lit/embedding/error_subkernel_annot.py
Normal file
15
artiq/test/lit/embedding/error_subkernel_annot.py
Normal file
@ -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()
|
15
artiq/test/lit/embedding/error_subkernel_annot_return.py
Normal file
15
artiq/test/lit/embedding/error_subkernel_annot_return.py
Normal file
@ -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()
|
18
artiq/test/lit/embedding/subkernel_no_arg.py
Normal file
18
artiq/test/lit/embedding/subkernel_no_arg.py
Normal file
@ -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
|
22
artiq/test/lit/embedding/subkernel_return.py
Normal file
22
artiq/test/lit/embedding/subkernel_return.py
Normal file
@ -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
|
22
artiq/test/lit/embedding/subkernel_return_none.py
Normal file
22
artiq/test/lit/embedding/subkernel_return_none.py
Normal file
@ -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
|
25
artiq/test/lit/embedding/subkernel_self.py
Normal file
25
artiq/test/lit/embedding/subkernel_self.py
Normal file
@ -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
|
25
artiq/test/lit/embedding/subkernel_self_args.py
Normal file
25
artiq/test/lit/embedding/subkernel_self_args.py
Normal file
@ -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
|
18
artiq/test/lit/embedding/subkernel_with_arg.py
Normal file
18
artiq/test/lit/embedding/subkernel_with_arg.py
Normal file
@ -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
|
21
artiq/test/lit/embedding/subkernel_with_opt_arg.py
Normal file
21
artiq/test/lit/embedding/subkernel_with_opt_arg.py
Normal file
@ -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
Block a user