cpu - Trying to start working with SIMD instructions, but having problems with error (0xC0000005) in C -



cpu - Trying to start working with SIMD instructions, but having problems with error (0xC0000005) in C -

i'm trying larn work simd instructions in c. decided start working sse. using windows 8.1 , coding codeblocks in windows environment. codeblocks settings set utilize intel i7 (which have), sse enabled. programme compiles fine, error runtime hits. error "(0xc0000005)". here code:

#include <stdio.h> #include <stdlib.h> #include <math.h> #include <xmmintrin.h> float scalarsse(float *m1, float *m2) { float prod; int i; __m128 x, y, z; for(i=0; i<5; i+=4) { x = _mm_load_ps(&*m1); y = _mm_load_ps(&*m2); x = _mm_mul_ps(x, y); z = _mm_add_ps(x, z); } for(i=0; i<4; i++) { prod += z[i]; } homecoming prod; } int main() { int i; float *s1 = calloc(1,sizeof (float)); float *s2 = calloc(1,sizeof (float)); for(i=0; i<100; i++) { *s1 = 2; *s2 = 2; float scalar_product_sse = scalarsse(s1, s2); } printf("done"); free (s1); free (s2); }

i cannot utilize debug mode not in project nor know how open project in codeblocks (it gives me errors :( )

i wondering how create work without errors. thanks!

here allocating space 1 float:

float *s1 = calloc(1,sizeof (float));

you accessing more 1 float in scalarsse

maybe help, although determining exact number utilize better:

float *s1 = calloc(100,sizeof (float)); float *s2 = calloc(100,sizeof (float));

additionally:

for(i=0; i<100; i++) { *s1 = 2; *s2 = 2; float scalar_product_sse = scalarsse(s1, s2); }

this same thing 100 times - intend?

"(0xc0000005)" means 'access violation' -- have tried access memory not allowed touch (or doesn't exist)

c cpu

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -