Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

AVX intrinsics with uin8_t and uint32_t

maeshiro_mi
Beginner
211 Views

Hi, all. I'm new with intrinsics and your help would be very appreciated.

I want to vectorize some std::vectors processing and my question is, how can I add(or subtract)  std::vector<uint8_t> and std::vector<uint32_t>?

Thanks in advance!

0 Kudos
5 Replies
Om_S_Intel
Employee
211 Views

The data types need to be of the same type. Also data access must be done using single stride for vectorization. These condition will not be met in your case.

 

maeshiro_mi
Beginner
211 Views

Thanks om-sachan.

The Auto-Vectorizer is able to vectorize this for loop, right?

std::vector<uint8_t> vec1;
vec1.resize(8192);
std::vector<uint32_t> vec2;
vec2.resize(8192);

for (int i = 0; i < 8192; i++) {
  vec2 += vec1;
}

So I thought I could code it with intrinsics to start learning.

Thanks again om-sachan!

Bernard
Black Belt
211 Views

@maeshiro_mi

Run your code and inspect disassembly you should see vmovaps(d) and vaddps(d) instructions or their integer counterparts.

maeshiro_mi
Beginner
211 Views

Thanks iliyapolak.

I found very interesting checking assembly and converting it to intrinsics.

Bernard
Black Belt
211 Views

maeshiro_mi wrote:

Thanks iliyapolak.

I found very interesting checking assembly and converting it to intrinsics.

I must admit that I am doing the same:)

Reply