Community
cancel
Showing results for 
Search instead for 
Did you mean: 
unrue
Beginner
70 Views

Single load operation

Dear Intel developers,

by using a __mm128 type, what is the best and fast way to fill that type one float per time starting from an array of float? Thanks.

Tags (1)
0 Kudos
5 Replies
TimP
Black Belt
70 Views

Did you consult intrinsics guide, e.g. https://software.intel.com/sites/landingpage/IntrinsicsGuide/ ?

If you don't want _mm_set_ps or _mm_setr_ps, you will need to explain your requirements.  Depending on what you have in mind, the C++ or possibly the ISA forum may be appropriate.

These intrinsics will choose appropriate instructions according to your compiler architecture switch setting.  Supposing that you do want to change just one 32-bit field, you can set the other fields to the current values, and check whether the compiler optimizes away redundant operations.

unrue
Beginner
70 Views

Tim P. wrote:

Did you consult intrinsics guide, e.g. https://software.intel.com/sites/landingpage/IntrinsicsGuide/ ?

If you don't want _mm_set_ps or _mm_setr_ps, you will need to explain your requirements.  Depending on what you have in mind, the C++ or possibly the ISA forum may be appropriate.

These intrinsics will choose appropriate instructions according to your compiler architecture switch setting.  Supposing that you do want to change just one 32-bit field, you can set the other fields to the current values, and check whether the compiler optimizes away redundant operations.

 

Hi Tim,

Yes I use frequently Intel Intrinsics Guide, but at the moment I didn't find a solution. Starting from a __m128 type, so having 4 floats [1, 2, 3, 4] I would like to set a single float per time without modify the others. By using a maskload for example, I can set a single elements, but the others are set to zero from that instructions, but It seems, also from your reply, the partial solution is to rewrite the elements with the same values except the value to modify

McCalpinJohn
Black Belt
70 Views

It is easy enough to write the four values to consecutive memory locations using a 4-element dummy array, then perform a 128-bit load to get them all back into a vector register.   I find this more convenient than figuring out some of the more obscure intrinsic functions.
 

jimdempseyatthecove
Black Belt
70 Views

Try

masked load of target (same mask as for source)
masked load of source
xor the mask load of target with target (zeroing out the field of interest)
or the masked load of source into the target (with zeroed out the field of interest)

Jim Dempsey
 

Bernard
Black Belt
70 Views

Usually I am using what @John described in his response. As a additional advise you may align your float array on 16-byte boundaries before loading it into XMM register.

 

Reply