Thanks Andreas, that was definitely a mistake.  The other error was in my
understanding of the block size argument and the grid argument and how they
work.  The block argument here was supposed to be (256,1,1) not (5,1,1),
where 256 was the CACHE_SIZE for each of the CUDA threads in the kernel.

Reading a bit on how CUDA threads work and the CUDA threading model was
extremely helpful in this!

I was correct that my problem was somewhere in the chunk of code making the
call though!

Off to read more on CUDA basics to prevent shooting myself in the foot again
like this.  And I'll see if I can re-write what I've done so far with
gpuarrays.

By the way, your Hedge package is extremely cool and I'm looking forward to
experimenting with it at some point.

Raefer

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Andreas Klöckner
Sent: Wednesday, April 29, 2009 3:37 PM
To: [email protected]
Subject: Re: [PyCuda] Odd results from PyCUDA port of options pricing
example

I see one potential issue:

  b_gpu = cuda.mem_alloc(len(h_OptionData))

You probably mean len(h_OptionData)*numpy.dtype(numpy.float32).itemsize,
which is a long way of saying len(h_OptionData)*4.

Word of advice: Use gpuarrays. Less foot-shooting potential.

Andreas

On Mittwoch 29 April 2009, Raefer Gabriel wrote:
> Hi all,
>
> I am trying to port the binomial options example from the CUDA SDK to
> pyCuda as a learning  exercise primarily, and I seem to be getting
> incorrect results and am having trouble tracking down the problem.  I am
> new to CUDA and pyCuda.
>
> Source code is here (no external dependencies other than pycuda - I'm
> running Python 2.6 here on Ubuntu 9.04, and CUDA and pyCuda pass all
> included tests as working fine):
> http://www.alaricuscapital.com/pycuda-binomial.txt
>
> I know that the basic logic in the kernel is correct, since it is copied
> from the binomialOptions example in the SDK.  However, I had to make a few
> minor tweaks to it - namely, instead of using static arrays, I am passing
> in the options input data as array arguments to the kernel, and I copied
in
> some #defines from the header to make it compile smoothly.
>
> I have verified that this data I'm trying to pass is being received
> properly in the kernel, by changing the kernel's return values to match
> each of the input variables - so I am at least getting data to the
> function!
>
> And I verified my comparison function "binomialOptionFromProcessed"
against
> a known-good implementation of European Call binomial option pricing from
> the pyFinancials library - they produce identical results for the same
> number of steps, so I know I didn't munge that up.
>
> However, they are clearly not producing consistent results.
>
> So the two possibilities seem to be that I'm doing something wrong in the
> pyCuda portion of my code that is mucking up my data down at the bottom of
> the binomialOptionsGPU function, or that in tweaking the kernel from the
> SDK I have broken something in the kernel (either because I replaced the
> static arrays, or something else).
>
> I was hoping for some guidance on this, at least to help me rule out
stupid
> mistakes with how I am invoking pyCUDA so I can better focus my debugging
> efforts.
>
> Thanks in advance for any help!
>
> Raefer Gabriel
>
>
>
>
> _______________________________________________
> PyCuda mailing list
> [email protected]
> http://tiker.net/mailman/listinfo/pycuda_tiker.net




_______________________________________________
PyCuda mailing list
[email protected]
http://tiker.net/mailman/listinfo/pycuda_tiker.net

Reply via email to