Common Lisp Package: LPARALLEL.COGNATE

Parallelized versions of some Common Lisp functions.

README:

FUNCTION

Public

PCOUNT (ITEM SEQUENCE &KEY FROM-END (START 0) END KEY TEST TEST-NOT PARTS)

Parallel version of `count'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PCOUNT-IF (PREDICATE SEQUENCE &KEY FROM-END (START 0) END KEY PARTS)

Parallel version of `count-if'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PCOUNT-IF-NOT (PREDICATE SEQUENCE &REST ARGS &KEY FROM-END START END KEY PARTS)

Parallel version of `count-if-not'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PEVERY (PREDICATE &REST SEQUENCES)

Parallel version of `every'. Calls to `predicate' are done in parallel, though not necessarily at the same time. Behavior is otherwise indistinguishable from `every'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PFIND (ITEM SEQUENCE &REST ARGS &KEY FROM-END TEST TEST-NOT START END KEY PARTS)

Parallel version of `pfind'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PFIND-IF (PREDICATE SEQUENCE &REST ARGS &KEY FROM-END START END KEY PARTS)

Parallel version of `pfind-if'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PFIND-IF-NOT (PREDICATE SEQUENCE &REST ARGS &KEY FROM-END START END KEY PARTS)

Parallel version of `pfind-if-not'. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PMAP (RESULT-TYPE FUNCTION &REST SEQUENCES)

Parallel version of `map'. Keyword arguments `parts' and `size' are also accepted. The `parts' option divides each sequence into `parts' number of parts. Default is (kernel-worker-count). The `size' option limits the number of elements mapped to `size'. When given, no `length' calls are made on the sequence(s) passed. Warning: `size' must be less than or equal to the length of the smallest sequence passed. It is unspecified what happens when that condition is not met.

PMAP-INTO (RESULT-SEQUENCE FUNCTION &REST SEQUENCES)

Parallel version of `map-into'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAP-REDUCE (MAP-FUNCTION REDUCE-FUNCTION SEQUENCE &REST ARGS &KEY START END INITIAL-VALUE PARTS RECURSE)

Equivalent to (preduce reduce-function sequence :key map-function ...).

PMAPC (FUNCTION &REST LISTS)

Parallel version of `mapc'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAPCAN (FUNCTION &REST LISTS)

Parallel version of `mapcan'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAPCAR (FUNCTION &REST SEQUENCES)

Parallel version of `mapcar'. Keyword arguments `parts' and `size' are also accepted (see `pmap'). Unlike `mapcar', `pmapcar' also accepts vectors.

PMAPCON (FUNCTION &REST LISTS)

Parallel version of `mapcon'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAPL (FUNCTION &REST LISTS)

Parallel version of `mapl'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAPLIST (FUNCTION &REST LISTS)

Parallel version of `maplist'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PMAPLIST-INTO (RESULT-LIST FUNCTION &REST LISTS)

Like `pmaplist' but results are stored in `result-list'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PNOTANY (PREDICATE &REST SEQUENCES)

Parallel version of `notany'. Calls to `predicate' are done in parallel, though not necessarily at the same time. Behavior is otherwise indistinguishable from `notany'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PNOTEVERY (PREDICATE &REST SEQUENCES)

Parallel version of `notevery'. Calls to `predicate' are done in parallel, though not necessarily at the same time. Behavior is otherwise indistinguishable from `notevery'. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PREDUCE (FUNCTION SEQUENCE &REST ARGS &KEY KEY FROM-END (START 0) END INITIAL-VALUE PARTS RECURSE)

Parallel version of `reduce'. `preduce' subdivides the input sequence into `parts' number of parts and, in parallel, calls `reduce' on each part. The partial results are then reduced again, either by `reduce' (the default) or, if `recurse' is non-nil, by `preduce'. `parts' defaults to (kernel-worker-count). `key' is thrown out while reducing the partial results. It applies to the first pass only. `start' and `end' have the same meaning as in `reduce'. `from-end' means "from the end of each part". `initial-value' means "initial value of each part".

PREDUCE-PARTIAL (FUNCTION SEQUENCE &REST ARGS &KEY KEY FROM-END (START 0) END INITIAL-VALUE PARTS)

Like `preduce' but only does a single reducing pass. The length of `sequence' must not be zero. Returns the partial results as a vector.

PREMOVE (ITEM SEQUENCE &REST ARGS &KEY TEST TEST-NOT FROM-END (START 0) END KEY PARTS)

Parallel version of `remove'. Note the `count' option is not supported. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PREMOVE-IF (TEST SEQUENCE &REST ARGS &KEY FROM-END (START 0) END KEY PARTS)

Parallel version of `remove-if'. Note the `count' option is not supported. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PREMOVE-IF-NOT (TEST SEQUENCE &REST ARGS &KEY FROM-END (START 0) END KEY PARTS)

Parallel version of `remove-if-not'. Note the `count' option is not supported. The `parts' option divides `sequence' into `parts' number of parts. Default is (kernel-worker-count).

PSOME (PREDICATE &REST SEQUENCES)

