While working on gh-177, I spent quite some time dealing with weird/unhelpful error messages and/or limitations that arise with functors that don't arise with isolated workunits. For example,
import pykokkos as pk
@pk.functor
class Workload_gh_173:
def __init__(self, s: int):
self.size: pk.int = s
@pk.workunit
def store_result(self, i: int, result: pk.View1D[pk.int64]):
result[i] = self.size
def test_gh_173():
w = Workload_gh_173(900)
result = pk.View([1], dtype=pk.int64)
pk.parallel_for(1, w.store_result, result=result)
Fails after python runtests.py -t tests/test_regressions.py with a long traceback that isn't particularly helpful in identifying the problem:
While working on gh-177, I spent quite some time dealing with weird/unhelpful error messages and/or limitations that arise with functors that don't arise with isolated workunits. For example,
Fails after
python runtests.py -t tests/test_regressions.py
with a long traceback that isn't particularly helpful in identifying the problem:Conversely (and confusingly), if I extract the workunit outside of the functor, this type of construction works just fine:
I'm inclined to say this is a bug because the error message is just not clear enough to explain why this is allowed in one case and not the other.
To make matters worse, I get a different error message with this kind of construct:
The error message is basically nonsense to me:
And if I extract the workunit from the functor, things work "ok" again, so I find this arrangement of behaviors really hard to reason about: