Aligned data types not supported in managed code

Aligned data types not supported in managed code

Hi,

When we migrate our TBB from 2.1 to 3.0, we get unsuccessful compile errors. A lot of statements saying:

"Aligned data types not supported in managed code."

I just looked at TBB headers and it does use align for the atomic class:

#define __TBB_DECL_ATOMIC_FIELD(t,f,a) __declspec(align(a)) t f;

Used here:

template<>

struct atomic_rep<4> { // Specialization

#if _MSC_VER && __TBB_WORDSIZE==4

// Work-around that avoids spurious /Wp64 warnings

typedef intptr_t word;

#else

typedef int32_t word;

#endif

__TBB_DECL_ATOMIC_FIELD(int32_t,value,4)

};

The alignment isn't any more than the usual native alignment, but the compiler still complains. I don't know why TBB added the alignment. In TBB 2.1, the alignment was only used for 8 byte atomics. Now it is used for 2, 4, and 8 byte atomics.

So what is your suggestion to fix this?

Thanks,

Wallace

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If you know that you will not use them in tightly packed structures (is that even possible?), it seems safe to remove the alignment declaration up to 4 bytes. I'm not sure about 8 bytes: on g++ there is a runtime test for alignment at even or odd 4-byte boundaries (a linker issue), but I'd have to check the implementation for Windows environments.

If there is no immediate reason to not declare alignment, it is probably safest and easiest to declare alignment for all sizes, even if in a couple of years this might only be needed for 16-byte integers and up. And why should managed code not support alignment declarations if it would automatically provide such alignment anyway, so you might want to report this to Microsoft as well.

Leave a Comment

Please sign in to add a comment. Not a member? Join today