You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While writing compyle code, I noticed that there were a few redundancies in the syntax which made it 1) more verbose than needed, and 2) easier to make mistakes. Given below are some changes which I believe could help reduce such redundancies.
Set a global default backend: I guess cython would be a good default. I imagine most people will only use one backend at a time. Users can override the global default and users who use multiple backends can pass the backend argument explicitly or use the with_config syntax.
Remove need for annotate by default: It looks likeElementwise could wrap the function itself
Different backend for openmp: Replace parallel cython backend (backend='cython' and use_openmp=True) with possibly an 'openmp' backend (backend='openmp'). This is based on the observations that the use_openmp flag is useless by itself and that most of the algorithms compyle uses are different for cython and for openmp.
Wrapper package over numpy: This is one point I am not too sure of but it's inspired by pyopencl's array package. This makes it possible to have an interface to create arrays directly on the device if the backend is opencl or cuda. More importantly, it helps clearly differentiate between a numpy array and a "wrapped" compyle array.
If the changes above are incorporated, the simple example given for compyle would look something like this
from compyle.api import Elementwise
import compyle.array as ary
def axpb(i, x, y, a, b):
y[i] = a*sin(x[i]) + b
x = ary.linspace(0, 1, 10000)
y = ary.zeros_like(x)
a, b = 2.0, 3.0
e = Elementwise(axpb)
e(x, y, a, b)
The text was updated successfully, but these errors were encountered:
Thanks for taking the time to write this. I thought there was a global default backend already but I need to check. I've been a bit preoccupied with other things and hope to get back to this. The reason that we do not have openmp as a separate backend is that one may want to use both openmp and opencl together but then one could in theory just use the with_config. I like the idea of a numpy wrapper and didn't do it initially but perhaps we should just bite that bullet sooner rather than later.
While writing compyle code, I noticed that there were a few redundancies in the syntax which made it 1) more verbose than needed, and 2) easier to make mistakes. Given below are some changes which I believe could help reduce such redundancies.
Set a global default backend: I guess cython would be a good default. I imagine most people will only use one backend at a time. Users can override the global default and users who use multiple backends can pass the
backend
argument explicitly or use thewith_config
syntax.Remove need for
annotate
by default: It looks likeElementwise
could wrap the function itselfDifferent
backend
for openmp: Replace parallel cython backend (backend='cython' and use_openmp=True) with possibly an 'openmp' backend (backend='openmp'). This is based on the observations that theuse_openmp
flag is useless by itself and that most of the algorithms compyle uses are different for cython and for openmp.Wrapper package over numpy: This is one point I am not too sure of but it's inspired by pyopencl's array package. This makes it possible to have an interface to create arrays directly on the device if the backend is opencl or cuda. More importantly, it helps clearly differentiate between a numpy array and a "wrapped" compyle array.
If the changes above are incorporated, the simple example given for compyle would look something like this
The text was updated successfully, but these errors were encountered: