Skip to content

Commit

Permalink
Merge branch 'master' of github.com:RRZE-HPC/kerncraft
Browse files Browse the repository at this point in the history
  • Loading branch information
cod3monk committed Feb 17, 2022
2 parents 9a57a73 + 28be1d7 commit b5a302d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kerncraft/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from . import incore_model
from .pycparser_utils import clean_code, replace_id

from kerncraft.symbolic.utils import int_ceil

@contextmanager
def set_recursionlimit(new_limit):
Expand Down Expand Up @@ -389,7 +390,7 @@ def iteration_length(self, dimension=None):

for var_name, start, end, incr in loops:
# This unspools the iterations:
length = end-start
length = int_ceil((end-start), incr)
total_length = total_length*length
return self.subs_consts(total_length)

Expand Down Expand Up @@ -483,7 +484,7 @@ def global_iterator_to_indices(self, git=None):
loop_var = symbol_pos_int(var_name)

# This unspools the iterations:
length = end-start # FIXME is incr handled correct here?
length = int_ceil((end-start), incr)
counter = start+(((global_iterator*last_incr) // total_length)*incr) % length
total_length = total_length*length
last_incr = incr
Expand Down Expand Up @@ -511,7 +512,7 @@ def global_iterator(self):
total_length = sympy.Integer(1)
for var_name, start, end, incr in reversed(self._loop_stack):
loop_var = symbol_pos_int(var_name)
length = end - start # FIXME is incr handled correct here?
length = int_ceil((end-start), incr)
global_iterator += (loop_var - start) * total_length
total_length *= length
return global_iterator
Expand Down
1 change: 1 addition & 0 deletions kerncraft/symbolic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from kerncraft.symbolic.utils import int_ceil, int_floor
19 changes: 19 additions & 0 deletions kerncraft/symbolic/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sympy

class int_floor(sympy.Function):
@classmethod
def eval(cls, x, y):
if x.is_Number and y.is_Number:
return x // y

def _eval_is_integer(self):
return True

class int_ceil(sympy.Function):
@classmethod
def eval(cls, x, y):
if x.is_Number and y.is_Number:
return sympy.ceiling(x / y)

def _eval_is_integer(self):
return True

0 comments on commit b5a302d

Please sign in to comment.