chiark / gitweb /
add .nprocessors.make to bzrignore
[moebius2.git] / parallel.h
1 /*
2  * Parallel processing
3  */
4
5 #ifndef PARALLEL_H
6 #define PARALLEL_H
7
8 #ifdef NPROCESSORS
9 # define NSECTIONS NPROCESSORS
10 #else
11 # define NSECTIONS 1
12 #endif
13
14 /* used anamorphically: section, nsections */
15
16 #define OUTER_PERSECTION_BASE(zero,n, sect) \
17   ((zero) + sect * (((n)-(zero) + NSECTIONS-1) / NSECTIONS))
18 #define OUTER(v,zero,n, precomp)                                          \
19   for ((v)= OUTER_PERSECTION_BASE((zero),(n), section);                   \
20        precomp,                                                           \
21        (v) < OUTER_PERSECTION_BASE((zero),(n), section + 1) && (v) < (n); \
22        (v)++)
23
24 #define nsections NSECTIONS
25
26 typedef void Computation(const struct Vertices *vertices,
27                          int section, void *secdata, void *gendata);
28
29 void inparallel(const struct Vertices *vertices,
30                 Computation *separately,
31                 Computation *combine,
32                 size_t secdatasz, void *gendata);
33
34 #endif /*PARALLEL_H*/