[vsipl++] vsip::Vector and mlock
Jules Bergmann
jules at codesourcery.com
Thu Nov 6 15:17:40 UTC 2008
Stefan Seefeld wrote:
> Gaetano Mendola wrote:
>
>> I need to do the same with vsip::vector<T> becouse I'm
>> replacing in my application that std::vector with a
>> vsip::Vector (I need to perform an FFT on it), is it
>> safe do:
>>
>> vsip::Vector<T> myVector;
>> ...
>> mlock(&myVector(0), sizeof(t)*myVector.size());
>
> While Sourcery VSIPL++ provides direct data access, this is quite a bit
> more involved than the above, as VSIPL++ views encapsulate memory
> management quite differently compared to std::vector<>.
Sourcery VSIPL++ also has a feature called user-specified storage that
binds a VSIPL++ view to memory allocated outside the library. This
would allow you to allocate the memory in any way you choose (including
locking it down). Here's an example of what this might look like:
allocate your data outside of VSIPL++:
T* myPtr = new T[size];
mlock(myPtr, sizeof(T)*size);
then create a VSIPL++ view/block that refers to it:
Dense<T> block(size, myPtr);
Vector<T> view(block);
before you use view/block in VSIPL++, you need to admit the data into
the library:
block.admit();
at this point, you can use 'view' like any other VSIPL++ view,
performing FFTs on it, etc.
fft(view);
Finally, when you're done, you need to release the data:
block.release();
Also, different VSIPL++ backends have requirements on data layout,
primarily for alignment. To be safest, you'll want to make sure the
data you allocate has SIMD or cache line alignment, typically 32 B on x86.
-- Jules
--
Jules Bergmann
CodeSourcery
jules at codesourcery.com
(650) 331-3385 x705
More information about the vsipl++
mailing list