Right. As you can see from the example I posted, you have to keep a
separation between host compiler code and nvcc code, which you then
link together. There are a few things to keep in mind.
1) NVCC cannot see any boost::python. I'm in the process of filing a
bug against boost::python, which contains some non-standard C++ that
will never be compilable by NVCC. Consequently, you'll need to do all
the manipulation of Python objects (access, construction) in host code
compiled with the host compiler.
2) The host compiler cannot see any GPU code. So all your calls to
Thrust, etc. should be done from the device module. You can include
your own code and link against your own libraries with the appropriate
Codepy calls.
3) As far as templates go, I've used two main strategies. As you
mentioned, one is to write a wrapper which instantiates the template,
and call that wrapper from the host code. The other is to use
explicit template instantiation in the device module, and use an
extern template instantiation in the host module. Both have worked
for me in the past.
- bryan
On Wed, May 23, 2012 at 2:20 AM, Apostolis Glenis <apostglen46(a)gmail.com> wrote:
Really cool stuff.I guess I can have my thrust code in
a different file and
just compile the file at runtime,correct?
One more thing is templates.If I have a function that requires template
argument,i have to write a wrapper function for initialization at runtime?
Thanks again,
Apostolis
2012/5/23 Bryan Catanzaro <bcatanzaro(a)acm.org>
Thanks and Done!
- bryan
On Tue, May 22, 2012 at 4:29 PM, Andreas Kloeckner
<lists(a)informa.tiker.net> wrote:
> On Tue, 22 May 2012 15:43:12 -0700, Bryan Catanzaro <bcatanzaro(a)acm.org>
> wrote:
>> Sure, here's an example of how to call thrust::sort on a PyCUDA
>> gpuarray.
>>
https://gist.github.com/2772091
>
> Cool, like it! I've stolen this and put it here:
>
>
http://wiki.tiker.net/PyCuda/Examples/ThrustInterop
>
> Bryan, can you please fill in a license there?
>
> Thanks!
> Andreas