reusing cudppPlan handles across algorithms?

3 views
Skip to first unread message

mroberts

unread,
Nov 24, 2009, 3:23:55 PM11/24/09
to CUDPP
Hello,

Let me begin by saying thanks for the awesome library. I'm currently
finding uses for the compact, sort, and scan operations for my MSc
project and it's helping me out a lot :)

I have a quick question about the cudppPlan interface. Is there any
safe way to reuse plan objects across algorithms? You can certainly
reuse plan objects for multiple instantiations of the same algorithm
on different sizes of data sets (up to the maximum number specified
when creating the plan), but is there any way to do this across
algorithms?

For example, in the case of doing a scan, then a compact, then a sort,
is there any way to pick whichever algorithm uses the most memory,
make a plan for this algorithm, and then conceptually "cast" the plan
for this algorithm into a plan for other algorithms (since the other
algorithms are guaranteed to use less memory)?

cheers,
mike

John Owens

unread,
Nov 24, 2009, 4:02:42 PM11/24/09
to cu...@googlegroups.com
Hi Mike, short answer is "no, you can't do that in its present form". You might be able to hack passing pointers around to reuse some memory across plans (at your own risk), but solving this correctly is a big project:

- You'd need to do a dependency analysis to figure out which memory was valid at what times and thus what you could reuse.
- You'd also want to have some sort of memory manager in the ideal case to allocate blocks of memory (and ideally, also a virtual memory manager to give the illusion of uniform blocks of memory).

This is a good argument for a higher-level language above CUDA that could handle details like this. However, it's not something we've addressed in CUDPP.

JDO


--

You received this message because you are subscribed to the Google Groups "CUDPP" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cudpp+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cudpp?hl=en.



Mark Harris

unread,
Nov 24, 2009, 4:47:59 PM11/24/09
to cu...@googlegroups.com
Hi Mike,

I agree the answer should be NO.  If this becomes a big problem for users, we should fix it inside the library rather than requiring users to hack around.  Are you interested in this because you are really tight on memory, or are you just looking to tie up loose ends?  If the latter, I would move on to bigger problems. :)

If you are really short on memory, you could technically do the allocation of internal data yourself.  For example, you could create a scan plan normally using cudppPlan(), but then create the compact plan yourself by accessing the internal CUDPPCompactPlan structure and assigning its m_scanPlan pointer the pointer from the CUDPPScanPlan created with cudppPlan.   But I would NOT recommend this, because if you make subtle mistakes, they could bite you later.  You should also be REALLY careful about this if you are using multiple GPUs and CUDA contexts.  CUDPP 1.1 is not safe for use in this situation, but the next release will be, but you will not be able to share plans across CUDA contexts.

One thing we're leaving open as a possibility for the future is to give CUDPP its own internal heap manager so that the user can specify the maximum heap size so they have some control on internal memory used by the library, and then CUDPP will reuse internal temporary allocations across plans when possible.

Mark
Reply all
Reply to author
Forward
0 new messages