I wrote a simple c++ openMP program that use SSE instructions, and I am facing the Segmentation fault when the number of threads is bigger than 4. I am using g++ as compiler and linux as OS.
Please help me
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <emmintrin.h>
#include <assert.h>
#include <stdint.h>
#include <omp.h>
unsigned **a;
void f(int input_index){
int j;
__m128i* t = (__m128i*) a[input_index];
for(j=0; j<4; j++)
t[j] = _mm_set1_epi32(input_index* lenS);
}
int main(int argc, char *argv[])
{
int i,j,nThreads,tid;
bitD = new unsigned*[4];
for(i=0; i<4; i++)
bitD[i] = new unsigned[16];
omp_set_num_threads(8);
#pragma omp parallel private(i,nThreads,tid)
{
tid = omp_get_thread_num();
nThreads = omp_get_num_threads();
for(i=0; i<(4/nThreads); i++){
f(i*nThreads+tid);
}
}
for(i=0; i<4; i++)
for(j=0; j<16; j++)
printf("a[%d][%d]=%d\n",i,j,bitD[i][j]);
}
Aucun commentaire:
Enregistrer un commentaire