Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

STL Vector: how to get aligned memory?

Hello,

I would like to use an stl vector for some tabular data:

std::vector<float> table;

The table has to be multiplied with another vector and I want to use dsplibs DSPF_sp_vecmul for this task.

So I have two problems:

  1. The input vectors for DSPF_sp_vecmul have to be DWORD aligned - how can I do this for an std::vector's data?
  2. How can I assign the resulting vector to an std::vector?

The vector class in Qt has a possibility to get a pointer to the vector's real data - this would be quite handy for stl, too :)

Of course, I can get the same result with a C-array - but I don't like them ;)

TIA,

Markus

  • Markus Grunwald said:
    The input vectors for DSPF_sp_vecmul have to be DWORD aligned - how can I do this for an std::vector's data?

    Where is table?  Global, local, member of a class?  If it is global, you can put this line right before it ...

    #pragma DATA_ALIGN(8)

    Sorry, but this is incorrect advice.  That would align the chunk of memory reserved for the vector.  But there is no guarantee that the user data in the vector begins at that address.  There is no way to align the data within a vector.

    Markus Grunwald said:
    How can I assign the resulting vector to an std::vector?

    I've never done it, but I understand you can pass vectors to C functions, and have them work just as C arrays do.  Please see this discussion on it.

    Thanks and regards,

    -George