Renamed classes and ops from Write to Store and Read to Load

This commit is contained in:
Nicolas 2026-01-01 15:34:56 +01:00
parent df5b4c19f1
commit 884fc3affd
19 changed files with 74 additions and 74 deletions

View File

@ -1,5 +1,5 @@
import pkgutil import pkgutil
from typing import Any, Sequence, TypeVar, overload, TypeAlias, Generic, cast, Callable from typing import Any, Sequence, TypeVar, overload, TypeAlias, Generic, Callable
from ._stencils import stencil_database, detect_process_arch from ._stencils import stencil_database, detect_process_arch
import copapy as cp import copapy as cp
from ._helper_types import TNum from ._helper_types import TNum
@ -360,7 +360,7 @@ class CPConstant(Node):
return self.node_hash return self.node_hash
class Write(Node): class Store(Node):
def __init__(self, input: value[Any] | Net | int | float): def __init__(self, input: value[Any] | Net | int | float):
if isinstance(input, value): if isinstance(input, value):
net = input.net net = input.net
@ -370,7 +370,7 @@ class Write(Node):
node = CPConstant(input) node = CPConstant(input)
net = Net(node.dtype, node) net = Net(node.dtype, node)
self.name = 'write_' + transl_type(net.dtype) self.name = 'store_' + transl_type(net.dtype)
self.args = (net,) self.args = (net,)
self.node_hash = hash(self.name) ^ hash(net.source.node_hash) self.node_hash = hash(self.name) ^ hash(net.source.node_hash)

View File

