On Fri, Jun 14, 2019 at 4:29 PM Nikhil Garg <
nikhilg...@gmail.com> wrote:
>
> I am trying to wrap a c++ function which takes a std::vector of a c++ class and performs some operation on it and returns a c++ class object as an output. The c++ function performs those operations on GPU. I have managed to write a cython class which can create a std::vector of c++ class pointers held by the cython class.
>
> I have also tested that c++ can see that the vector indeed contains the c++ class objects. I was earlier having segmentation fault as I never initialized "thisptr" with an instance of c++ class within cython. As i did not initialize it, i was pushing NULL into a std::vector in cython. It was compiling but was giving me segmentaton fault.
Note also that if the Cython classes own the C++ classes (that is,
they deallocate them on cleanup) you'll have to be sure to keep them
around as well for the pointers in the vector to remain valid.
> However, now I am wondering that although, I am able to pass the std::vector of c++ class object from cython to c++, I am not able to run the computation from the function GPU. I have an alternative test executable in c++, which is able to perform the same operation, but I can't do that when I call the function from cython.
What goes wrong when you try to run the computation? Perhaps an
example of the C++ code that works would be helpful in constructing
the equivalent code in Cython.
> To unsubscribe from this group and stop receiving emails from it, send an email to
cython-users...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/cython-users/8c4e5cdc-2206-4463-b983-8f7bbfc34fef%40googlegroups.com.