Advertisement
Guest User

Untitled

a guest
Feb 6th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include "immintrin.h"
  3.  
  4. int main(int argc, char ** argv){
  5.  
  6.         int numElements = 2000;
  7.         double data[numElements];
  8.  
  9.         for(int i = 0; i < numElements; ++i){
  10.                 data[i] = (double) i;
  11.         }
  12.  
  13.         __m512d result;
  14.         __m512d summand = _mm512_set1_pd(2.0);
  15.         __m256i offsets = _mm256_set_epi32(7,6,5,4,3,2,1,0);
  16.  
  17.         for(int i = 0; i < numElements/sizeof(double); ++i){
  18.                 result = _mm512_i32gather_pd(offsets, data, sizeof(double));
  19.                 result = _mm512_add_pd(result, summand);
  20.                 _mm512_i32scatter_pd(data, offsets, result, sizeof(double));
  21.         }
  22.  
  23.         std::cout << "Value: " << data[1] << std::endl;
  24.  
  25.         return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement