First draft of performance test SQL schema.
[beedb.git] / exp / raw_mem_bw.c
blob9d3cd7919f0d5cec3da27958c462eaf059ffa331
1 /*
2 Copyright 2008 Kristian Nielsen
4 This file is part of BeeDB.
6 Foobar is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
11 Foobar is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <stdio.h>
24 typedef int v4si __attribute__ ((vector_size (16)));
25 typedef float v4sf __attribute__ ((vector_size (16)));
27 #if 0
28 void
29 load_loop(float *p, uint64_t count)
31 if (0xf & (unsigned long)p)
33 fprintf(stderr, "load_loop: error: unaligned source\n");
34 exit(1);
36 while (count > 0)
38 v4sf x0= __builtin_ia32_loadaps(p);
39 v4sf x1= __builtin_ia32_loadaps(p+4);
40 v4sf x2= __builtin_ia32_loadaps(p+8);
41 v4sf x3= __builtin_ia32_loadaps(p+12);
44 #endif
46 void
47 foo(int *p)
49 v4si x= *(v4si *)p;
50 v4si y= *(v4si *)(p+4);
51 *(v4si *)(p+4)= x;
52 *(v4si *)(p)= y;
55 void
56 load_loop(v4si *p, uint64_t count)
58 if (0xf & (unsigned long)p)
60 fprintf(stderr, "load_loop: error: unaligned source\n");
61 exit(1);
63 v4si x;
64 while (count-- > 0)
66 x+= p[0];
67 x+= p[1];
68 x+= p[2];
69 x+= p[3];
70 p+= 4;
72 *p= x;
75 int
76 main(int argc, char *argv)
78 uint64_t count= 1024*1024*16;
79 uint64_t loops= 10;
80 v4si *p= malloc((count+1)*64);
81 while (loops--)
83 load_loop(p, count);
85 printf("%d\n", *(char *)(p+count));