dimanche 5 avril 2020

Optimize and vectorize random function in c

I programed a function to generate pseudo-random numbers, but my compiler doesn't vectorize this not vectorized: complicated access pattern. How can I achive that the compiler vectorize this? I use the comand gcc -O3 -ffast-math -funroll-all-loops -ftree-vectorize -fopt-info-vec-missed -lm -g $1 -o ${2}.O3

    unsigned int seed;
    unsigned int temp;
    #define val13 13
    unsigned int var1 = 214013;
    unsigned int var2 = 2531011;
    inline int myRandom() {
      seed = (var1*seed + var2);
      return (seed>>val13);
    }

If I change the code to this I manage to vectorize but I do not get the expected result.

inline int myRandom() {
          return ((var1*seed + var2)>>val13);
        }

How can I achive the compiler to vectorize this function and get the expected result?




Aucun commentaire:

Enregistrer un commentaire