I have tried to apply #pragma omp simd
to the following code (loops) but it does not seem to work (no speed improvement). I also tried #pragma omp simd linear
but all my attempts resulted in a seg fault.
https://github.com/Rdatatable/data.table/blob/master/src/fsort.c#L209 https://github.com/Rdatatable/data.table/blob/master/src/fsort.c#L184
Is it even possible to increment a vector with simd
? Example:
#include <stdio.h>
#include <stdlib.h>
int main() {
int len = 1000;
int tmp[len];
for(int i=0; i<len; ++i) {
tmp[i]=rand()%100;
}
int *thisCounts = (int *) calloc(len, sizeof(int));
for (int j=0; j<len; ++j) {
thisCounts[tmp[j]]++;
}
for (int j=0; j<len; ++j) {
printf("%d, ",thisCounts[j]);
}
free(thisCounts);
return 0;
}
FYI, line 209 is the one that takes most time and I am trying to improve.
Thank you