C
Christian Lande
Hi all,
can anybody help me with the following code:
#include <stdio.h>
#include <emmintrin.h>
#define M 2
int main () {
int i;
__m128d *s, ts, td;
double *p = malloc(M*sizeof(*p)); //A
// double p[2]; //B
if (p==NULL) return 0;
p[0]=p[1]=1.0;
printf("%.3f %.3f\n", p[0], p[1]);
s = (__m128d *)p; //D
if (s != p) return 0;
ts = *s;
td = _mm_add_pd(ts, ts);
*s = td; //C
printf("%.3f %.3f\n", p[0], p[1]);
}
Line "C" causes a Segmentation Fault and I don't know why. If I replace line
"A" with line "B" it works correctly. Something must be wrong with line "D"
maybe somebody knows what?
Thanks for any help,
ChL
PS: I'm using an Intel Compiler icc version 8.0 on a Xeon machine compiling
with the command "icc test.c -o test -march=pentium4".
can anybody help me with the following code:
#include <stdio.h>
#include <emmintrin.h>
#define M 2
int main () {
int i;
__m128d *s, ts, td;
double *p = malloc(M*sizeof(*p)); //A
// double p[2]; //B
if (p==NULL) return 0;
p[0]=p[1]=1.0;
printf("%.3f %.3f\n", p[0], p[1]);
s = (__m128d *)p; //D
if (s != p) return 0;
ts = *s;
td = _mm_add_pd(ts, ts);
*s = td; //C
printf("%.3f %.3f\n", p[0], p[1]);
}
Line "C" causes a Segmentation Fault and I don't know why. If I replace line
"A" with line "B" it works correctly. Something must be wrong with line "D"
maybe somebody knows what?
Thanks for any help,
ChL
PS: I'm using an Intel Compiler icc version 8.0 on a Xeon machine compiling
with the command "icc test.c -o test -march=pentium4".