Skip to content
Snippets Groups Projects
Commit 962672ea authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added fun.c

parent 3fd32160
No related branches found
No related tags found
No related merge requests found
......@@ -780,6 +780,7 @@ test/grid_search/tests.h -text
test/grid_search/utils.c -text
test/grid_search/utils.h -text
test/inputfiles.test.in -text
test/simd/fun.c -text
test/simd/memalign.c -text
test/testStreams.py -text
test/test_Arith.py -text
......
void fun1(int nelem, double *restrict array1, double *restrict array2)
{
for ( int i = 0; i < nelem; ++i )
array1[i] += array2[i];
}
// icc -std=c99 -O3 -qopt-report=5 -march=native -openmp memalign.c fun.c
#include <stdio.h>
#include <stdlib.h>
void fun1(int nelem, double *restrict array1, double *restrict array2);
int get_alignment(double *ptr)
{
int64_t iptr = (int64_t) ptr;
......@@ -10,7 +14,7 @@ int get_alignment(double *ptr)
for ( int i = 0; i < 4; ++i )
if ( iptr%mk[i] == 0 )
{
malign = mk[4];
malign = mk[i];
break;
}
......@@ -21,13 +25,19 @@ int main(void)
{
int nelem = 97;
double *array = (double *) malloc(nelem*sizeof(double));
double *array1 = (double *) malloc(nelem*sizeof(double));
double *array2 = (double *) malloc(nelem*sizeof(double));
printf("mem alignment: %d %d\n", get_alignment(array1), get_alignment(array2));
for ( int i = 0; i < nelem; ++i ) array1[i] = 0;
for ( int i = 0; i < nelem; ++i ) array2[i] = 1;
int64_t iptr = (int64_t) array;
int malign = get_alignment(array);
printf("mem alignment: %d\n", malign);
for ( int i = 0; i < 200000000; ++i )
fun1(nelem, array1, array2);
free(array);
free(array1);
free(array2);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment