1 // SPDX-License-Identifier: GPL-2.0
2 // Carsten Haitzler <carsten.haitzler@arm.com>, 2021
15 static void *thrfn(void *arg)
18 unsigned int i, in = a->in;
20 for (i = 0; i < 10000; i++) {
22 // force an unroll of thia add instruction so we can test long runs of code
23 #define SNIP1 "add %[in], %[in], #1\n"
25 #define SNIP2 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1
27 #define SNIP3 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2 SNIP2
29 #define SNIP4 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3 SNIP3
31 #define SNIP5 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4 SNIP4
33 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5 SNIP5
35 : /* in */ [in] "r" (in)
41 static pthread_t new_thr(void *(*fn) (void *arg), void *arg)
46 pthread_attr_init(&attr);
47 pthread_create(&t, &attr, fn, arg);
51 int main(int argc, char **argv)
54 pthread_t threads[256];
55 struct args args[256];
58 printf("ERR: %s [numthreads]\n", argv[0]);
63 if ((thr > 256) || (thr < 1)) {
64 printf("ERR: threads 1-256\n");
67 for (i = 0; i < thr; i++) {
69 args[i].th = new_thr(thrfn, &(args[i]));
71 for (i = 0; i < thr; i++)
72 pthread_join(args[i].th, &(args[i].ret));