X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=blobdiff_plain;f=parallel.h;h=a8a748fdce036e0ac5ce5cb3bdbe315512e75357;hp=3d5082285824cf07bd0ab560fe032d0d0567b616;hb=40661bde068ca5b4ebbf3c9e74efcbcdfef2584a;hpb=21a2bd20afe0f4673494f4841a5675ca68cbd2d7 diff --git a/parallel.h b/parallel.h index 3d50822..a8a748f 100644 --- a/parallel.h +++ b/parallel.h @@ -21,6 +21,18 @@ (v) < OUTER_PERSECTION_BASE((zero),(n), section + 1) && (v) < (n); \ (v)++) +/* + * OUTER is a loop constructor like INNER (see mgraph.h). + * + * Constraints on its use: + * - must be in exactly one loop of particular function + * - function must not modify anything other than + * its return value (for cost computation functions, COST()) or + * its designated output (for precomputation functions, PRECOMP()) + * and in the latter case it may not read other parts of its output + * - function must of course be reentrant + */ + #define nsections NSECTIONS typedef void Computation(const struct Vertices *vertices, @@ -30,5 +42,16 @@ void inparallel(const struct Vertices *vertices, Computation *separately, Computation *combine, size_t secdatasz, void *gendata); + /* nsections copies of the computation `separately' are run in parallel + * with different values of `section' from 0 to nsections-1. + * Each copy is passed the same gendata as passed to inparallel. + * Each copy gets its own data block (struct aligned) of size + * secdatasz, passed as secdata, uninitialised on entry. + * After all the copies have finished, `combine' is invoked + * nsections times sequentially, with the same sets of arguments. + * inparallel is NOT itself reentrant. + */ + +void inparallel_barrier(void); #endif /*PARALLEL_H*/