lparallel

API Reference

lparallel

Parallelism for Common Lisp

LPARALLEL.UTIL

(private) Miscellaneous utilities.
  • Variable *NORMAL-OPTIMIZE*
    '(optimize (speed 3) (safety 1) (debug 1) (compilation-speed 0))
  • Variable *FULL-OPTIMIZE*
    '(optimize (speed 3) (safety 0) (debug 0) (compilation-speed 0))
  • Macro ALIAS-FUNCTION (alias orig)
  • Macro ALIAS-MACRO (alias orig)
  • Function UNSPLICE (form)
  • Macro WITH-PARSED-BODY ((body declares &optional docstring) &body own-body)
    Pop docstring and declarations off `body' and assign them to the variables `docstring' and `declares' respectively. If `docstring' is not present then no docstring is parsed.
  • Function TO-BOOLEAN (x)
  • Function INTERACT (&rest prompt)
    Read from user and eval.
  • Macro REPEAT (n &body body)
  • Macro DOSEQUENCE ((var sequence &optional return) &body body)
  • Macro UNWIND-PROTECT/EXT (&key prepare main cleanup abort)
    Extended `unwind-protect'. `prepare' : executed first, outside of `unwind-protect' `main' : protected form `cleanup' : cleanup form `abort' : executed if `main' does not finish
  • Type INDEX
  • Macro DEFMACRO/ONCE (name params &body body)
    Like `defmacro' except that params which are immediately preceded by `&once' are passed to a `once-only' call which surrounds `body'.
  • Macro DEFUN/INLINE (name lambda-list &body body)
    Shortcut for (declaim (inline foo)) (defun foo ...).
  • Macro DEFUN/TYPE (name lambda-list arg-types return-type &body body)
    Shortcut for (declaim (ftype (function arg-types return-type) foo) (defun foo ...). Additionally constrains return-type to the number of values provided.
  • Macro DEFUN/TYPE/INLINE (name lambda-list arg-types return-type &body body)
  • Macro DEFSLOTS (name supers slots &rest options)
    Define a thing with slots. A `defslots' form may expand to either a `defclass' form or a `defstruct' form. Thou art foolish to depend upon either. The syntax of `defslots' matches that of `defclass' with the following restrictions: at most one superclass is permitted; `:initform', `:type', and `:reader', are the only slot options allowed; `:documentation' is the only class option allowed. `(defslots foo ...)' defines the functions `make-foo-instance' and `with-foo-slots' which are like `make-instance' and `with-slots' respectively. `make-foo-instance' takes keyword arguments corresponding to slots of the same name. All slots must be initialized when an instance is created, else an error will be signaled.
  • Macro DEFPAIR (name supers (a b) &optional doc)
    Define a cons type using defclass syntax. Exactly two slots and zero superclasses must be given. Available slot options are: `:initform', `:type', `:reader'. A deftype for `name' is defined. `(defpair foo ...)' defines the function `make-foo-instance' which takes keyword arguments corresponding to slots of the same name. All slots must be initialized when an instance is created, else an error will be signaled.

Also exports

  • ALEXANDRIA.0.DEV:SYMBOLICATE
  • ALEXANDRIA.0.DEV:WITH-GENSYMS
  • ALEXANDRIA.0.DEV:WHEN-LET
  • ALEXANDRIA.0.DEV:ENSURE-FUNCTION

LPARALLEL.THREAD-UTIL

(private) Thread utilities.
  • Macro CAS (place old new &environment env)
  • Function MAKE-SPIN-LOCK
  • Macro WITH-SPIN-LOCK-HELD (((access container)) &body body)
  • Macro WITH-THREAD ((&key bindings name) &body body)
  • Macro WITH-LOCK-PREDICATE/NO-WAIT (lock predicate &body body)
  • Macro WITH-LOCK-PREDICATE/WAIT (lock predicate &body body)

Also exports

  • BORDEAUX-THREADS:CURRENT-THREAD
  • BORDEAUX-THREADS:MAKE-LOCK
  • BORDEAUX-THREADS:WITH-LOCK-HELD
  • BORDEAUX-THREADS:MAKE-CONDITION-VARIABLE
  • BORDEAUX-THREADS:DESTROY-THREAD

LPARALLEL.RAW-QUEUE

(private) Raw queue data structure.
  • Type RAW-QUEUE-COUNT
  • Struct RAW-QUEUE
    HEAD
    TAIL
  • Function MAKE-RAW-QUEUE (&optional initial-capacity)
  • Function PUSH-RAW-QUEUE (value queue)
  • Function POP-RAW-QUEUE (queue)
  • Function RAW-QUEUE-COUNT (queue)
  • Function RAW-QUEUE-EMPTY-P (queue)
  • Function PEEK-RAW-QUEUE (queue)

LPARALLEL.CONS-QUEUE

(private) Blocking infinite-capacity queue.
  • Struct CONS-QUEUE
    IMPL
    LOCK
    CVAR
  • Macro WITH-LOCKED-CONS-QUEUE (queue &body body)
  • Function PUSH-CONS-QUEUE/NO-LOCK (object queue)
  • Function PUSH-CONS-QUEUE (object queue)
  • Function POP-CONS-QUEUE/NO-LOCK (queue)
  • Function POP-CONS-QUEUE (queue)
  • Function TRY-POP-CONS-QUEUE (queue timeout)
  • Function TRY-POP-CONS-QUEUE/NO-LOCK (queue timeout)
  • Function CONS-QUEUE-COUNT/NO-LOCK (queue)
  • Function CONS-QUEUE-COUNT (queue)
  • Function CONS-QUEUE-EMPTY-P/NO-LOCK (queue)
  • Function CONS-QUEUE-EMPTY-P (queue)
  • Function PEEK-CONS-QUEUE/NO-LOCK (queue)
  • Function PEEK-CONS-QUEUE (queue)
  • Function MAKE-CONS-QUEUE (&key initial-contents)

LPARALLEL.VECTOR-QUEUE

(private) Blocking fixed-capacity queue.
  • Struct VECTOR-QUEUE
    IMPL
    LOCK
    NOTIFY-PUSH
    NOTIFY-POP
  • Macro WITH-LOCKED-VECTOR-QUEUE (queue &body body)
  • Function PUSH-VECTOR-QUEUE/NO-LOCK (object queue)
  • Function PUSH-VECTOR-QUEUE (object queue)
  • Function POP-VECTOR-QUEUE/NO-LOCK (queue)
  • Function POP-VECTOR-QUEUE (queue)
  • Function TRY-POP-VECTOR-QUEUE (queue timeout)
  • Function TRY-POP-VECTOR-QUEUE/NO-LOCK (queue timeout)
  • Function VECTOR-QUEUE-COUNT/NO-LOCK (queue)
  • Function VECTOR-QUEUE-COUNT (queue)
  • Function VECTOR-QUEUE-CAPACITY (queue)
  • Function VECTOR-QUEUE-EMPTY-P/NO-LOCK (queue)
  • Function VECTOR-QUEUE-EMPTY-P (queue)
  • Function VECTOR-QUEUE-FULL-P/NO-LOCK (queue)
  • Function VECTOR-QUEUE-FULL-P (queue)
  • Function PEEK-VECTOR-QUEUE/NO-LOCK (queue)
  • Function PEEK-VECTOR-QUEUE (queue)
  • Function MAKE-VECTOR-QUEUE (capacity &key initial-contents)

LPARALLEL.QUEUE

Blocking FIFO queue for communication between threads.
  • Type QUEUE
  • Function MAKE-QUEUE (&rest args)
  • Macro WITH-LOCKED-QUEUE (queue &body body)
  • Function PUSH-QUEUE (object queue)
  • Function PUSH-QUEUE/NO-LOCK (object queue)
  • Function POP-QUEUE (queue)
  • Function POP-QUEUE/NO-LOCK (queue)
  • Function PEEK-QUEUE (queue)
  • Function PEEK-QUEUE/NO-LOCK (queue)
  • Function QUEUE-COUNT (queue)
  • Function QUEUE-COUNT/NO-LOCK (queue)
  • Function QUEUE-EMPTY-P (queue)
  • Function QUEUE-EMPTY-P/NO-LOCK (queue)
  • Function QUEUE-FULL-P (queue)
  • Function QUEUE-FULL-P/NO-LOCK (queue)
  • Function TRY-POP-QUEUE (queue &key timeout)
  • Function TRY-POP-QUEUE/NO-LOCK (queue &key timeout)

LPARALLEL.COUNTER

(private) Atomic counter.
  • Type COUNTER-VALUE
  • Struct COUNTER
    VALUE
  • Function COUNTER-VALUE (instance)
  • Function (setf COUNTER-VALUE) (value instance)
  • Function MAKE-COUNTER (&optional (value 0))
  • Function INC-COUNTER (counter)
  • Function DEC-COUNTER (counter)

LPARALLEL.SPIN-QUEUE

(private) Thread-safe FIFO queue which spins instead of locks.
  • Struct SPIN-QUEUE
    HEAD
    TAIL
  • Function MAKE-SPIN-QUEUE
  • Function PUSH-SPIN-QUEUE (value queue)
  • Function POP-SPIN-QUEUE (queue)
  • Function SPIN-QUEUE-EMPTY-P (queue)
  • Function SPIN-QUEUE-COUNT (queue)
  • Function PEEK-SPIN-QUEUE (queue)

LPARALLEL.KERNEL

Encompasses the scheduling and execution of parallel tasks using a
   pool of worker threads. All parallelism in lparallel is done on top
   of the kernel.
  • Variable *TASK-CATEGORY*
    :default
    See `kill-tasks'. Default value is `:default'.
  • Variable *TASK-PRIORITY*
    :default
    When bound to `:low', the kernel schedules submitted tasks at low priority. Default value is `:default'.
  • Variable *KERNEL*
    nil
    The current kernel, or nil.
  • Variable *KERNEL-SPIN-COUNT*
    2000
    Default value of the `spin-count' argument to `make-kernel'.
  • Variable *DEBUG-TASKS-P*
    t
    If true (the default), the debugger is invoked when an error goes unhandled inside a task, i.e. when the handlers established by `task-handler-bind' (if any) do not handle it. If false, unhandled errors from tasks are automatically transferred to their parent thread (and/or any dependent threads) via the `transfer-error' restart. This is for convenience -- sometimes you wish to avoid N debugger popups arising from N errors in N worker threads. For local control over debugger invocation, bind a task handler: (task-handler-bind ((error #'invoke-debugger)) ...) (task-handler-bind ((error #'invoke-transfer-error)) ...)
  • Macro TASK-HANDLER-BIND (clauses &body body)
    Like `handler-bind' but handles conditions signaled inside tasks that were created in `body'.
  • Function INVOKE-TRANSFER-ERROR (error)
    Equivalent to (invoke-restart 'transfer-error error). This is a convenience function for use in `task-handler-bind'.
  • Condition TASK-KILLED-ERROR  (ERROR)
    Error signaled when attempting to obtain the result of a killed task.
  • Condition NO-KERNEL-ERROR  (ERROR)
    Error signaled when `*kernel*' is nil.
  • Condition KERNEL-CREATION-ERROR  (ERROR)
    Error signaled when `make-kernel' fails.
  • Struct KERNEL
    The kernel encompasses the scheduling and execution of parallel tasks using a pool of worker threads. All parallelism in lparallel is done on top of the kernel.
    SCHEDULER
    WORKERS
    WORKERS-LOCK
    WORKER-INFO
    USE-CALLER-P
    ALIVEP
  • Struct CHANNEL
    A task is submitted to the kernel using a channel. A channel always points to the same kernel, which is the value of `*kernel*' when the channel is created.
    QUEUE
    KERNEL
  • Function KILL-TASKS (task-category &key dry-run)
    This is an expensive function which should only be used in exceptional circumstances. Every task has an associated task category. When a task is submitted, it is assigned the category of `*task-category*' which has a default value of `:default'. `kill-tasks' interrupts running tasks whose category is `eql' to `task-category'. The corresponding worker threads are killed and replaced. Pending tasks are not affected. If you don't know what to pass for `task-category' then you should probably pass `:default', though this may kill more tasks than you wish. Binding `*task-category*' around `submit-task' enables targeted task killing. If `dry-run' is nil, the function returns the number of tasks killed. If `dry-run' is non-nil then no tasks are killed. In this case the return value is the number of tasks that would have been killed if `dry-run' were nil. `kill-tasks' is not available in ABCL.
  • Function MAKE-KERNEL (worker-count &key (name "lparallel") (bindings `((*standard-output* . ,*standard-output*) (*error-output* . ,*error-output*))) (context #'funcall) (spin-count *kernel-spin-count*) (use-caller nil))
    Create a kernel with `worker-count' number of worker threads. `name' is a string identifier for this kernel which is reported by `print-object'. Worker threads will also be given this name, shown in `bordeaux-threads:all-threads'. `bindings' is an alist for establishing thread-local variables inside worker threads. By default workers will have *standard-output* and *error-output* bindings. Dynamic context for each worker may be established with the function `context'. The argument passed to `context' is a function which must be funcalled. It begins the worker loop and will not return until the worker exits. The default value of `context' is #'funcall. The special variables in `bindings' are available inside the `context' function. When a worker discovers that no tasks are available, `spin-count' is the number of task-searching iterations done by the worker before sleeping. If `use-caller' is true (default is false) then in certain situations the calling thread may be enlisted to steal work from worker threads. This is an optimization strategy that currently applies only during the execution of functions defined by `defpun' and `defpun/type'. Typically in this case the number of workers will be one less than the number of cores/CPUs. A kernel will not be garbage collected until `end-kernel' is called.
  • Function CHECK-KERNEL
    Ensures the value of `*kernel*' is a kernel instance. Provides the MAKE-KERNEL and STORE-VALUE restarts. Returns `*kernel*'.
  • Function KERNEL-BINDINGS
    Return the bindings passed to `make-kernel'.
  • Function KERNEL-NAME
    Return the name passed to `make-kernel'.
  • Function KERNEL-CONTEXT
    Return the context passed to `make-kernel'.
  • Function KERNEL-WORKER-COUNT
    Return the number of workers in the current kernel.
  • Function KERNEL-WORKER-INDEX
    If called from inside a worker, return the worker's assigned index, ranging from 0 to one less than (kernel-worker-count). If not called from inside a worker, return nil.
  • Function MAKE-CHANNEL (&rest args)
    Create a channel for submitting and receiving tasks. The current value of `*kernel*' is stored for use in `submit-task'. By default there is no limit on the channel capacity. Passing a `fixed-capacity' keyword argument limits the capacity to the value passed. Note that a fixed capacity channel may cause a deadlocked kernel if `receive-result' is not called a sufficient number of times.
  • Function SUBMIT-TASK (channel function &rest args)
    Submit a task through `channel' to the kernel stored in `channel'.
  • Function RECEIVE-RESULT (channel)
    Remove a result from `channel'. If nothing is available the call will block until a result is received.
  • Function TRY-RECEIVE-RESULT (channel &key timeout)
    If `channel' has a result then remove it and return (values result t). If no result is available and `timeout' is given, then wait up to `timeout' seconds for a result. If the channel is empty and the timeout has expired, or if the channel is empty and no timeout was given, return (values nil nil). Providing a nil or non-positive value of `timeout' is equivalent to providing no timeout.
  • Macro DO-FAST-RECEIVES ((result channel count) &body body)
    Receive `count' number of results from `channel', executing `body' each time with the result bound to `result'. `body' should be a trivial operation such as an aref call.
  • Function END-KERNEL (&key wait)
    Sets `*kernel*' to nil and ends all workers gracefully. `end-kernel' should not be used as a substitute for properly waiting on tasks with `receive-result' or otherwise. If `wait' is nil (the default) then `end-kernel' returns immediately. Workers are waited upon by a separate shutdown manager thread. If `wait' is non-nil then `end-kernel' blocks until all workers are finished. No shutdown manager thread is created. A list of the implementation-defined worker thread objects is returned. If `wait' is nil then the shutdown manager thread is also returned as the first element in the list. Note that creating and destroying kernels is relatively expensive. A kernel typically exists for lifetime of the Lisp process. Having more than one kernel is fine -- simply use `let' to bind a kernel instance to `*kernel*' when you need it. Use `kill-tasks' to terminate deadlocked or infinite looping tasks.
  • Function TASK-CATEGORIES-RUNNING
    Return a vector containing the task category currently running for each worker.
  • Function BROADCAST-TASK (function &rest args)
    Wait for current and pending tasks to complete, if any, then simultaneously execute the given task inside each worker. Wait until these tasks finish, then return the results in a vector. Calling `broadcast-task' from inside a worker is an error.
  • Function SUBMIT-TIMEOUT (channel timeout-seconds timeout-result)
    Effectively equivalent to (submit-task channel (lambda () (sleep timeout-seconds) timeout-result)) The difference is that `submit-timeout' does not occupy a worker thread. A timeout object is returned, which may be passed to `cancel-timeout'. `submit-timeout' and `cancel-timeout' are deprecated; use the new `:timeout' option in `try-receive-result'.
  • Function CANCEL-TIMEOUT (timeout timeout-result)
    Attempt to cancel a timeout. If successful, the channel passed to `submit-timeout' will receive `timeout-result'. At most one call to `cancel-timeout' will succeed; others will be ignored. If the timeout has expired on its own then `cancel-timeout' will have no effect. `cancel-timeout' is not available in ABCL. `submit-timeout' and `cancel-timeout' are deprecated; use the new `:timeout' option in `try-receive-result'.

LPARALLEL.KERNEL-UTIL

(semi-private) Abstracts some common patterns for submitting and
   receiving tasks. This probably won't change, but no guarantees.
  • Macro WITH-SUBMIT-COUNTED (&body body)
  • Macro WITH-SUBMIT-INDEXED (count array &body body)
  • Macro WITH-SUBMIT-CANCELABLE (&body body)
  • Macro WITH-TEMP-KERNEL ((&rest make-kernel-args) &body body)
    Create a temporary kernel for the duration of `body', ensuring that `end-kernel' is eventually called. `make-kernel' is given the arguments `make-kernel-args'. **NOTE**: Use this only if you understand its implications. Since `*kernel*' is unaffected outside `body', the REPL will be useless with respect to the temporary kernel. For instance calling `kill-tasks' from the REPL will not affect tasks that are running in the temporary kernel. Multiple uses of `with-temp-kernel' within the same application are prone to defeat the purpose and benefits of having a thread pool. This is an especial risk if `with-temp-kernel' appears inside a library, which is likely to be a suboptimal situation. While using `with-temp-kernel' is generally a bad idea, there are a few valid uses, such as for testing, where the code is non-critical or where convenience trumps other concerns.

LPARALLEL.PROMISE

Promises and futures.
  • Function PROMISE
    Create a promise. A promise is a receptacle for a result which is unknown at the time it is created.
  • Macro DELAY (&body body)
    Create a delay. A delay is a promise which is fulfilled when `force' is called upon it.
  • Macro FUTURE (&body body)
    Create a future. A future is a promise which is fulfilled in parallel by the implicit progn `body'.
  • Macro SPECULATE (&body body)
    Create a speculation. A speculation is a low-priority future.
  • Function CHAIN (object)
    Create a chain. A chain links objects together by relaying `force' and `fulfilledp' calls.
  • Macro FULFILL (object &body body)
    Attempt to give `object' a value. If `object' is a promise which is not fulfilled and not currently being fulfilled, then the implicit progn `body' will be executed and the promise will store the result. In this case `fulfill' returns true. If `object' is a promise that is either already fulfilled or actively being fulfilled, then `body' will not be executed and `fulfill' returns false. If `object' is a chain, call `fulfill' on the chained object. If `object' is not a promise and not a chain then false is returned immediately, with `body' being ignored.
  • Function FULFILLEDP (object)
    If `object' is a promise, return a boolean indicating whether the promise is fulfilled. If `object' is a chain, call `fulfilledp' on the chained object. If `object' is not a promise and not a chain, return true.
  • Function FORCE (object)
    If `object' is a promise and the promise is fulfilled, return the fulfilled value (possibly multiple values). If the promise is unfulfilled then the call blocks until the promise is fulfilled. If `object' is a chain, call `force' on the chained object. If `object' is not a promise and not a chain, return the identical object passed. Note if `force' is called on an unfulfilled future then the future is fulfilled by the caller of `force'.

LPARALLEL.PTREE

A ptree is a computation represented by a tree together with
   functionality to execute the tree in parallel.
  • Condition PTREE-REDEFINITION-ERROR  (PTREE-ERROR)
    Attempted to redefine a node's function.
  • Condition PTREE-UNDEFINED-FUNCTION-ERROR  (PTREE-ERROR)
    Attempted to execute a node which had no function.
  • Condition PTREE-LAMBDA-LIST-KEYWORD-ERROR  (PTREE-ERROR)
    Lambda list keywords found in function definition.
  • Variable *PTREE-NODE-KERNEL*
    nil
    When non-nil, `*kernel*' is bound to this value during the call of a node function.
  • Struct PTREE
    A ptree is a computation represented by a tree together with functionality to execute the tree in parallel.
    NODES
    QUEUE
    PENDING
    LOCK
  • Function MAKE-PTREE
    Create a ptree instance.
  • Function CHECK-PTREE (ptree)
    Verify that all nodes have been defined with an associated function. If not, `ptree-undefined-function-error' is signaled.
  • Function CLEAR-PTREE (ptree)
    Clear all node results in `ptree', restoring the tree to its uncomputed state.
  • Function CLEAR-PTREE-ERRORS (ptree)
    Clear all error results in `ptree', allowing the computation to resume from its latest pre-error state.
  • Function PTREE-FN (id args function ptree)
    Define a ptree node with identifier `id', which is some unique object suitable for `eql' comparison such as symbol. The ids of its child nodes are elements of the list `args'. `function' is the function associated with this node. The arguments passed to `function' are the respective results of the child node computations. `ptree' is the ptree instance in which the node is being defined.
  • Function PTREE-COMPUTED-P (id ptree)
    Return true if the node with identifier `id' in `ptree' has finished computing, otherwise return false.
  • Function CALL-PTREE (id ptree)
    Return the computation result of the node with identifier `id' in `ptree'. If the node is uncomputed, compute the result. If the node is already computed, return the computed result.
  • Macro PTREE (defs &body body)
    Create a ptree using `flet' syntax. ptree ((node-name child-names function-body)*) form* Each `node-name' form corresponds to the definition of a ptree node. `node-name' is the name of the node being defined (a symbol). `child-names' is a list of the names of child nodes (symbols). The function associated with the node being defined is `(lambda ,child-names ,@function-body) `child-names' cannot contain lambda list keywords. For each `node-name', a symbol macro is defined which expands to a `call-ptree' form for that node.

LPARALLEL.SLET

(private) Serial let.
  • Macro SLET (bindings &body body)
    `slet' (serial let) is the non-parallel counterpart to `plet'. The syntax of `slet' matches that of `plet', which includes the ability to bind multiple values.

LPARALLEL.DEFPUN

Fine-grained parallelism.
  • Macro DECLAIM-DEFPUN (&rest names)
    See `defpun'.
  • Macro DEFPUN (name lambda-list &body body)
    `defpun' defines a function which is specially geared for fine-grained parallelism. If you have many small tasks which bog down the system, `defpun' may help. The syntax of `defpun' matches that of `defun'. The difference is that `plet' and `plet-if' take on new meaning inside `defpun'. The symbols in the binding positions of `plet' and `plet-if' should be viewed as lazily evaluated immutable references. Inside a `defpun' form the name of the function being defined is a macrolet, as are the names of other functions which were defined by `defpun'. Thus using #' on them is an error. Calls to functions defined by `defpun' entail more overhead when the caller lies outside a `defpun' form. A `defpun' function must exist before it is referenced inside another `defpun' function. If this is not possible--for example if func1 and func2 reference each other--then use `declaim-defpun' to specify intent: (declaim-defpun func1 func2)
  • Macro DEFPUN/TYPE (name lambda-list arg-types return-type &body body)
    Typed version of `defpun'. `arg-types' is an unevaluated list of argument types. `return-type' is an unevaluated form of the return type, possibly indicating multiple values as in (values fixnum float). (As a technical point, if `return-type' contains no lambda list keywords then the return type given to ftype will be additionally constrained to match the number of return values specified.)
  • Macro DEFPUN* (&rest args)
    Deprecated. Instead use `defpun' and pass `:use-caller t' to `make-kernel'.
  • Macro DEFPUN/TYPE* (&rest args)
    Deprecated. Instead use `defpun/type' and pass `:use-caller t' to `make-kernel'.
  • Macro PLET (bindings &body body)
    The syntax of `plet' matches that of `let'. plet ({var-no-init | (var [init-form]) | ((var1 var2 ...) [init-form])}*) declaration* 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. Likewise, each ((var1 var2 ...) init-form) pair creates a future where `var1', `var2',... are bound to the respective multiple return values of `init-form'. Each `var-no-init' is bound to nil and each variable without a corresponding `init-form' is bound to nil (no future is created). Type declarations for vars are recognized by `plet' and incorporated into the final expansion. The semantics of these declarations are the same as those of a regular `let' form. `plet' is subject to optimization inside `defpun'.
  • Macro PLET-IF (predicate bindings &body body)
    The syntax of `plet-if' matches that of `plet' 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 `slet'. `plet-if' is subject to optimization inside `defpun'.

Also exports

  • LPARALLEL.SLET:SLET

LPARALLEL.COGNATE

Parallelized versions of some Common Lisp functions.
  • Macro 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.
  • Macro 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.
  • Macro PFUNCALL (function &rest args)
    Parallel version of `funcall'. Arguments in `args' may be executed in parallel, though not necessarily at the same time.
  • Function PMAP-INTO (result-sequence function &rest sequences)
    Parallel version of `map-into'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function 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.
  • Function PMAPCAR (function &rest sequences)
    Parallel version of `mapcar'. Keyword arguments `parts' and `size' are also accepted (see `pmap'). Unlike `mapcar', `pmapcar' also accepts vectors.
  • Function 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').
  • Function PMAPLIST (function &rest lists)
    Parallel version of `maplist'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function PMAPL (function &rest lists)
    Parallel version of `mapl'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function PMAPC (function &rest lists)
    Parallel version of `mapc'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function PMAPCAN (function &rest lists)
    Parallel version of `mapcan'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function PMAPCON (function &rest lists)
    Parallel version of `mapcon'. Keyword arguments `parts' and `size' are also accepted (see `pmap').
  • Function 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 ...).
  • Macro 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.
  • Function 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').
  • Function 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').
  • Function 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').
  • Function 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').
  • Function 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".
  • Function 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.
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function 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).
  • Function PSORT (sequence predicate &key key granularity &allow-other-keys)
  • Function PSORT* (&rest args)
    Deprecated. Instead use `psort' and pass `:use-caller t' to `make-kernel'.

Also exports

  • LPARALLEL.DEFPUN:PLET
  • LPARALLEL.SLET:SLET
  • LPARALLEL.DEFPUN:PLET-IF

LPARALLEL

This is a convenience package which exports the external symbols of:
   lparallel.kernel
   lparallel.promise
   lparallel.defpun
   lparallel.cognate
   lparallel.ptree
No exported symbols.

Also exports

  • LPARALLEL.PTREE:PTREE-FN
  • LPARALLEL.COGNATE:PMAPCAN
  • LPARALLEL.COGNATE:PSOME
  • LPARALLEL.DEFPUN:DEFPUN*
  • LPARALLEL.DEFPUN:PLET
  • LPARALLEL.COGNATE:PMAPL
  • LPARALLEL.PTREE:PTREE-REDEFINITION-ERROR
  • LPARALLEL.COGNATE:PMAPC
  • LPARALLEL.COGNATE:PDOTIMES
  • LPARALLEL.SLET:SLET
  • LPARALLEL.PROMISE:FUTURE
  • LPARALLEL.PROMISE:FORCE
  • LPARALLEL.COGNATE:PFUNCALL
  • LPARALLEL.COGNATE:PEVERY
  • LPARALLEL.KERNEL:MAKE-CHANNEL
  • LPARALLEL.KERNEL:CHECK-KERNEL
  • LPARALLEL.COGNATE:PNOTANY
  • LPARALLEL.PROMISE:PROMISE
  • LPARALLEL.KERNEL:BROADCAST-TASK
  • LPARALLEL.COGNATE:PMAPLIST
  • LPARALLEL.PROMISE:FULFILL
  • LPARALLEL.PTREE:PTREE
  • LPARALLEL.KERNEL:NO-KERNEL-ERROR
  • LPARALLEL.COGNATE:PFIND
  • LPARALLEL.PTREE:MAKE-PTREE
  • LPARALLEL.KERNEL:TRANSFER-ERROR
  • LPARALLEL.KERNEL:KERNEL-BINDINGS
  • LPARALLEL.KERNEL:KERNEL-NAME
  • LPARALLEL.KERNEL:*TASK-PRIORITY*
  • LPARALLEL.COGNATE:PSORT*
  • LPARALLEL.KERNEL:DO-FAST-RECEIVES
  • LPARALLEL.KERNEL:TASK-CATEGORIES-RUNNING
  • LPARALLEL.COGNATE:PREDUCE-PARTIAL
  • LPARALLEL.KERNEL:CANCEL-TIMEOUT
  • LPARALLEL.PROMISE:FULFILLEDP
  • LPARALLEL.COGNATE:PAND
  • LPARALLEL.KERNEL:TASK-HANDLER-BIND
  • LPARALLEL.KERNEL:RECEIVE-RESULT
  • LPARALLEL.PTREE:*PTREE-NODE-KERNEL*
  • LPARALLEL.COGNATE:PFIND-IF-NOT
  • LPARALLEL.KERNEL:END-KERNEL
  • LPARALLEL.COGNATE:PSORT
  • LPARALLEL.KERNEL:MAKE-KERNEL
  • LPARALLEL.PROMISE:SPECULATE
  • LPARALLEL.KERNEL:*DEBUG-TASKS-P*
  • LPARALLEL.KERNEL:*KERNEL-SPIN-COUNT*
  • LPARALLEL.COGNATE:POR
  • LPARALLEL.DEFPUN:DECLAIM-DEFPUN
  • LPARALLEL.DEFPUN:DEFPUN/TYPE
  • LPARALLEL.KERNEL:*TASK-CATEGORY*
  • LPARALLEL.PTREE:PTREE-COMPUTED-P
  • LPARALLEL.PTREE:CLEAR-PTREE
  • LPARALLEL.COGNATE:PMAP-INTO
  • LPARALLEL.COGNATE:PMAP
  • LPARALLEL.KERNEL:SUBMIT-TIMEOUT
  • LPARALLEL.KERNEL:KERNEL-WORKER-COUNT
  • LPARALLEL.KERNEL:*KERNEL*
  • LPARALLEL.COGNATE:PCOUNT-IF
  • LPARALLEL.KERNEL:KILL-TASKS
  • LPARALLEL.KERNEL:TASK-KILLED-ERROR
  • LPARALLEL.KERNEL:KERNEL-CREATION-ERROR
  • LPARALLEL.PROMISE:CHAIN
  • LPARALLEL.COGNATE:PCOUNT-IF-NOT
  • LPARALLEL.COGNATE:PREMOVE-IF-NOT
  • LPARALLEL.DEFPUN:DEFPUN/TYPE*
  • LPARALLEL.PTREE:CHECK-PTREE
  • LPARALLEL.PTREE:CLEAR-PTREE-ERRORS
  • LPARALLEL.COGNATE:PMAPCAR
  • LPARALLEL.KERNEL:INVOKE-TRANSFER-ERROR
  • LPARALLEL.PROMISE:DELAY
  • LPARALLEL.COGNATE:PREMOVE
  • LPARALLEL.PTREE:CALL-PTREE
  • LPARALLEL.COGNATE:PCOUNT
  • LPARALLEL.KERNEL:KERNEL-CONTEXT
  • LPARALLEL.COGNATE:PREDUCE
  • LPARALLEL.COGNATE:PMAPCON
  • LPARALLEL.COGNATE:PFIND-IF
  • LPARALLEL.KERNEL:CHANNEL
  • LPARALLEL.DEFPUN:PLET-IF
  • LPARALLEL.KERNEL:TRY-RECEIVE-RESULT
  • LPARALLEL.PTREE:PTREE-UNDEFINED-FUNCTION-ERROR
  • LPARALLEL.COGNATE:PMAPLIST-INTO
  • LPARALLEL.DEFPUN:DEFPUN
  • LPARALLEL.COGNATE:PNOTEVERY
  • LPARALLEL.KERNEL:KERNEL
  • LPARALLEL.PTREE:PTREE-LAMBDA-LIST-KEYWORD-ERROR
  • LPARALLEL.COGNATE:PREMOVE-IF
  • LPARALLEL.KERNEL:KERNEL-WORKER-INDEX
  • LPARALLEL.COGNATE:PMAP-REDUCE
  • LPARALLEL.KERNEL:SUBMIT-TASK

lparallel-bench

Benchmarks for lparallel.

LPARALLEL-BENCH

Benchmarks for lparallel.
  • Function EXECUTE (num-workers &rest fns)
  • Function PROFILE (&rest args)
  • Function STAT-PROFILE (&rest args)

Also exports

  • LPARALLEL.KERNEL-UTIL:WITH-TEMP-KERNEL

lparallel-test

Test suite for lparallel.

LPARALLEL-TEST.1AM

  • Variable *TESTS*
    nil
    A list of tests; the default argument to `run'.
  • Function RUN (&optional (tests *tests*))
    Run each test in the sequence `tests'. Default is `*tests*'.
  • Macro TEST (name &body body)
    Define a test function and add it to `*tests*'.
  • Macro IS (form)
    Assert that `form' evaluates to non-nil.
  • Macro SIGNALS (condition &body body)
    Assert that `body' signals a condition of type `condition'.

LPARALLEL-TEST

Test suite for lparallel.
No exported symbols.