cub icon indicating copy to clipboard operation
cub copied to clipboard

Documentation (& code) regarding determining temp_storage_bytes not very clear

Open eyalroz opened this issue 8 years ago • 3 comments

I would like to be able to determine my device-wide primitive's temp_storage_bytes before I have all of the primitive's arguments ready. The interface for obtaining it ostensibly requires everything to be ready for the actual run - and the documentation does not make it clear what arguments it actually needs and what it's going to do with them (e.g. will it look at the input at all, in any way? Probably not, but who knows)

Also, delving into the source (in my case: dispatch_select_if.cuh), I see:

if (d_temp_storage == NULL)
{
    // Return if the caller is simply requesting the size of the storage allocation
    break;
}

which is super-weird. What if I passed a pointer to a size_t containing 2^64-1? Would my code be led to believe it has to allocate that much? Hmm.

eyalroz avatar Mar 31 '16 20:03 eyalroz

From my experience with library, the arguments to calculate temp storage size are data type(s) (templated) and length of it. I call the methods very early in the code with all pointers set to nullptr and only non-zero argument is size of the data to be processed and get the temp size that works fine till the very end. Hope this helps.

daktfi avatar Jan 20 '17 05:01 daktfi

Yep. That is the case for everything currently in CUB: we need to know the data types and length of input. The iterators:pointers can be null.

dumerrill avatar Jan 20 '17 14:01 dumerrill

We should add a section to the docs about this. A generic section that explains the common pattern and conventions for using the cub::Device* API would be useful.

alliepiper avatar May 06 '22 20:05 alliepiper