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

AVX intrinsics with uin8_t and uint32_t

maeshiro_mi
Beginner
601 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
601 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.

 

0 Kudos
maeshiro_mi
Beginner
601 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!

0 Kudos
Bernard
Valued Contributor I
601 Views

@maeshiro_mi

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

0 Kudos
maeshiro_mi
Beginner
601 Views

Thanks iliyapolak.

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

0 Kudos
Bernard
Valued Contributor I
601 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:)

0 Kudos
Reply