Re: [Loopy] Loopy -- Structs ?
by Andreas Kloeckner
Fred Burton <fredlburton(a)gmail.com> writes:
> Hi,
>
> Is there a different syntax that I need to use for structs? (also, how
> would I go about registering a preamble generator here?)
Thanks for the report. Turns out assigning to struct components was
broken. Fix and test here:
https://gitlab.tiker.net/inducer/loopy/merge_requests/96
This should show up in master before too long.
Andreas
2 years, 8 months
Re: [Loopy] Instruction -> Statement rename
by Andreas Kloeckner
Marmaduke Woodman <wdmn(a)protonmail.ch> writes:
> I view Loopy as a VM/backend for my work, so I personally think
> instruction is a good choice.... reviewers nitpick when they can't
> find anything useful to say.
Thanks all for your feedback. I'll wait for a quiet moment (in terms of
pending patches) and make it happen. I think it's ultimately the better
term, and aside from merge conflicts, I think it should be an easy
change.
Andreas
2 years, 9 months
Re: [Loopy] Loopy -- Structs ?
by Andreas Kloeckner
Hi Fred,
Fred Burton <fredlburton(a)gmail.com> writes:
> In PyOpenCL I saw there was a way to map structs (numpy dtypes) to structs
> in opencl
> (It seems handy for keeping data organized in and out of the kernels).
>
> Does loo.py support something like this (structs)?
> Is there a way to make this (OpenCL / PyOpenCL structs) work with loo.py ?
Yes, this should be no problem. The PyOpenCL target uses PyOpenCL's
type registry, so if you have the type working with PyOpenCL, it should
work with loopy, with the one caveat that you may need to register a
preamble generator to add the type declaration.
Andreas
2 years, 9 months
Re: [Loopy] Loopy -- Small vectors
by Andreas Kloeckner
Fred Burton <fredlburton(a)gmail.com> writes:
> Hi,
>
> In OpenCL I believe you can use float3 and similar small tuple types (for
> 3d geometry ops for example) to add, dot3, etc.
> Is there support for this in loo.py kernel syntax ?
>
> I'd like to be able to do things like:
>
> // normalize a vector
> <> nv = unv / sqrt(dot3(unv,unv))
>
> where unv is a float3
> without needing to add many lines of code or manually introducing more
> inames, etc.
> (it seems like I'd need an iname over unv for the dot product, and another
> one for scaling the output)
PyOpenCL defines short vector types, and if you're using the PyOpenCL
target, you can use those. Loopy doesn't yet expose all of the CL
built-in functions though--patches welcome.
That said, I consider using explicit short vector types in loopy a bit
"un-idiomatic". You can write scalar programs, tag short-vector iname
axes as "vec" and corresponding (data) array axes as "vec", and loopy
should produce short-vector code for you.
Andreas
2 years, 9 months
Fwd: Loopy - Indexing into arrays ?
by Fred Burton
(forwarding to list in case this helps others -- oops, I guess I have to
get used to using mailing lists properly :) )
Thanks !
With your help I was able to get it to work as:
code = '''
<> j = indys[i]
out[i] = xs[j]
'''
args = [lp.GlobalArg("xs", shape=("n_available",), dtype=np.float32),
lp.GlobalArg("indys", shape=("n_selected",), dtype=np.int32),
lp.ValueArg("n_available", dtype=np.int32),
"..."]
getselected = lp.make_kernel(
"{ [i]: 0<=i<n_selected }",
code,
args)
print (getselected)
ev,outs = getselected(queue, xs=xs, indys = indys, n_available=len(xs))
print (outs)
2 years, 9 months
Loopy -- Small vectors
by Fred Burton
Hi,
In OpenCL I believe you can use float3 and similar small tuple types (for
3d geometry ops for example) to add, dot3, etc.
Is there support for this in loo.py kernel syntax ?
I'd like to be able to do things like:
// normalize a vector
<> nv = unv / sqrt(dot3(unv,unv))
where unv is a float3
without needing to add many lines of code or manually introducing more
inames, etc.
(it seems like I'd need an iname over unv for the dot product, and another
one for scaling the output)
Thanks,
2 years, 9 months
Loopy -- Structs ?
by Fred Burton
Hi,
In PyOpenCL I saw there was a way to map structs (numpy dtypes) to structs
in opencl
(It seems handy for keeping data organized in and out of the kernels).
Does loo.py support something like this (structs)?
Is there a way to make this (OpenCL / PyOpenCL structs) work with loo.py ?
Thanks,
2 years, 9 months
Re: [Loopy] Loopy - Indexing into arrays ?
by Dominic Kempf
Hey Fred,
For your minimum example, I need to add arguments for xs and indys (and
specifically its type information) to the kernel to make code generation
work. Like this:
getselected = lp.make_kernel(
"{ [i]: 0<=i<n_selected }",
code,
[lp.GlobalArg("xs", shape=("n_selected",), dtype=np.float64),
lp.GlobalArg("indys", shape=("n_selected",), dtype=np.float64),
"..."])
I hope that helps,
Dominic
On Sat, Mar 4, 2017 at 1:36 AM, Fred Burton <fredlburton(a)gmail.com> wrote:
> Hi,
>
> From the documentation I think this should work but so far I haven't been
> able to get the simplest examples that use this to work in loo.py version
> (both? 2016.2 and git master) (on Python 2.7.13 on OSX)
>
> When I run your examples/sparse.py, I get:
>
> ValueError: <class 'loopy.tools.PersistentHashWalkMapper'> encountered
> invalid foreign object: None
>
> and my own "minimal" examples also don't work for me:
>
> ---
>
> # Select indexed values from xs array
> code = '''
> <> j = indys[i]
> out[i] = xs[j]
> '''
>
> getselected = lp.make_kernel(
> "{ [i]: 0<=i<n_selected }",
> code)
>
> print (getselected)
>
> getselected = loopy.assume(getselected, "j >= 0")
> getselected = loopy.assume(getselected, "j < 10")
>
> ev,outs = getselected(queue, xs=xs, indys = indys)
>
> print (outs)
>
> ---
>
> Is this not working in the current version, or are there syntax/api
> changes, or more assumptions/information that I need to provide for it to
> work?
>
> Thanks.
>
> _______________________________________________
> Loopy mailing list
> Loopy(a)tiker.net
> https://lists.tiker.net/listinfo/loopy
>
>
2 years, 9 months
Loopy - Indexing into arrays ?
by Fred Burton
Hi,
>From the documentation I think this should work but so far I haven't been
able to get the simplest examples that use this to work in loo.py version
(both? 2016.2 and git master) (on Python 2.7.13 on OSX)
When I run your examples/sparse.py, I get:
ValueError: <class 'loopy.tools.PersistentHashWalkMapper'> encountered
invalid foreign object: None
and my own "minimal" examples also don't work for me:
---
# Select indexed values from xs array
code = '''
<> j = indys[i]
out[i] = xs[j]
'''
getselected = lp.make_kernel(
"{ [i]: 0<=i<n_selected }",
code)
print (getselected)
getselected = loopy.assume(getselected, "j >= 0")
getselected = loopy.assume(getselected, "j < 10")
ev,outs = getselected(queue, xs=xs, indys = indys)
print (outs)
---
Is this not working in the current version, or are there syntax/api
changes, or more assumptions/information that I need to provide for it to
work?
Thanks.
2 years, 9 months