@ -2,7 +2,7 @@ from typing import Generator, Iterable, Any
from . import _binwrite as binw from . import _binwrite as binw
from ._stencils import stencil_database, patch_entry from ._stencils import stencil_database, patch_entry
from collections import defaultdict, deque from collections import defaultdict, deque
from ._basic_types import Net, Node, Write, CPConstant, Op, transl_type from ._basic_types import Net, Node, Store, CPConstant, Op, transl_type
def stable_toposort(edges: Iterable[tuple[Node, Node]]) -> list[Node]: def stable_toposort(edges: Iterable[tuple[Node, Node]]) -> list[Node]:
@ -132,7 +132,7 @@ def get_const_nets(nodes: list[Node]) -> list[Net]:
return [net_lookup[node] for node in nodes if isinstance(node, CPConstant)] return [net_lookup[node] for node in nodes if isinstance(node, CPConstant)]
def add_read_ops(node_list: list[Node]) -> Generator[tuple[Net | None, Node], None, None]: def add_load_ops(node_list: list[Node]) -> Generator[tuple[Net | None, Node], None, None]:
"""Add read node before each op where arguments are not already positioned """Add read node before each op where arguments are not already positioned
correctly in the registers correctly in the registers
@ -156,7 +156,7 @@ def add_read_ops(node_list: list[Node]) -> Generator[tuple[Net | None, Node], No
#if net in registers: #if net in registers:
# print('x swap registers') # print('x swap registers')
type_list = ['int' if r is None else transl_type(r.dtype) for r in registers] type_list = ['int' if r is None else transl_type(r.dtype) for r in registers]
new_node = Op(f"read_{transl_type(net.dtype)}_reg{i}_" + '_'.join(type_list), []) new_node = Op(f"load_{transl_type(net.dtype)}_reg{i}_" + '_'.join(type_list), [])
yield net, new_node yield net, new_node
registers[i] = net registers[i] = net
@ -170,7 +170,7 @@ def add_read_ops(node_list: list[Node]) -> Generator[tuple[Net | None, Node], No
yield None, node yield None, node
def add_write_ops(net_node_list: list[tuple[Net | None, Node]], const_nets: list[Net]) -> Generator[tuple[Net | None, Node], None, None]: def add_store_ops(net_node_list: list[tuple[Net | None, Node]], const_nets: list[Net]) -> Generator[tuple[Net | None, Node], None, None]:
"""Add write operation for each new defined net if a read operation is later followed """Add write operation for each new defined net if a read operation is later followed
Returns: Returns:
@ -181,19 +181,19 @@ def add_write_ops(net_node_list: list[tuple[Net | None, Node]], const_nets: list
# Initialize set of nets with constants # Initialize set of nets with constants
stored_nets = set(const_nets) stored_nets = set(const_nets)
#assert all(node.name.startswith('read_') for net, node in net_node_list if net) #assert all(node.name.startswith('load_') for net, node in net_node_list if net)
read_back_nets = { read_back_nets = {
net for net, node in net_node_list net for net, node in net_node_list
if net and node.name.startswith('read_')} if net and node.name.startswith('load_')}
registers: list[Net | None] = [None, None] registers: list[Net | None] = [None, None]
for net, node in net_node_list: for net, node in net_node_list:
if isinstance(node, Write): if isinstance(node, Store):
assert len(registers) == 2 assert len(registers) == 2
type_list = [transl_type(r.dtype) if r else 'int' for r in registers] type_list = [transl_type(r.dtype) if r else 'int' for r in registers]
yield node.args[0], Op(f"write_{type_list[0]}_reg0_" + '_'.join(type_list), node.args) yield node.args[0], Op(f"store_{type_list[0]}_reg0_" + '_'.join(type_list), node.args)
elif node.name.startswith('read_'): elif node.name.startswith('load_'):
yield net, node yield net, node
else: else:
yield None, node yield None, node
@ -207,7 +207,7 @@ def add_write_ops(net_node_list: list[tuple[Net | None, Node]], const_nets: list
if net in read_back_nets and net not in stored_nets: if net in read_back_nets and net not in stored_nets:
type_list = [transl_type(r.dtype) if r else 'int' for r in registers] type_list = [transl_type(r.dtype) if r else 'int' for r in registers]
yield net, Op(f"write_{type_list[0]}_reg0_" + '_'.join(type_list), []) yield net, Op(f"store_{type_list[0]}_reg0_" + '_'.join(type_list), [])
stored_nets.add(net) stored_nets.add(net)
@ -344,8 +344,8 @@ def compile_to_dag(node_list: Iterable[Node], sdb: stencil_database) -> tuple[bi
ordered_ops = list(stable_toposort(get_all_dag_edges(node_list))) ordered_ops = list(stable_toposort(get_all_dag_edges(node_list)))
const_net_list = get_const_nets(ordered_ops) const_net_list = get_const_nets(ordered_ops)
output_ops = list(add_read_ops(ordered_ops)) output_ops = list(add_load_ops(ordered_ops))
extended_output_ops = list(add_write_ops(output_ops, const_net_list)) extended_output_ops = list(add_store_ops(output_ops, const_net_list))
dw = binw.data_writer(sdb.byteorder) dw = binw.data_writer(sdb.byteorder)

View File

@ -2,7 +2,7 @@ from typing import Iterable, overload, TypeVar, Any, Callable, TypeAlias
from . import _binwrite as binw from . import _binwrite as binw
from coparun_module import coparun, read_data_mem, create_target, clear_target from coparun_module import coparun, read_data_mem, create_target, clear_target
import struct import struct
from ._basic_types import value, Net, Node, Write, NumLike, ArrayType, stencil_db_from_package from ._basic_types import value, Net, Node, Store, NumLike, ArrayType, stencil_db_from_package
from ._compiler import compile_to_dag from ._compiler import compile_to_dag
T = TypeVar("T", int, float) T = TypeVar("T", int, float)
@ -76,13 +76,13 @@ class Target():
if isinstance(input, ArrayType): if isinstance(input, ArrayType):
for v in input.values: for v in input.values:
if isinstance(v, value): if isinstance(v, value):
nodes.append(Write(v)) nodes.append(Store(v))
elif isinstance(input, Iterable): elif isinstance(input, Iterable):
for v in input: for v in input:
if isinstance(v, value): if isinstance(v, value):
nodes.append(Write(v)) nodes.append(Store(v))
elif isinstance(input, value): elif isinstance(input, value):
nodes.append(Write(input)) nodes.append(Store(input))
dw, self._values = compile_to_dag(nodes, self.sdb) dw, self._values = compile_to_dag(nodes, self.sdb)
dw.write_com(binw.Command.END_COM) dw.write_com(binw.Command.END_COM)

View File

@ -4,10 +4,10 @@ and give access to compiler internals and debugging tools.
""" """
from ._target import add_read_command from ._target import add_read_command
from ._basic_types import Net, Op, Node, CPConstant, Write, stencil_db_from_package from ._basic_types import Net, Op, Node, CPConstant, Store, stencil_db_from_package
from ._compiler import compile_to_dag, \ from ._compiler import compile_to_dag, \
stable_toposort, get_const_nets, get_all_dag_edges, add_read_ops, get_all_dag_edges_between, \ stable_toposort, get_const_nets, get_all_dag_edges, add_load_ops, get_all_dag_edges_between, \
add_write_ops, get_dag_stats add_store_ops, get_dag_stats
__all__ = [ __all__ = [
"add_read_command", "add_read_command",
@ -15,14 +15,14 @@ __all__ = [
"Op", "Op",
"Node", "Node",
"CPConstant", "CPConstant",
"Write", "Store",
"compile_to_dag", "compile_to_dag",
"stable_toposort", "stable_toposort",
"get_const_nets", "get_const_nets",
"get_all_dag_edges", "get_all_dag_edges",
"get_all_dag_edges_between", "get_all_dag_edges_between",
"add_read_ops", "add_load_ops",
"add_write_ops", "add_store_ops",
"stencil_db_from_package", "stencil_db_from_package",
"get_dag_stats" "get_dag_stats"
] ]

View File

@ -187,27 +187,27 @@ def get_result_stubs2(type1: str, type2: str) -> str:
@norm_indent @norm_indent
def get_read_reg0_code(type1: str, type2: str, type_out: str) -> str: def get_load_reg0_code(type1: str, type2: str, type_out: str) -> str:
return f""" return f"""
STENCIL void read_{type_out}_reg0_{type1}_{type2}({type1} arg1, {type2} arg2) {{ STENCIL void load_{type_out}_reg0_{type1}_{type2}({type1} arg1, {type2} arg2) {{
result_{type_out}_{type2}(dummy_{type_out}, arg2); result_{type_out}_{type2}(dummy_{type_out}, arg2);
}} }}
""" """
@norm_indent @norm_indent
def get_read_reg1_code(type1: str, type2: str, type_out: str) -> str: def get_load_reg1_code(type1: str, type2: str, type_out: str) -> str:
return f""" return f"""
STENCIL void read_{type_out}_reg1_{type1}_{type2}({type1} arg1, {type2} arg2) {{ STENCIL void load_{type_out}_reg1_{type1}_{type2}({type1} arg1, {type2} arg2) {{
result_{type1}_{type_out}(arg1, dummy_{type_out}); result_{type1}_{type_out}(arg1, dummy_{type_out});
}} }}
""" """
@norm_indent @norm_indent
def get_write_code(type1: str, type2: str) -> str: def get_store_code(type1: str, type2: str) -> str:
return f""" return f"""
STENCIL void write_{type1}_reg0_{type1}_{type2}({type1} arg1, {type2} arg2) {{ STENCIL void store_{type1}_reg0_{type1}_{type2}({type1} arg1, {type2} arg2) {{
dummy_{type1} = arg1; dummy_{type1} = arg1;
result_{type1}_{type2}(arg1, arg2); result_{type1}_{type2}(arg1, arg2);
}} }}
@ -289,11 +289,11 @@ if __name__ == "__main__":
code += get_op_code('mod', 'int', 'int', 'int') code += get_op_code('mod', 'int', 'int', 'int')
for t1, t2, t_out in permutate(types, types, types): for t1, t2, t_out in permutate(types, types, types):
code += get_read_reg0_code(t1, t2, t_out) code += get_load_reg0_code(t1, t2, t_out)
code += get_read_reg1_code(t1, t2, t_out) code += get_load_reg1_code(t1, t2, t_out)
for t1, t2 in permutate(types, types): for t1, t2 in permutate(types, types):
code += get_write_code(t1, t2) code += get_store_code(t1, t2)
print(f"Write file {args.path}...") print(f"Write file {args.path}...")
with open(args.path, 'w') as f: with open(args.path, 'w') as f:

View File

@ -1,5 +1,5 @@
from copapy import value from copapy import value
from copapy.backend import Write from copapy.backend import Store
import copapy.backend as cpb import copapy.backend as cpb
@ -19,16 +19,16 @@ def test_ast_generation():
#i1 = c1 * 2 #i1 = c1 * 2
#r1 = i1 + 7 #r1 = i1 + 7
#r2 = i1 + 9 #r2 = i1 + 9
#out = [Write(r1), Write(r2)] #out = [Store(r1), Store(r2)]
c1 = value(4) c1 = value(4)
c2 = value(2) c2 = value(2)
#i1 = c1 * 2 #i1 = c1 * 2
#r1 = i1 + 7 + (c2 + 7 * 9) #r1 = i1 + 7 + (c2 + 7 * 9)
#r2 = i1 + 9 #r2 = i1 + 9
#out = [Write(r1), Write(r2)] #out = [Store(r1), Store(r2)]
r1 = c1 * 5 + 8 + c2 * 3 r1 = c1 * 5 + 8 + c2 * 3
out = [Write(r1)] out = [Store(r1)]
print(out) print(out)
print('-- get_edges:') print('-- get_edges:')
@ -48,12 +48,12 @@ def test_ast_generation():
print('#', p) print('#', p)
print('-- add_read_ops:') print('-- add_read_ops:')
output_ops = list(cpb.add_read_ops(ordered_ops)) output_ops = list(cpb.add_load_ops(ordered_ops))
for p in output_ops: for p in output_ops:
print('#', p) print('#', p)
print('-- add_write_ops:') print('-- add_write_ops:')
extended_output_ops = list(cpb.add_write_ops(output_ops, const_list)) extended_output_ops = list(cpb.add_store_ops(output_ops, const_list))
for p in extended_output_ops: for p in extended_output_ops:
print('#', p) print('#', p)
print('--') print('--')

View File

@ -1,5 +1,5 @@
from copapy import value from copapy import value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import copapy as cp import copapy as cp
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
@ -22,7 +22,7 @@ def test_compile():
# Function with no passing-on-jump as last instruction: # Function with no passing-on-jump as last instruction:
ret_test = [r for v in test_vals for r in (cp.tan(value(v)),)] ret_test = [r for v in test_vals for r in (cp.tan(value(v)),)]
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
il, variables = compile_to_dag(out, copapy.generic_sdb) il, variables = compile_to_dag(out, copapy.generic_sdb)

View File

@ -1,6 +1,6 @@
import time import time
from copapy import backend from copapy import backend
from copapy.backend import Write, stencil_db_from_package from copapy.backend import Store, stencil_db_from_package
import copapy.backend as cpb import copapy.backend as cpb
import copapy as cp import copapy as cp
import copapy._binwrite as binw import copapy._binwrite as binw
@ -13,7 +13,7 @@ def test_timing_compiler():
#t2 = t1.sum() #t2 = t1.sum()
t3 = cp.vector(cp.value(1 / (v + 1)) for v in range(256)) t3 = cp.vector(cp.value(1 / (v + 1)) for v in range(256))
t5 = ((t3 * t1) * 2).magnitude() t5 = ((t3 * t1) * 2).magnitude()
out = [Write(t5)] out = [Store(t5)]
print(out) print(out)
@ -45,7 +45,7 @@ def test_timing_compiler():
print('-- add_read_ops:') print('-- add_read_ops:')
t0 = time.time() t0 = time.time()
output_ops = list(cpb.add_read_ops(ordered_ops)) output_ops = list(cpb.add_load_ops(ordered_ops))
t1 = time.time() t1 = time.time()
#for p in output_ops: #for p in output_ops:
# print('#', p) # print('#', p)
@ -53,7 +53,7 @@ def test_timing_compiler():
print('-- add_write_ops:') print('-- add_write_ops:')
t0 = time.time() t0 = time.time()
extended_output_ops = list(cpb.add_write_ops(output_ops, const_net_list)) extended_output_ops = list(cpb.add_store_ops(output_ops, const_net_list))
t1 = time.time() t1 = time.time()
#for p in extended_output_ops: #for p in extended_output_ops:
# print('#', p) # print('#', p)

View File

@ -1,5 +1,5 @@
from copapy import NumLike from copapy import NumLike
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import copapy as cp import copapy as cp
import subprocess import subprocess
import struct import struct
@ -58,7 +58,7 @@ def test_compile():
ret = (t2, t4, t5) ret = (t2, t4, t5)
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
il, variables = compile_to_dag(out, copapy.generic_sdb) il, variables = compile_to_dag(out, copapy.generic_sdb)

View File

@ -1,5 +1,5 @@
from copapy import NumLike from copapy import NumLike
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -52,7 +52,7 @@ def test_compile():
ret = (t2, t4, t5) ret = (t2, t4, t5)
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
sdb = backend.stencil_db_from_package('arm64') sdb = backend.stencil_db_from_package('arm64')
il, variables = compile_to_dag(out, sdb) il, variables = compile_to_dag(out, sdb)

View File

@ -1,5 +1,5 @@
from copapy import NumLike from copapy import NumLike
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -52,7 +52,7 @@ def test_compile():
ret = (t2, t4, t5) ret = (t2, t4, t5)
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
sdb = backend.stencil_db_from_package('armv7') sdb = backend.stencil_db_from_package('armv7')
il, variables = compile_to_dag(out, sdb) il, variables = compile_to_dag(out, sdb)

View File

@ -1,5 +1,5 @@
from copapy import value, NumLike from copapy import value, NumLike
from copapy.backend import Write, compile_to_dag, add_read_command, Net from copapy.backend import Store, compile_to_dag, add_read_command
import copapy import copapy
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
@ -26,7 +26,7 @@ def test_compile():
ret = function(c1) ret = function(c1)
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
il, vars = compile_to_dag(out, copapy.generic_sdb) il, vars = compile_to_dag(out, copapy.generic_sdb)

View File

@ -1,5 +1,5 @@
from copapy import value from copapy import value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import copapy as cp import copapy as cp
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
@ -21,7 +21,7 @@ def test_compile_sqrt():
ret = [r for v in test_vals for r in (cp.sqrt(value(v)),)] ret = [r for v in test_vals for r in (cp.sqrt(value(v)),)]
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
il, variables = compile_to_dag(out, copapy.generic_sdb) il, variables = compile_to_dag(out, copapy.generic_sdb)
@ -55,7 +55,7 @@ def test_compile_log():
ret = [r for v in test_vals for r in (cp.log(value(v)),)] ret = [r for v in test_vals for r in (cp.log(value(v)),)]
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
il, variables = compile_to_dag(out, copapy.generic_sdb) il, variables = compile_to_dag(out, copapy.generic_sdb)
@ -89,7 +89,7 @@ def test_compile_sin():
ret = [r for v in test_vals for r in (cp.sin(value(v)),)] ret = [r for v in test_vals for r in (cp.sin(value(v)),)]
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
il, variables = compile_to_dag(out, copapy.generic_sdb) il, variables = compile_to_dag(out, copapy.generic_sdb)

View File

@ -1,12 +1,12 @@
import copapy as cp import copapy as cp
from copapy import value from copapy import value
from copapy.backend import get_dag_stats, Write from copapy.backend import get_dag_stats, Store
import copapy.backend as cpb import copapy.backend as cpb
from typing import Any from typing import Any
def show_dag(val: value[Any]): def show_dag(val: value[Any]):
out = [Write(val.net)] out = [Store(val.net)]
print(out) print(out)
print('-- get_edges:') print('-- get_edges:')
@ -26,12 +26,12 @@ def show_dag(val: value[Any]):
print('#', p) print('#', p)
print('-- add_read_ops:') print('-- add_read_ops:')
output_ops = list(cpb.add_read_ops(ordered_ops)) output_ops = list(cpb.add_load_ops(ordered_ops))
for p in output_ops: for p in output_ops:
print('#', p) print('#', p)
print('-- add_write_ops:') print('-- add_write_ops:')
extended_output_ops = list(cpb.add_write_ops(output_ops, const_list)) extended_output_ops = list(cpb.add_store_ops(output_ops, const_list))
for p in extended_output_ops: for p in extended_output_ops:
print('#', p) print('#', p)
print('--') print('--')

View File

@ -1,5 +1,5 @@
from copapy import NumLike, iif, value from copapy import NumLike, iif, value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -91,7 +91,7 @@ def test_compile():
ret_test = function1(c_i) + function1(c_f) + function2(c_i) + function2(c_f) + function3(c_i) + function4(c_i) + function5(c_b) + [value(9) % 2] + iiftests(c_i) + iiftests(c_f) + [cp.asin(c_i/10)] ret_test = function1(c_i) + function1(c_f) + function2(c_i) + function2(c_f) + function3(c_i) + function4(c_i) + function5(c_b) + [value(9) % 2] + iiftests(c_i) + iiftests(c_f) + [cp.asin(c_i/10)]
ret_ref = function1(9) + function1(1.111) + function2(9) + function2(1.111) + function3(9) + function4(9) + function5(True) + [9 % 2] + iiftests(9) + iiftests(1.111) + [cp.asin(9/10)] ret_ref = function1(9) + function1(1.111) + function2(9) + function2(1.111) + function3(9) + function4(9) + function5(True) + [9 % 2] + iiftests(9) + iiftests(1.111) + [cp.asin(9/10)]
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
#ret_test += [c_i, v2] #ret_test += [c_i, v2]
#ret_ref += [9, 4.44, -4.44] #ret_ref += [9, 4.44, -4.44]

View File

@ -1,5 +1,5 @@
from copapy import NumLike, iif, value from copapy import NumLike, iif, value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -96,7 +96,7 @@ def test_compile():
#ret_test = (c_i * 100 // 5, c_f * 10 // 5) #ret_test = (c_i * 100 // 5, c_f * 10 // 5)
#ret_ref = (9 * 100 // 5, 1.111 * 10 // 5) #ret_ref = (9 * 100 // 5, 1.111 * 10 // 5)
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
sdb = backend.stencil_db_from_package('armv6') sdb = backend.stencil_db_from_package('armv6')
dw, variables = compile_to_dag(out, sdb) dw, variables = compile_to_dag(out, sdb)

View File

@ -1,5 +1,5 @@
from copapy import NumLike, iif, value from copapy import NumLike, iif, value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -96,7 +96,7 @@ def test_compile():
#ret_test = (c_i * 100 // 5, c_f * 10 // 5) #ret_test = (c_i * 100 // 5, c_f * 10 // 5)
#ret_ref = (9 * 100 // 5, 1.111 * 10 // 5) #ret_ref = (9 * 100 // 5, 1.111 * 10 // 5)
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
sdb = backend.stencil_db_from_package('armv7') sdb = backend.stencil_db_from_package('armv7')
dw, variables = compile_to_dag(out, sdb) dw, variables = compile_to_dag(out, sdb)

View File

@ -1,5 +1,5 @@
from copapy import NumLike, iif, value from copapy import NumLike, iif, value
from copapy.backend import Write, compile_to_dag, add_read_command from copapy.backend import Store, compile_to_dag, add_read_command
import subprocess import subprocess
from copapy import _binwrite from copapy import _binwrite
import copapy.backend as backend import copapy.backend as backend
@ -104,7 +104,7 @@ def test_compile():
#ret_test = [cp.get_42(c_i)] #ret_test = [cp.get_42(c_i)]
#ret_ref = [cp.get_42(9)] #ret_ref = [cp.get_42(9)]
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
#ret_test += [c_i, v2] #ret_test += [c_i, v2]
#ret_ref += [9, 4.44, -4.44] #ret_ref += [9, 4.44, -4.44]
@ -185,7 +185,7 @@ def test_vector_compile():
ret = (t2, t4, t5) ret = (t2, t4, t5)
out = [Write(r) for r in ret] out = [Store(r) for r in ret]
sdb = backend.stencil_db_from_package('x86') sdb = backend.stencil_db_from_package('x86')
il, variables = compile_to_dag(out, sdb) il, variables = compile_to_dag(out, sdb)
@ -243,7 +243,7 @@ def test_sinus():
ret_test = [si, e] ret_test = [si, e]
ret_ref = [cp.sin(a_val), (a_val + 0.87 * 2.0) ** 2 + cp.sin(a_val) + cp.sqrt(0.87)] ret_ref = [cp.sin(a_val), (a_val + 0.87 * 2.0) ** 2 + cp.sin(a_val) + cp.sqrt(0.87)]
out = [Write(r) for r in ret_test] out = [Store(r) for r in ret_test]
sdb = backend.stencil_db_from_package('x86') sdb = backend.stencil_db_from_package('x86')
dw, variables = compile_to_dag(out, sdb) dw, variables = compile_to_dag(out, sdb)

View File

@ -1,5 +1,5 @@
from copapy import value from copapy import value
from copapy.backend import Write, compile_to_dag, stencil_db_from_package from copapy.backend import Store, compile_to_dag, stencil_db_from_package
from copapy._binwrite import Command from copapy._binwrite import Command
input = value(9.0) input = value(9.0)
@ -8,7 +8,7 @@ result = input ** 2 / 3.3 + 5
arch = 'native' arch = 'native'
sdb = stencil_db_from_package(arch) sdb = stencil_db_from_package(arch)
dw, _ = compile_to_dag([Write(result)], sdb) dw, _ = compile_to_dag([Store(result)], sdb)
# Instruct runner to dump patched code to a file: # Instruct runner to dump patched code to a file:
dw.write_com(Command.DUMP_CODE) dw.write_com(Command.DUMP_CODE)