-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hoist reduction loops #104
Changes from all commits
5031f78
19fb417
88373a5
875b4a0
a7a8ac0
678cade
d110454
61757ec
893a4a7
0e6144f
ccb798c
702ab2a
5060a67
1984750
244a7fe
7dd9b23
9f62168
ce9ca5d
36d0445
74804a6
8cbcb6f
064ab50
fec3baa
b3b99ff
3337830
6a344e8
c49166b
b92f96c
c1cdaae
2fdef6b
d8f2f0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,11 +447,11 @@ class Symbol(Expr): | |
a[i][3*j + 2]. | ||
""" | ||
|
||
def __init__(self, symbol, rank=(), offset=()): | ||
def __init__(self, symbol, rank=None, offset=None): | ||
super(Symbol, self).__init__([]) | ||
self.symbol = symbol | ||
self.rank = rank | ||
self.offset = offset or tuple([(1, 0) for r in rank]) | ||
self.rank = Rank(rank or ()) | ||
self.offset = offset or tuple([(1, 0) for r in self.rank]) | ||
|
||
def operands(self): | ||
return [self.symbol, self.rank, self.offset], {} | ||
|
@@ -465,6 +465,14 @@ def is_const(self): | |
from .utils import is_const_dim | ||
return not self.rank or all(is_const_dim(r) for r in self.rank) | ||
|
||
@property | ||
def is_number(self): | ||
try: | ||
float(self.symbol) | ||
return True | ||
except ValueError: | ||
return False | ||
|
||
@property | ||
def is_const_offset(self): | ||
from .utils import is_const_dim, flatten | ||
|
@@ -715,7 +723,8 @@ def __init__(self, typ, sym, init=None, qualifiers=None, attributes=None, | |
self._scope = scope or UNKNOWN | ||
|
||
def operands(self): | ||
return [self.typ, self.sym, self.init, self.qual, self.attr], {} | ||
return [self.typ, self.sym, self.init, self.qual, self.attr, | ||
self.pointers], {} | ||
|
||
def pad(self, new_rank): | ||
self.sym.rank = new_rank | ||
|
@@ -893,6 +902,10 @@ def increment(self, value): | |
def header(self): | ||
return (self.start, self.size, self.increment) | ||
|
||
@property | ||
def block(self): | ||
return self.children[0] | ||
|
||
@property | ||
def body(self): | ||
return self.children[0].children | ||
|
@@ -1216,6 +1229,26 @@ def gencode(self, not_scope=False): | |
return self.children[0].gencode() | ||
|
||
|
||
class Rank(tuple): | ||
|
||
def __contains__(self, val): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you happy with the usage that sticks an COFFEE expression into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm "kinda happy", in the sense that this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine, I do not mind having the interface cleanup (which will require corresponding changes in other components) in a separate PR after this one is merged. |
||
from coffee.visitors import FindInstances | ||
if isinstance(val, Node): | ||
val, search = str(val), type(Node) | ||
elif isinstance(val, str): | ||
val, search = val, Symbol | ||
else: | ||
return False | ||
for i in self: | ||
if isinstance(i, Node): | ||
items = FindInstances(search).visit(i) | ||
if any(val == str(i) for i in items[search]): | ||
return True | ||
elif isinstance(i, str) and val == i: | ||
return True | ||
return False | ||
|
||
|
||
# Utility functions ### | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have a specific number type if you wish...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a list of changes for COFFEE in mind including a restructuring of
base.py
, as well as the addition of new types (egNumber
) and class attributes (egis_Symbol
,is_Incr
). I'll do this in another PR