Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

SIMD Programming

Pourya_Shirazian
Beginner
442 Views
I have a simd vector 4 class defined as:
[bash]		class svec4
		{
		public:
			//ALIGN(16)
			__declspec(align(16)) union{
				__m128 v;
				float f[4];
			};

			svec4()
			{
				v = _mm_setzero_ps();
			}
                 }
[/bash]
problem is the address of the variable v is not always aligned at 16 bytes and a memory exception error pops up. How can I make sure that the address assigned to a variable of type svec4 is always aligned at 16 bytes.
0 Kudos
3 Replies
Andreas_Klaedtke
Beginner
442 Views
Which version of the Intel compiler are you using and which operating system?

I have tried it with icpc 12.0.0 on a Linux system, and it seems to work fine.
0 Kudos
Om_S_Intel
Employee
442 Views
I would say no to intrinsic. It is beter to write suitable code so that compiler can generate SSE code. The code will be maintainable and portable.
0 Kudos
jimdempseyatthecove
Honored Contributor III
442 Views
Try adding the __declspec(align(16))to the class declararion as well.

Jim Dempsey
0 Kudos
Reply