On Thu, Aug 25, 2011 at 2:21 AM, Francis <[email protected]> wrote: > Thanks for the replies @Eli and @David. I suppose given a 'small' enough > list of sub-lists doing what I need to do in the host is good enough instead > of moving and doing the task in the device. I am just looking out for > possible scenarios where the list of sub-lists will be 'large' enough that > moving and doing the task in the GPU using PyCUDA will be much faster. > If indeed I do go ahead with the for loop as Eli and I similarly thought > about that would have a running time of O( n ) where n is the number of > sub-lists. Since I have lots of threads I can put to use I was thinking I'd > rather do the O( n ) task in the device thus making it have a constant > running time relatively speaking. Of course that's an ideal case and doesn't > consider the device-host copy delays that much.
Perhaps I wasn't clear. Unless there's some magic interoperability between Python and CUDA that I don't know about, you *can't* send an entire python list to CUDA (and even if you could, you'd have to copy the entire thing over the PCI bus, which isn't super fast). You'd have to pre-process each sublist first. However, getting the length of a python list is O(1), and preprocessing the list is O(length of the sublist), so you're better off getting the length of each sublist in python code and sending a list of just the lengths to CUDA. However, since you can't just send a python list to CUDA, you *still* have to preprocess the list of sublist lengths (by sticking them into a numpy array, etc.) at which point you're iterating over the list of lengths in python anyway, and just tracking the one you want is going to be a performance win. Unless there's an aspect of the problem that I'm not picking up on, I really don't see how CUDA can improve the performance of this problem *at all*. Put more succinctly: the boilerplate to prepare your data to send to CUDA is going to be more expensive than computing the answer in python for this problem. HTH, Eli _______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
