anndata: Replaced with new Python version.
[utils.git] / loadcpu.c
CommitLineData
a0d86d96
FT
1#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4#include <errno.h>
5#include <pthread.h>
6
06282b33
FT
7static void *spin_snb(void *uu)
8{
9 char __attribute__((aligned(32))) m[2][32];
10
11 asm("vpxor %%xmm1, %%xmm1, %%xmm1;\n"
12 "vpxor %%xmm2, %%xmm2, %%xmm2;\n"
13 "0:\n"
14 "vmovaps (%0), %%ymm0;\n"
15 "vmovaps %%ymm1, (%1);\n"
16 "vaddps %%ymm1, %%ymm1, %%ymm2\n"
17 "vmulps %%ymm3, %%ymm3, %%ymm4\n"
18 "vmovaps (%0), %%ymm0;\n"
19 "vmovaps %%xmm1, (%1);\n"
20 "vaddps %%ymm1, %%ymm1, %%ymm2\n"
21 "vmulps %%ymm3, %%ymm3, %%ymm4\n"
22 "vmovaps (%0), %%ymm0;\n"
23 "vaddps %%ymm1, %%ymm1, %%ymm2\n"
24 "vmulps %%ymm3, %%ymm3, %%ymm4\n"
25 "jmp 0b;\n"
26 :
27 : "r" (&m[0]), "r" (&m[1])
28 : "rax", "rcx");
29 abort();
30}
31
a0d86d96
FT
32static void *spin(void *uu)
33{
34 while(1) {
35 }
36}
37
38int main(int argc, char **argv)
39{
40 int i, n;
41
42 n = 4;
43 pthread_t threads[n];
44 for(i = 0; i < n; i++) {
45 if(pthread_create(&threads[i], NULL, spin, NULL)) {
46 fprintf(stderr, "loadcpu: pthread_create: %s\n", strerror(errno));
47 exit(1);
48 }
49 }
50 pthread_join(threads[0], NULL);
51 return(0);
52}
53
54/*
55 * Local Variables:
56 * compile-command: "gcc -g -Wall -o loadcpu loadcpu.c -lpthread"
57 * End:
58 */