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

added memalign.c

parent 74af70da
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/memalign.c -text
test/testStreams.py -text
test/test_Arith.py -text
test/test_Arithc.py -text
......
#include <stdio.h>
#include <stdlib.h>
int get_alignment(double *ptr)
{
int64_t iptr = (int64_t) ptr;
int mk[4] = {64, 32, 16, 8};
int malign = 0;
for ( int i = 0; i < 4; ++i )
if ( iptr%mk[i] == 0 )
{
malign = mk[4];
break;
}
return malign;
}
int main(void)
{
int nelem = 97;
double *array = (double *) malloc(nelem*sizeof(double));
int64_t iptr = (int64_t) array;
int malign = get_alignment(array);
printf("mem alignment: %d\n", malign);
free(array);
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