Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.

I defined byte array as following.

BYTE buffer[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

And I call '_mm_load_si128()'.

__m128i current_0 = _mm_load_si128((__m128i*)buffer);

But, It occured error message 'Access Violation'.

Is it wrong? I really don't know..

Please give me advice. Thank you :)

What I have tried:

I tried as following code.

BYTE buffer[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
__m128i current_0 = _mm_loadu_si128((__m128i*)buffer);

It worked.
But I don't know they have difference of performance '_mm_loadu_si128' and '_mm_load_si128' when the image has big size.
Posted
Updated 8-Apr-16 3:10am
v2
Comments
nv3 8-Apr-16 12:19pm    
For _mm_load_si128 to work correctly the buffer needs to be aligned on a 16-byte boundary. And your buffer, just allocated on the stack, probably is not aligned or just by chance. If you don't know what "alignment" means, google it. Without that knowledge you will not be able to get far with SIMD instructions.

1 solution

See _mm_loadu_si128[^]. _mm_load_si128 needs the byte array to be 16-byte aligned. The performance will be slower for the non-aligned array.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900