Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1116 Discussions

Support for saturation and addition instruction in AVX-512

Udupi__Nagacharan
1,558 Views

Hi 

Is there a saturation function _mm512_adds_epi32 in AVX-512 . There already exists _mm512_adds_epi16 but I could not find the same for 32 bit integers

Additionally how do we add 2 integer 32 bit vectors and not loose the carry using AVX-512 instruction. As I understand that _mm512_add_epi32 adds 2 vectors but will store only the lower 32 bits ignoring a carry ? Since addition of 2 32 bit numbers can be a 33 bit number how do we accommodate them with the AVX-512 instructions ? Any help and reference to the sample code is highly appreciated  

Thanks 

 

0 Kudos
1 Reply
Christopher_H_
Beginner
1,558 Views

For add with saturation, you could convert the numbers to 2 sets 64bit and use min/max to saturate to 32bit range. Then convert back, its not ideal but should work.

As for carry bits you could shift right, do the addition and check the relevant bit. Adds and shifts are pretty cheap so should not be very expensive.

0 Kudos
Reply