Hi all,

I have a problem and almost a solution, but my program crashes after running and giving the right output. The problem is to use an external library, in this case chag:pp [1] which is a header file only library, along with PyCUDA. What I'm trying to do is to use their compaction algorithm on a pycuda array. I've successfully built a DLL from a C++ file which basically does this:

struct Predicate
{
    __device__ bool operator() (double value) const
    {
        return value>0.0;
    }
};
void find_positive(
        int x_gpu_start,
        int x_gpu_end,
        int y_gpu_start,
        int count_start
        )
{
    pp::compact(
        (double *)x_gpu_start, /* Input start pointer */
        (double *)x_gpu_end,   /* Input end pointer */
        (double *)y_gpu_start, /* Output start pointer */
        (size_t *)count_start, /* Storage for valid element count */
        Predicate()            /* Predicate */
        );
}

I'm then using ctypes to load this library and call that function, like this:

lib = cdll.LoadLibrary('testchagpp')
find_positive = lib.find_positive
x = randn(100)
y = to_gpu(x)
out = to_gpu(zeros(len(x)))
count = to_gpu(array([0], dtype=int))
find_positive(int(y.gpudata), int(y.gpudata)+len(x)*8,
              int(out.gpudata), int(count.gpudata))


The program works, in that it correctly compacts the array x into the array y, but afterwards I get the error:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I'm on 64 bit Windows 7, but using a 32 bit build of Python, PyCuda, etc.

I see two possibilities. Possibility 1: I've just made a mistake somewhere about something obvious, and this approach should work. Possibility 2: I can't pass pycuda data to the DLL file and this causes something to break somewhere.

Any ideas?

Many thanks,
Dan Goodman

[1] http://www.cse.chalmers.se/~billeter/pub/pp/

_______________________________________________
PyCUDA mailing list
[email protected]
http://host304.hostmonster.com/mailman/listinfo/pycuda_tiker.net

Reply via email to