Parallel version of `some'. Calls to `predicate' are done in parallel, though not necessarily at the same time. Behavior is otherwise indistinguishable from `some' except that any non-nil predicate comparison result may be returned. Keyword arguments `parts' and `size' are also accepted (see `pmap').

PSORT (SEQUENCE PREDICATE &KEY KEY GRANULARITY &ALLOW-OTHER-KEYS)

Parallel version of `sort'. If `granularity' is provided then parallel tasks are created only for segments larger than `granularity'. This may or may not result in better performance. At present `psort' is only parallelized for vectors; other types are given to `cl:sort'.

PSORT* (SEQUENCE PREDICATE &KEY KEY GRANULARITY &ALLOW-OTHER-KEYS)

Like `psort' but optimized for N-1 worker threads where N is the number of cores. The caller of `psort*' always participates in the computation. In contrast, the caller of `psort' participates only when the caller is in a worker thread.

Private

MAKE-INPUT-PARTS (SEQUENCES SIZE PARTS-HINT)

Subdivide and interleave sequences for parallel mapping.

MAKE-RESULT-PARTS (RESULT SIZE PARTS-HINT)

Subdivide the result sequence. For a list, delineate boundaries by slicing.

MAP-ITERATE (MAP SIZE FN SEQS)

A variation of (map nil ...)/mapc/mapl with size constrained. Without a result to delineate sublist boundaries, we must enforce them manually.

MAPLIST-INTO (RESULT-LIST FN &REST LISTS)

A variation of map-into.

PMAP-INTO/POWDER/ARRAY (RESULT-SEQ FN SEQS SIZE)

When a sequence of size N is divided into N parts, it becomes powder.

Undocumented

%%.DEFPUN.QUICKSORT/KEY/GRAN

%%.DEFPUN.QUICKSORT/KEY/GRAN*

%%.DEFPUN.QUICKSORT/KEY/NO-GRAN

%%.DEFPUN.QUICKSORT/KEY/NO-GRAN*

%%.DEFPUN.QUICKSORT/NO-KEY/GRAN

%%.DEFPUN.QUICKSORT/NO-KEY/GRAN*

%%.DEFPUN.QUICKSORT/NO-KEY/NO-GRAN

%%.DEFPUN.QUICKSORT/NO-KEY/NO-GRAN*

%PDOTIMES (SIZE PARTS FN)

%PREDUCE-PARTIAL (FUNCTION SEQUENCE START SIZE PARTS &REST KEYWORD-ARGS)

CALL-QUICKSORT (VEC LO HI COMPARE GRANULARITY KEY)

CALL-QUICKSORT* (VEC LO HI COMPARE GRANULARITY KEY)

FIND-MIN-LENGTH (SEQS)

FIND-NUM-PARTS (SIZE PARTS-HINT)

GET-PARTS-HINT (PARTS-HINT)

ITEM-PREDICATE (ITEM TEST TEST-NOT)

MAKE-PARTS (RESULT SIZE PARTS-HINT &KEY SLICEP)

MAP-NIL (&REST ARGS)

MIDPOINT (A B)

PFIND-IF/LIST (PREDICATE SEQUENCE &KEY FROM-END (START 0) END KEY PARTS)

PFIND-IF/VECTOR (PREDICATE SEQUENCE &KEY FROM-END (START 0) END KEY PARTS)

PMAP-INTO/PARSED (MAP-INTO RESULT-SEQ FN SEQS SIZE PARTS-HINT)

PMAP-INTO/PARTS (MAP-INTO RESULT-SEQ FN SEQS SIZE PARTS-HINT)

PMAP-INTO/POWDER (MAP-INTO RESULT-SEQ FN SEQS SIZE)

PMAP-INTO/POWDER/LIST (MAP RESULT-SEQ FN SEQS SIZE)

PMAP-INTO/UNPARSED (MAP-INTO RESULT-SEQ FN SEQS)

PMAP-ITERATE (MAP FN SEQS SIZE PARTS-HINT)

PMAP-ITERATE/PARTS (MAP FN SEQS SIZE PARTS-HINT)

PMAP-ITERATE/POWDER (MAP FN SEQS SIZE)

PMAP/PARSED (RESULT-TYPE FUNCTION SEQUENCES SIZE PARTS-HINT)

PMAP/UNPARSED (RESULT-TYPE FUNCTION SEQUENCES)

PQUALIFIER (QUALIFIER PREDICATE SEQUENCES BAIL)

PREDUCE-PARTIAL/LIST (FUNCTION SEQUENCE START SIZE PARTS &REST KEYWORD-ARGS)

PREDUCE-PARTIAL/VECTOR (FUNCTION SEQUENCE START SIZE PARTS &REST KEYWORD-ARGS)

PREDUCE/COMMON (FUNCTION SEQUENCE SUBSIZE &KEY KEY FROM-END (START 0) END (INITIAL-VALUE NIL INITIAL-VALUE-GIVEN-P) PARTS RECURSE PARTIAL)

PREMOVE-IF-NOT/LIST (TEST LIST FROM-END START END KEY PARTS)

QUICKSORT/KEY/GRAN (VEC LO HI COMPARE GRAN22 KEY21)

QUICKSORT/KEY/GRAN* (VEC LO HI COMPARE GRAN22 KEY21)

QUICKSORT/KEY/NO-GRAN (VEC LO HI COMPARE KEY21)

QUICKSORT/KEY/NO-GRAN* (VEC LO HI COMPARE KEY21)

QUICKSORT/NO-KEY/GRAN (VEC LO HI COMPARE GRAN22)

QUICKSORT/NO-KEY/GRAN* (VEC LO HI COMPARE GRAN22)

QUICKSORT/NO-KEY/NO-GRAN (VEC LO HI COMPARE)

QUICKSORT/NO-KEY/NO-GRAN* (VEC LO HI COMPARE)

QUOTED-VECTOR-TYPE-P (FORM)

QUOTEDP (FORM)

REMOVE-PROP (TARGET-KEY PLIST)

REMOVE-PROPS (KEYS PLIST)

SUBDIVIDE-ARRAY (ARRAY SIZE PARTS-HINT)

SUBDIVIDE-LIST (LIST SIZE PARTS-HINT)

SUBDIVIDE-LIST/SLICE (LIST SIZE PARTS-HINT)

SUBSIZE (SEQ SIZE START END)

ZIP/VECTOR (SEQS)

MACRO

Public

PAND (&REST FORMS)

Parallel version of `and'. Forms in `forms' may be executed in parallel, though not necessarily at the same time. If all forms evaluate to true, then the result of any form may be returned.

PDOTIMES ((VAR COUNT &OPTIONAL RESULT PARTS) &BODY BODY)

Parallel version of `dotimes'. The `parts' option divides the integer range into `parts' number of parts. Default is (kernel-worker-count). Unlike `dotimes', `pdotimes' does not define an implicit block named nil.

PFUNCALL (FUNCTION &REST ARGS)

Parallel version of `funcall'. Arguments in `args' may be executed in parallel, though not necessarily at the same time.

PLET (BINDINGS &BODY BODY)

The syntax of `plet' matches that of `let'. plet ({var-no-init | (var [init-form])}*) form* For each (var init-form) pair, a future is created which executes `init-form'. Inside `body', `var' is a symbol macro which expands to a `force' form for the corresponding future. Each `var-no-init' is bound to nil and each `var' without `init-form' is bound to nil (no future is created). `plet' is subject to optimization inside `defpun'.

PLET-IF (PREDICATE BINDINGS &BODY BODY)

The syntax of `plet-if' matches that of `let' except for the addition of the `predicate' form. If `predicate' evaluates to true, the behavior is the same as `plet'. If `predicate' evaluates to false, the behavior is the same as `let'. `plet-if' is subject to optimization inside `defpun'.

POR (&REST FORMS)

Parallel version of `or'. Forms in `forms' may be executed in parallel, though not necessarily at the same time. Any form which evaluates to non-nil may be returned.

Private

DEFMACRO/SYMS (NAME PARAMS &BODY BODY)

Like `defmacro' but requires all parameters to be symbols.

TOPLEVEL-PLET (BINDINGS &BODY BODY)

The syntax of `plet' matches that of `let'. plet ({var-no-init | (var [init-form])}*) form* For each (var init-form) pair, a future is created which executes `init-form'. Inside `body', `var' is a symbol macro which expands to a `force' form for the corresponding future. Each `var-no-init' is bound to nil and each `var' without `init-form' is bound to nil (no future is created). `plet' is subject to optimization inside `defpun'.

Undocumented

CHECK-SYMBOLS (&REST SYMS)

DEFINE-CALL-QUICKSORT (NAME QUICKSORT/KEY/GRAN QUICKSORT/KEY/NO-GRAN QUICKSORT/NO-KEY/GRAN QUICKSORT/NO-KEY/NO-GRAN)

DEFINE-PSORT (NAME CALL-QUICKSORT)

DEFINE-QUICKSORT-FN (NAME DEF CALL-KEY KEY KEY-TYPE GRAN GRAN-TYPE)

DEFINE-QUICKSORT-FNS

FUTURE-LET (&KEY KERNEL FUTURE FORCE BINDINGS PRE-BODY BODY)

MAP-INTO/VECTOR/1-VECTOR/RANGE (DST FN SRC START END)

PMAP-INTO/VECTOR/1-VECTOR (DST FN SRC SIZE PARTS)

POP-KEYWORD-ARGS (LIST &REST KEYS)

POP-OPTIONS (LIST)

POP-PLIST (LIST)

WITH-FORMS-SUBMITTED (FORMS &BODY BODY)

WITH-PARSED-OPTIONS ((SEQS SIZE PARTS-HINT) &BODY BODY)

WITH-PARTS (SEQ-SIZE PARTS-HINT &BODY BODY)

WITH-PFIND-CONTEXT (SEQUENCE START END PARTS &BODY BODY)

WITH-PREDUCE-CONTEXT (SIZE PARTS &BODY BODY)