The petalisp Reference Manual

This is the petalisp Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 06:30:07 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 petalisp

Elegant High Performance Computing

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.asd.


2.2 petalisp.api

A Convenient API for Petalisp.

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.api.asd.

Child Components

2.3 petalisp.utilities

Author

Marco Heisig <>

License

AGPLv3

Dependencies
  • alexandria (system).
  • bordeaux-threads (system).
  • queues.priority-queue (system).
  • trivia (system).
  • trivial-garbage (system).
Source

petalisp.utilities.asd.

Child Components

2.4 petalisp.core

Author

Marco Heisig <>

License

AGPLv3

Dependencies
  • alexandria (system).
  • bordeaux-threads (system).
  • lparallel (system).
  • trivia (system).
  • petalisp.utilities (system).
  • typo (system).
Source

petalisp.core.asd.

Child Components

2.5 petalisp.ir

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.ir.asd.

Child Components

2.6 petalisp.codegen

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.codegen.asd.

Child Components

2.7 petalisp.native-backend

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.native-backend.asd.

Child Components

2.8 petalisp.test-suite

A comprehensive test suite for Petalisp.

Author

Marco Heisig <>

License

AGPLv3

Dependencies
Source

petalisp.test-suite.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 petalisp/petalisp.asd

Source

petalisp.asd.

Parent Component

petalisp (system).

ASDF Systems

petalisp.


3.1.2 petalisp.api/petalisp.api.asd

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

ASDF Systems

petalisp.api.


3.1.3 petalisp.utilities/petalisp.utilities.asd

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

ASDF Systems

petalisp.utilities.


3.1.4 petalisp.core/petalisp.core.asd

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

ASDF Systems

petalisp.core.


3.1.5 petalisp.ir/petalisp.ir.asd

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

ASDF Systems

petalisp.ir.


3.1.6 petalisp.codegen/petalisp.codegen.asd

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

ASDF Systems

petalisp.codegen.


3.1.7 petalisp.native-backend/petalisp.native-backend.asd

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

ASDF Systems

petalisp.native-backend.


3.1.8 petalisp.test-suite/petalisp.test-suite.asd

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

ASDF Systems

petalisp.test-suite.


3.1.9 petalisp.api/differentiator.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface
Internals

3.1.10 petalisp.api/lazy-broadcast.lisp

Dependency

lazy-reshape.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface
Internals

3.1.11 petalisp.api/lazy-change-shape.lisp

Dependency

shape-syntax.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Internals

3.1.12 petalisp.api/lazy-drop-axes.lisp

Dependency

lazy-reshape.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-drop-axes (function).


3.1.13 petalisp.api/lazy-harmonize.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

3.1.14 petalisp.api/lazy-index-components.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-index-components (function).


3.1.15 petalisp.api/lazy.lisp

Dependency

lazy-broadcast.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy (function).


3.1.16 petalisp.api/lazy-multiple-value.lisp

Dependency

lazy-broadcast.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-multiple-value (function).


3.1.17 petalisp.api/lazy-multireduce.lisp

Dependency

lazy-reduce.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-multireduce (function).


3.1.18 petalisp.api/lazy-overwrite.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-overwrite (function).


3.1.19 petalisp.api/lazy-reduce.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-reduce (function).

Internals

lazy-reduce-aux (function).


3.1.20 petalisp.api/lazy-reshape.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-reshape (function).

Internals

3.1.21 petalisp.api/lazy-slice.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-slice (function).


3.1.22 petalisp.api/lazy-slices.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-slices (function).


3.1.23 petalisp.api/lazy-sort.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-sort (function).


3.1.24 petalisp.api/lazy-stack.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

lazy-stack (function).


3.1.25 petalisp.api/network.lisp

Dependencies
Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface
Internals

network-evaluator (reader method).


3.1.26 petalisp.api/packages.lisp

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Packages
Public Interface

*backend* (special variable).


3.1.27 petalisp.api/reshapers.lisp

Dependency

lazy-reshape.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

3.1.28 petalisp.api/shape-syntax.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface
Internals

3.1.29 petalisp.api/transform.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface
Internals

3.1.30 petalisp.api/with-lazy-arrays.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

with-lazy-arrays (macro).


3.1.31 petalisp.api/with-backend.lisp

Dependency

packages.lisp (file).

Source

petalisp.api.asd.

Parent Component

petalisp.api (system).

Public Interface

with-backend (macro).


3.1.33 petalisp.utilities/packages.lisp

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Packages

petalisp.utilities.


3.1.34 petalisp.utilities/documentation.lisp

Dependency

packages.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface
Internals

3.1.35 petalisp.utilities/cqueue.lisp

Dependency

documentation.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Packages

petalisp.cqueue.

Public Interface
Internals

3.1.36 petalisp.utilities/extended-euclid.lisp

Dependency

cqueue.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface

extended-euclid (function).

Internals

3.1.37 petalisp.utilities/powers-of-two.lisp

Dependency

extended-euclid.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface
Internals

clp2-fixnum (type).


3.1.38 petalisp.utilities/prime-factors.lisp

Dependency

powers-of-two.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface
Internals

3.1.39 petalisp.utilities/with-collectors.lisp

Dependency

prime-factors.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface

with-collectors (macro).

Internals

with-collector (macro).


3.1.40 petalisp.utilities/number-of-cpus.lisp

Dependency

with-collectors.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface

number-of-cpus (function).


3.1.41 petalisp.utilities/graph-coloring.lisp

Dependency

number-of-cpus.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface
Internals

3.1.42 petalisp.utilities/karmarkar-karp.lisp

Dependency

graph-coloring.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Packages

petalisp.karmarkar-karp.

Public Interface

karmarkar-karp (function).

Internals

3.1.43 petalisp.utilities/scheduling.lisp

Dependency

karmarkar-karp.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Packages

petalisp.scheduling.

Public Interface
Internals

3.1.44 petalisp.utilities/with-pinned-objects.lisp

Dependency

scheduling.lisp (file).

Source

petalisp.utilities.asd.

Parent Component

petalisp.utilities (system).

Public Interface
Internals

3.1.45 petalisp.core/packages.lisp

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Packages

petalisp.core.


3.1.46 petalisp.core/range.lisp

Dependency

packages.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.47 petalisp.core/shape.lisp

Dependency

range.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.48 petalisp.core/transformation.lisp

Dependency

shape.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.49 petalisp.core/transformation-constructors.lisp

Dependency

transformation.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.50 petalisp.core/lazy-array.lisp

Dependency

transformation-constructors.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.51 petalisp.core/lazy-ref.lisp

Dependency

lazy-array.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

add-transformation-constraints (function).


3.1.52 petalisp.core/lazy-fuse.lisp

Dependency

lazy-ref.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface

lazy-fuse (function).


3.1.53 petalisp.core/lazy-map.lisp

Dependency

lazy-fuse.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface

3.1.54 petalisp.core/substitute-lazy-arrays.lisp

Dependency

lazy-map.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

*substitutions* (special variable).


3.1.55 petalisp.core/backend.lisp

Dependency

substitute-lazy-arrays.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.56 petalisp.core/reference-backend.lisp

Dependency

backend.lisp (file).

Source

petalisp.core.asd.

Parent Component

petalisp.core (system).

Public Interface
Internals

3.1.57 petalisp.ir/packages.lisp

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Packages

petalisp.ir.


3.1.58 petalisp.ir/device.lisp

Dependency

packages.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface
Internals

3.1.59 petalisp.ir/ir.lisp

Dependency

device.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface
Internals

3.1.60 petalisp.ir/ir-checker.lisp

Dependency

ir.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface

check-ir (function).

Internals

3.1.61 petalisp.ir/ir-conversion.lisp

Dependency

ir-checker.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface
Internals

3.1.62 petalisp.ir/partitioning.lisp

Dependency

ir-conversion.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface
Internals

3.1.63 petalisp.ir/coloring.lisp

Dependency

partitioning.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).

Public Interface

compute-program-buffer-coloring (function).


3.1.64 petalisp.ir/documentation.lisp

Dependency

coloring.lisp (file).

Source

petalisp.ir.asd.

Parent Component

petalisp.ir (system).


3.1.65 petalisp.codegen/packages.lisp

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Packages

petalisp.codegen.


3.1.66 petalisp.codegen/indexing.lisp

Dependency

packages.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface
Internals

*index-ntype* (special variable).


3.1.67 petalisp.codegen/load-foreign-code.lisp

Dependency

indexing.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface

load-foreign-code (function).


3.1.68 petalisp.codegen/generic-functions.lisp

Dependency

load-foreign-code.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface

3.1.69 petalisp.codegen/blueprint.lisp

Dependency

generic-functions.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface
Internals

3.1.70 petalisp.codegen/bpinfo.lisp

Dependency

blueprint.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Internals

3.1.71 petalisp.codegen/compile-cache.lisp

Dependency

bpinfo.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Internals

3.1.72 petalisp.codegen/lisp-compiler.lisp

Dependency

compile-cache.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface
Internals

3.1.73 petalisp.codegen/lisp-interpreter.lisp

Dependency

lisp-compiler.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Internals

interpret-kernel (function).


3.1.74 petalisp.codegen/cpp-from-lisp.lisp

Dependency

lisp-interpreter.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Internals

3.1.75 petalisp.codegen/cpp-compiler.lisp

Dependency

cpp-from-lisp.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Internals

3.1.76 petalisp.codegen/mixins.lisp

Dependency

cpp-compiler.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface
Internals

compile-cache (reader method).


3.1.77 petalisp.codegen/ir-backend.lisp

Dependency

mixins.lisp (file).

Source

petalisp.codegen.asd.

Parent Component

petalisp.codegen (system).

Public Interface
Internals

3.1.78 petalisp.native-backend/packages.lisp

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Packages

petalisp.native-backend.


3.1.79 petalisp.native-backend/request.lisp

Dependency

packages.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Public Interface
Internals

3.1.80 petalisp.native-backend/pin-current-thread.lisp

Dependency

request.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Internals

3.1.81 petalisp.native-backend/worker-pool.lisp

Dependency

pin-current-thread.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Public Interface

print-object (method).

Internals

3.1.82 petalisp.native-backend/backend.lisp

Dependency

worker-pool.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Public Interface
Internals

3.1.83 petalisp.native-backend/scheduling.lisp

Dependency

backend.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Internals

3.1.84 petalisp.native-backend/allocation.lisp

Dependency

scheduling.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Internals

3.1.85 petalisp.native-backend/evaluator.lisp

Dependency

allocation.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Public Interface

backend-evaluator (method).

Internals

3.1.86 petalisp.native-backend/compilation.lisp

Dependency

evaluator.lisp (file).

Source

petalisp.native-backend.asd.

Parent Component

petalisp.native-backend (system).

Public Interface
Internals

3.1.87 petalisp.test-suite/packages.lisp

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Packages

petalisp.test-suite.


3.1.88 petalisp.test-suite/test-suite.lisp

Dependency

packages.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Public Interface
Internals

3.1.89 petalisp.test-suite/testing-backend.lisp

Dependency

test-suite.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Public Interface
Internals

3.1.90 petalisp.test-suite/code-statistics.lisp

Dependency

testing-backend.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

3.1.91 petalisp.test-suite/defgenerator.lisp

Dependency

code-statistics.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

3.1.92 petalisp.test-suite/generators.lisp

Dependency

defgenerator.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

3.1.93 petalisp.test-suite/run-petalisp-test-suite.lisp

Dependency

generators.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Public Interface

3.1.94 petalisp.test-suite/petalisp.core.lisp

Dependency

run-petalisp-test-suite.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

3.1.95 petalisp.test-suite/petalisp.api.lisp

Dependency

petalisp.core.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

lazy-sort-test (function).


3.1.96 petalisp.test-suite/petalisp.examples.lisp

Dependency

petalisp.api.lisp (file).

Source

petalisp.test-suite.asd.

Parent Component

petalisp.test-suite (system).

Internals

4 Packages

Packages are listed by definition order.


4.1 petalisp.api

Source

packages.lisp.

Nickname

petalisp

Use List
Used By List
  • petalisp-user.
  • petalisp.examples.image-processing.
  • petalisp.examples.iterative-methods.
  • petalisp.examples.linear-algebra.
  • petalisp.examples.machine-learning.
  • petalisp.examples.mnist.
  • petalisp.examples.multigrid.
  • petalisp.examples.wave-equation.
  • petalisp.test-suite.
Public Interface
Internals

4.2 petalisp.test-suite

Source

packages.lisp.

Use List
Public Interface
Internals

4.3 petalisp.codegen

Source

packages.lisp.

Use List
Used By List

petalisp.native-backend.

Public Interface
Internals

4.4 petalisp.utilities

Source

packages.lisp.

Use List

common-lisp.

Used By List

petalisp.karmarkar-karp.

Public Interface
Internals

4.5 petalisp-user

Source

packages.lisp.

Use List

4.6 petalisp.scheduling

Source

scheduling.lisp.

Use List

common-lisp.

Public Interface
Internals

4.7 petalisp.cqueue

Source

cqueue.lisp.

Use List

common-lisp.

Public Interface
Internals

4.8 petalisp.core

Source

packages.lisp.

Use List

common-lisp.

Used By List
Public Interface
Internals

4.9 petalisp.ir

Source

packages.lisp.

Use List
Used By List
Public Interface
Internals

4.10 petalisp.karmarkar-karp

Source

karmarkar-karp.lisp.

Use List
Internals

4.11 petalisp.native-backend

Source

packages.lisp.

Use List
Public Interface

make-native-backend (function).

Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Constants

Constant: ~

The symbols ~, ~* are self-evaluating. Their only purpose is to separate range designators in the functions named ~, ~*.

Package

petalisp.api.

Source

shape-syntax.lisp.

Constant: ~*

The symbols ~, ~* are self-evaluating. Their only purpose is to separate range designators in the functions named ~, ~*.

Package

petalisp.api.

Source

shape-syntax.lisp.


5.1.2 Special variables

Special Variable: *backend*
Package

petalisp.core.

Source

packages.lisp.

Special Variable: *lazy-array-lock*
Package

petalisp.core.

Source

lazy-array.lisp.

Special Variable: *stencil-max-radius*
Package

petalisp.ir.

Source

ir.lisp.


5.1.3 Macros

Macro: define-test (name &body body)

Define a test function and add it to *TESTS*.

Package

petalisp.test-suite.

Source

test-suite.lisp.

Macro: do-buffer-inputs ((kernel buffer &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-buffer-load-instructions ((load-instruction buffer &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-buffer-outputs ((kernel buffer &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-buffer-store-instructions ((store-instruction buffer &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-instruction-inputs ((input instruction &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-kernel-inputs ((buffer kernel &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-kernel-instructions ((instruction kernel &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-kernel-load-instructions ((load-instruction kernel &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-kernel-outputs ((buffer kernel &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-kernel-store-instructions ((store-instruction kernel &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-program-buffer-groups ((buffers program &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-program-buffers ((buffer program &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-program-kernels ((kernel program &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-program-tasks ((task program &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-stencil-instructions ((load-or-store-instruction stencil &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-task-defined-buffers ((defined-buffer task &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-task-kernels ((kernel task &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-task-predecessors ((predecessor task &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: do-task-successors ((successor task &optional result) &body body)
Package

petalisp.ir.

Source

ir.lisp.

Macro: document-compiler-macro (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-compiler-macros (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-function (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-functions (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-method-combination (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-method-combinations (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-setf-expander (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-setf-expanders (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-structure (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-structures (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-variable (name &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: document-variables (names &body body)
Package

petalisp.utilities.

Source

documentation.lisp.

Macro: is (test-form)

Assert that TEST-FORM evaluates to true.

Package

petalisp.test-suite.

Source

test-suite.lisp.

Macro: signals (condition &body body)

Assert that ‘body’ signals a condition of type ‘condition’.

Package

petalisp.test-suite.

Source

test-suite.lisp.

Macro: transform (&rest inputs-to-outputs)

Returns a transformation that maps the supplied inputs to the supplied outputs.

The supplied forms describe the inputs and outputs of the transformation. Inputs and outputs are separated by the symbol PETALISP:TO.

Each input can either be a symbol, an integer, or a list whose first element is a symbol and whose second element is a form that evaluates either to an integer or to NIL. The symbol is the name under which the value of that input can be referenced in one of the outputs. Any integer value is interpreted as an input constraint of the transformation in that axis.

Each output is a form that may reference up to one of the input variables. The output form is evaluated repeatedly in a context where the referenced input variable is bound to an integer to determine the coefficients for the linear mapping from the referenced input to the output.

Signals an error if any output form references more than one input, returns anything other than an integer, or describes a mapping that is not linear.

Examples:

(transform i to (+ i 1))
=> (transform a to (1+ a))

(transform i to (+ (+ i 1) 5))
=> (transform a to (+ a 6))

(transform 1 2 3 to)
=> (transform 1 2 3 to)

(transform to 1 2 3)
=> (transform to 1 2 3)

(transform i j to j i)
=> (transform a b to b a)

Package

petalisp.api.

Source

transform.lisp.

Macro: with-backend (backend &body body)
Package

petalisp.api.

Source

with-backend.lisp.

Macro: with-collectors (collectors &body body)

Within the lexical scope of BODY, bind the specified collectors. Each entry in COLLECTORS must be a list of two valid function names - RESULT and GATHER. Each such pair of function names is bound to local functions, with the following behavior:

The function named GATHER takes a single argument, stores this argument in some unspecified way, and returns this argument.

The function named RESULT takes either zero or one object. It returns the list of all objects that have been stored by calls to the function named GATHER. If supplied, the optional argument is used as the tail of the list being returned. Calling the function named RESULT more than once results in undefined behavior.

Examples:

(with-collectors ((odds collect-odd)
(evens collect-even))
(loop for n below 8 do
(if (oddp n)
(collect-odd n)
(collect-even n)))
(values (odds) (evens)))

=> (1 3 5 7)
=> (0 2 4 6)

(with-collectors ((numbers collect-number))
(collect-number 2)
(collect-number 3)
(numbers ’(4 5 6))) ; Here, we explicitly supply a tail.

=> (2 3 4 5 6)

Package

petalisp.utilities.

Source

with-collectors.lisp.

Macro: with-debug-optimization (&body body)

Execute BODY safely and with highest debug settings.

Package

petalisp.codegen.

Source

lisp-compiler.lisp.

Macro: with-lazy-arrays ((&rest names) &body body)

Execute the body in an environment where each of the supplied symbols is shadowed by the lazy array equivalent of the previous value of that symbol.

An alternative notation can be used to avoid shadowing the original array: If any array name is not a symbol but a list of a symbol and a form, the symbol is bound to the lazy array equivalent of what’s produced by that form.

It is good practice to start each function that expects some of its arguments to be lazy arrays to start with a suitable use of this macro.

Example:

(let ((a 5) (b #(1 2 3)))
(with-lazy-arrays (a (c b))
(values a b c)))
=> #<lazy-array (eql 5) (~*)>
=> #(1 2 3)
=> #<lazy-array t (~ 3)>

Package

petalisp.api.

Source

with-lazy-arrays.lisp.

Macro: with-pinned-objects ((&rest objects) &body body)
Package

petalisp.utilities.

Source

with-pinned-objects.lisp.

Macro: with-pinned-objects* (objects &body body)

Invoke BODY in an environment where all elements of the supplied sequence of objects are pinned to their current memory location.

Package

petalisp.utilities.

Source

with-pinned-objects.lisp.

Macro: with-temporary-backend (backend-creation-form &body body)
Package

petalisp.core.

Source

backend.lisp.

Macro: with-unsafe-optimization (&body body)

Optimize the heck out of BODY. Use with caution!

To preserve sanity, compiler efficiency hints are disabled by default. Use WITH-UNSAFE-OPTIMIZATIONS* to see these hints.

Package

petalisp.codegen.

Source

lisp-compiler.lisp.

Macro: with-unsafe-optimization* (&body body)

Optimize the heck out of BODY. Use with caution!

Package

petalisp.codegen.

Source

lisp-compiler.lisp.

Macro: without-compiler-notes (&body body)

Suppress all compiler notes arising during the compilation of BODY.

Package

petalisp.codegen.

Source

lisp-compiler.lisp.


5.1.4 Compiler macros

Compiler Macro: compose-transformations (&rest transformations)
Package

petalisp.core.

Source

transformation.lisp.

Compiler Macro: index* (&rest forms)
Package

petalisp.codegen.

Source

indexing.lisp.

Compiler Macro: index+ (&rest forms)
Package

petalisp.codegen.

Source

indexing.lisp.

Compiler Macro: range (&rest args)
Package

petalisp.core.

Source

range.lisp.


5.1.5 Ordinary functions

Function: all-tests ()
Package

petalisp.test-suite.

Source

test-suite.lisp.

Function: array-has-shape-p (array shape)
Package

petalisp.core.

Source

shape.lisp.

Function: array-shape (array)

Returns the shape of the supplied array.

Package

petalisp.core.

Source

shape.lisp.

Function: array-value (array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: buffer-bits (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Reader: buffer-depth (instance)
Writer: (setf buffer-depth) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

depth.

Reader: buffer-ntype (instance)
Writer: (setf buffer-ntype) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

ntype.

Reader: buffer-number (instance)
Writer: (setf buffer-number) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number.

Function: buffer-number-of-inputs (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: buffer-number-of-loads (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: buffer-number-of-outputs (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: buffer-number-of-stores (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: buffer-program (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: buffer-reuse-potential (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Reader: buffer-shape (instance)
Writer: (setf buffer-shape) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

shape.

Function: buffer-shard-bits (buffer-shard)

Returns the number of bits of storage required for allocating all elements managed by the supplied buffer shard.

Package

petalisp.ir.

Source

partitioning.lisp.

Reader: buffer-shard-buffer (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

buffer.

Reader: buffer-shard-domain (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

domain.

Function: buffer-shard-maxdepth (buffer-shard)

Returns the length of the longest chain of splits rooted in this buffer shard.

Package

petalisp.ir.

Source

partitioning.lisp.

Function: buffer-shard-p (object)
Package

petalisp.ir.

Source

partitioning.lisp.

Reader: buffer-shard-parent (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

parent.

Function: buffer-shard-path (buffer-shard)

Returns a list with one boolean for each ancestor of the supplied
buffer shard, that describes how to reach that buffer shard starting from its primogenitor. An entry of T means the path descends into the left child, and a value of NIL means the path descends into the right child.

Package

petalisp.ir.

Source

partitioning.lisp.

Function: buffer-shard-primogenitor (buffer-shard)

Returns the topmost ancestor of the supplied buffer shard.

Package

petalisp.ir.

Source

partitioning.lisp.

Reader: buffer-shard-readers (instance)
Writer: (setf buffer-shard-readers) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

readers.

Reader: buffer-shard-shape (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

shape.

Reader: buffer-shard-split (instance)
Writer: (setf buffer-shard-split) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

split.

Reader: buffer-shard-storage (instance)
Writer: (setf buffer-shard-storage) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

storage.

Reader: buffer-shard-writers (instance)
Writer: (setf buffer-shard-writers) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

writers.

Function: buffer-size (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Reader: buffer-storage (instance)
Writer: (setf buffer-storage) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

storage.

Reader: buffer-task (instance)
Writer: (setf buffer-task) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

task.

Function: bufferp (object)
Package

petalisp.ir.

Source

ir.lisp.

Reader: call-instruction-fnrecord (instance)
Writer: (setf call-instruction-fnrecord) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

fnrecord.

Function: call-instruction-function (call-instruction)
Package

petalisp.ir.

Source

ir.lisp.

Function: call-instruction-inputs (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf call-instruction-inputs) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Reader: call-instruction-number-of-values (instance)
Writer: (setf call-instruction-number-of-values) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number-of-values.

Function: call-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: call-network (network &rest plist)
Package

petalisp.api.

Source

network.lisp.

Function: cgraph-add-conflict (cgraph a b)
Package

petalisp.utilities.

Source

graph-coloring.lisp.

Function: cgraph-coloring (cgraph)

For a supplied conflict graph, returns a vector whose elements are lists of objects with no conflicts.

Package

petalisp.utilities.

Source

graph-coloring.lisp.

Function: cgraph-ensure-cnode (cgraph object)
Package

petalisp.utilities.

Source

graph-coloring.lisp.

Function: check-ir (nodes)
Package

petalisp.ir.

Source

ir-checker.lisp.

Function: check-package (package &key skip)
Package

petalisp.test-suite.

Source

test-suite.lisp.

Function: clear-shape-table (shape-table)
Package

petalisp.core.

Source

shape.lisp.

Function: clp2 (n)

Round the unsigned integer N up to the next larger power of two.

Package

petalisp.utilities.

Source

powers-of-two.lisp.

Function: collapsing-reshaper ()

Returns a function that can be supplied as a modifier to LAZY-RESHAPE to turn any lazy array shape into modifiers that collapse that shape, such that each range therein starts with zero and has a step size of one.

Package

petalisp.api.

Source

reshapers.lisp.

Function: collapsing-transformation (shape)
Package

petalisp.core.

Source

transformation-constructors.lisp.

Function: compatible-with-lazy-array-p (object lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: completedp (&rest requests)

Returns whether all the requests resulting from some COMPUTE-ASYNCHRONOUSLY operations have been completed.

Package

petalisp.core.

Source

backend.lisp.

Function: compose-transformations (transformation &rest more-transformations)

Returns a single transformation that is equivalent to consecutive invocations of the supplied transformations in right-to-left order.

Examples:

(compose-transformations (transform i to (/ i 2)) (transform i to (+ i 2)) (transform i to (* i 4)))
=> (transform a to (1+ (* 2 a)))

(compose-transformations (transform i to (* 2 (1+ i)))
(transform i to (1- (/ i 2))))
=> (transform a to a)

(compose-transformations (transform i j to (+ i 5) (+ j 7))
(transform i j to (* j 2) (* i 3)))
=> (transform a b to (+ (* 2 b) 5) (+ (* 3 a) 7))

Package

petalisp.core.

Source

transformation.lisp.

Function: compute (&rest arrays)

The primary interface for evaluating lazy arrays. It takes any number of arguments that must be lazy arrays or objects that can be converted to lazy arrays with the function LAZY-ARRAY — and returns the same number of possibly specialized regular arrays with the corresponding contents. A special case is that whenever an array with rank zero would be returned, it instead returns the sole element of that array. The reason for this treatment of scalars is that Petalisp treats every object as an array, whereas in Common Lisp the rank zero array containing an object and that object are distinct entities. Of those two distinct representations, the non-array one is much more intuitive and useful in practice, so this is the one being returned.

Whenever a shape of any of the supplied arrays is not a valid shape for a regular array, that array is collapsed before being computed, i.e., each axis is shifted to begin with zero, and divided by the step size.

All the heavy lifting in Petalisp happens within this function. The exact details of how it operates aren’t important for application programmers, but it is valuable to understand the rough steps that happen internally. The individual steps it performs are:

1. Convert each supplied argument to a lazy array.

2. Collapse each lazy array whose shape isn’t equivalent to that of a regular array.

3. Determine the dependency graph whose roots are the collapsed lazy arrays, and whose leaves are lazy arrays resulting from a call to LAZY-ARRAY on a regular array or scalar.

4. Optimize the dependency graph, discard all unused parts, and plan a schedule that is fast and has reasonable memory requirements.

5. Execute the schedule on the available hardware. Make use of all processing units, accelerators, or even distributed systems where possible. Gather the results in the form of regular arrays.

6. Change the internal representation of all the originally supplied lazy arrays such that future calculations involving them directly use the computed results.

7. Return the results as multiple values, while replacing any array with rank zero with the single element contained in that array.

This function is the workhorse of Petalisp. A lot of effort went into making it not only powerful, but also extremely fast. The overhead of assembling a graph of lazy arrays and passing it to COMPUTE instead of invoking an already compiled and optimized imperative program is usually on the order of just a few microseconds.

Examples:

(compute (lazy-array #(1 2 3)))
=> #(1 2 3)

(compute #(1 2 3))
=> #(1 2 3)

(compute 5)
=> 5

(compute #0A42)
=> 42

(compute #(1 2 3) 5 #0A42)
=> #(1 2 3)
=> 5
=> 42

Package

petalisp.core.

Source

backend.lisp.

Function: compute-asynchronously (&rest arrays)

Hints that it would be worthwhile to compute the supplied arrays asynchronously. Returns a request object that can be passed to the functions WAIT and COMPLETEDP.

Package

petalisp.core.

Source

backend.lisp.

Function: compute-buffer-shard-vicinity (buffer-shard)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: compute-list-of-arrays (arrays)

Returns a list of computed results - one for each element in the list of supplied arrays.

The computed result of an array or lazy array with rank zero is the one element contained in this array. The computed result of any other array or lazy array is an array with the same rank and dimensions. The computed result of any other object is that object itself.

Examples:

(compute-list-of-arrays (list (lazy #’+ 2 #(3 4))))
=> (#(5 6))

(compute-list-of-arrays
(list (lazy-reshape #2A((1 2) (3 4)) (transform i j to j i))))
=> (#2A((1 3) (2 4)))

(compute-list-of-arrays (list 2 #0A3 #(4)))
=> (2 3 #(4))

Package

petalisp.core.

Source

backend.lisp.

Function: compute-program-buffer-coloring (program)

Returns a partitioning of all non-leaf buffers in PROGRAM into a list of lists of buffers. Each list of buffers has the same color, meaning that they can share the same memory location without conflicts.

All root buffers conflict with each other, so each list of buffers contains at most one root buffer. By convention, if a root buffer is present in a list of buffers, it comes first.

Package

petalisp.ir.

Source

coloring.lisp.

Function: compute-stencil-center (instruction &rest more-instructions)

Returns a vector of offsets that is the weighted average of all the offsets of all the supplied load or store instructions.

Package

petalisp.ir.

Source

ir.lisp.

Function: copy-lazy-arrays (lazy-arrays)
Package

petalisp.core.

Source

substitute-lazy-arrays.lisp.

Function: cqueue-dequeue (cqueue)

Removes and returns the element at the front of CQUEUE, or return NIL if the cqueue was empty. Return a second value that is a boolean indicating whether an object was taken from the cqueue or not.

Package

petalisp.cqueue.

Source

cqueue.lisp.

Function: cqueue-enqueue (cqueue object)

Inserts OBJECT at the back of CQUEUE.

Package

petalisp.cqueue.

Source

cqueue.lisp.

Function: cqueuep (object)
Package

petalisp.cqueue.

Source

cqueue.lisp.

Function: delayed-action-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-array-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-array-storage (instance)
Writer: (setf delayed-array-storage) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

storage.

Reader: delayed-failure-condition (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

condition.

Function: delayed-failure-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-fuse-inputs (instance)
Writer: (setf delayed-fuse-inputs) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

inputs.

Function: delayed-fuse-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-map-fnrecord (instance)
Writer: (setf delayed-map-fnrecord) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

fnrecord.

Reader: delayed-map-inputs (instance)
Writer: (setf delayed-map-inputs) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

inputs.

Function: delayed-map-number-of-values (delayed-map)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-map-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-multiple-value-map-fnrecord (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: (setf delayed-multiple-value-map-fnrecord) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-multiple-value-map-inputs (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: (setf delayed-multiple-value-map-inputs) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-multiple-value-map-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-multiple-value-map-refbits (instance)
Writer: (setf delayed-multiple-value-map-refbits) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

refbits.

Reader: delayed-multiple-value-map-values-ntype (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

values-ntype.

Function: delayed-nop-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-nth-value-input (instance)
Writer: (setf delayed-nth-value-input) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

input.

Reader: delayed-nth-value-number (instance)
Writer: (setf delayed-nth-value-number) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

number.

Function: delayed-nth-value-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: delayed-range-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-reshape-input (instance)
Writer: (setf delayed-reshape-input) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

input.

Function: delayed-reshape-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-reshape-transformation (instance)
Writer: (setf delayed-reshape-transformation) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

transformation.

Function: delayed-unknown-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-wait-delayed-action (instance)
Writer: (setf delayed-wait-delayed-action) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

delayed-action.

Function: delayed-wait-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: delayed-wait-request (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

request.

Function: differentiator (outputs gradients)

Returns a function that, for each node in a network whose roots are the supplied OUTPUTS will return the gradient at that node.

GRADIENTS must be a sequence of the same length as OUTPUTS, and whose elements are either arrays with or symbols that will be used as the name of such a parameter.

Package

petalisp.api.

Source

differentiator.lisp.

Function: empty-lazy-array (shape)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: empty-lazy-arrays (n shape)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: empty-range ()

Returns a range with size zero.

Package

petalisp.core.

Source

range.lisp.

Function: empty-range-p (object)
Package

petalisp.core.

Source

range.lisp.

Function: empty-shape-p (shape)

Returns whether the supplied object is a shape with zero elements, i.e., has at least one range with size zero.

Examples:

(empty-shape-p (~ 1))
=> nil

(empty-shape-p (~ 0))
=> t

(shapep (~ 1 ~ 2 ~ 3 3))
=> t

Package

petalisp.core.

Source

shape.lisp.

Function: enlarge-shape (shape range)

For a given shape S and range R, this function returns a shape whose first range is R, and whose remaining ranges are those of S.

Examples:

(enlarge-shape (~*) (range 1 10))
=> (~ 1 10)

(enlarge-shape (~ 1 3) (range 1 4))
=> (~ 1 4 ~ 1 3)

Package

petalisp.core.

Source

shape.lisp.

Function: ensure-array-buffer-compatibility (array buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: ensure-array-shape-ntype-compatibility (array shape ntype)
Package

petalisp.ir.

Source

ir.lisp.

Function: evaluator (unknowns arrays)

For a supplied list of unknowns of length N and list of LAZY-ARRAYS of length K, returns a function with K+N arguments that returns, as multiple values, the K array values obtained by computing the supplied arrays after substituting the Ith unknown with the supplied argument in position K+I.

The first N arguments specify which storage to use for the results. A
value of NIL indicates that the corresponding result shall be a fresh
array. A value that is an array ensures that the result is written to that array.

An error is signaled if any of the arguments of an evaluator has a
different shape or element type as the corresponding result or unknown.

Package

petalisp.core.

Source

backend.lisp.

Function: extended-euclid (u v)

Given nonnegative integers u and v, returns the values u1 and u3 such that u*u1 + v*u2 = u3 = gcd(u,v).

Package

petalisp.utilities.

Source

extended-euclid.lisp.

Function: flattening-reshaper ()

Returns a function that can be supplied as a modifier to LAZY-RESHAPE to turn any lazy array shape into modifiers that flatten a lazy array of that shape. A flattened lazy array has the same contents as the original one in the same lexicographical ordering, but has rank one.

Examples:

(compute (lazy-reshape #2A((1 2) (3 4)) (flattening-reshaper)))
=> #(1 2 3 4)

(compute
(lazy-reshape #3A(((1 2 3) (4 5 6)) ((7 8 9) (10 11 12))) (flattening-reshaper)))
=> #(1 2 3 4 5 6 7 8 9 10 11 12)

(compute
(lazy-reshape #3A(((1 2 3) (4 5 6)) ((7 8 9) (10 11 12))) 2 (flattening-reshaper)))
=> #2A((1 2 3) (4 5 6) (7 8 9) (10 11 12))

Package

petalisp.api.

Source

reshapers.lisp.

Function: flp2 (n)

Round the unsigned integer N down to the next smaller power of two.

Package

petalisp.utilities.

Source

powers-of-two.lisp.

Function: fuse-ranges (&rest ranges)
Package

petalisp.core.

Source

range.lisp.

Function: fuse-shapes (shape &rest more-shapes)
Package

petalisp.core.

Source

shape.lisp.

Function: graph-add-edge (graph predecessor successor weight)

Add a new, weighted edge between the two supplied graph nodes.

Package

petalisp.scheduling.

Source

scheduling.lisp.

Function: graph-ensure-node (graph object)

Returns the graph node corresponding to the supplied object, and as a secondary return value, whether that node was already present in the graph.

Package

petalisp.scheduling.

Source

scheduling.lisp.

Reader: graph-object-nodes (instance)
Writer: (setf graph-object-nodes) (instance)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Target Slot

object-nodes.

Function: graph-parallel-depth-first-schedule (graph p)

Returns a list of vectors, where each vector describes one step of the schedule. Each vector has length P, and elements that are either NIL or one of the objects that have been scheduled. The schedule ensures that each node appears later than all its predecessors, and that all entries of one vector can be executed in parallel.

This function uses the P-DFS algorithm from Blelloch, Gibbons, and
Matias (https://doi.org/10.1145/301970.301974), with some augmentations to improve data locality.

Package

petalisp.scheduling.

Source

scheduling.lisp.

Function: graphp (object)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Function: harmonized-element-type (&rest arrays)

Returns a type to which all elements of all the supplied lazy arrays can be coerced safely. If the element types of all supplied lazy arrays are number types, the resulting type is obtained by the standard rules of numeric contagion (CLHS 12.1.4.1 and CLHS 12.1.4.4). Otherwise, the resulting type is one that encompasses the union of the element types of all supplied lazy arrays.

Examples:

(harmonized-element-type 5 6.0)
=> single-float

(harmonized-element-type 5.0d0 #C(0 1))
=> (complex double-float)

(harmonized-element-type ’foo ’bar ’baz 42)
=> (not null)

Package

petalisp.api.

Source

lazy-harmonize.lisp.

Function: host-device ()
Package

petalisp.ir.

Source

device.lisp.

Function: identity-transformation (rank)

Returns an identity transformation of the specified rank.

Package

petalisp.core.

Source

transformation-constructors.lisp.

Function: identity-transformation-p (object)

Returns whether a supplied object is an identity transformation.

Examples:

(identity-transformation-p (transform i j to j i))
=> nil

(identity-transformation-p (transform i j to i j))
=> t

Package

petalisp.core.

Source

transformation.lisp.

Function: index* (&rest indices)
Package

petalisp.codegen.

Source

indexing.lisp.

Function: index+ (&rest indices)
Package

petalisp.codegen.

Source

indexing.lisp.

Function: inflate-shape (shape n)
Package

petalisp.core.

Source

shape.lisp.

Reader: instruction-inputs (instance)
Writer: (setf instruction-inputs) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

inputs.

Reader: instruction-number (instance)
Writer: (setf instruction-number) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number.

Reader: instruction-transformation (instance)
Writer: (setf instruction-transformation) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

transformation.

Function: instructionp (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: interior-buffer-p (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: ir-from-lazy-arrays (lazy-arrays &key kernel-size-threshold debug)

Returns a list of buffers that form the root of an IR data flow graph that is equivalent to the data flow graph specified by the supplied LAZY-ARRAYS.

An IR graph is consists of alternating buffers and kernels. Each kernel reads and writes from zero or more buffers and writes to zero and more buffers. The behavior or each kernel is described by a directed acyclic graph of instructions.

Package

petalisp.ir.

Source

ir-conversion.lisp.

Function: iref-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: iref-instruction-transformation (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf iref-instruction-transformation) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: iterating-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: iteration-space-blueprint (iteration-space)
Package

petalisp.codegen.

Source

blueprint.lisp.

Function: karmarkar-karp (s k &key weight)

Partition the set of objects S in k subsets such that the sums of the weights of the objects in each subset are nearly equal.

Returns a vector of length k whose elements are lists that partition S. As a second value, returns the difference between the sum of the weights of the smalles partition and that of the largest partition.

Package

petalisp.utilities.

Source

karmarkar-karp.lisp.

Function: kernel-blueprint (kernel)

Returns a utree that represents all information necessary to generate a high-performance implementation of KERNEL. Identical blueprints are EQ, which makes them ideal for caching.

Package

petalisp.codegen.

Source

blueprint.lisp.

Function: kernel-cost (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Reader: kernel-instruction-vector (instance)
Writer: (setf kernel-instruction-vector) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

instruction-vector.

Reader: kernel-iteration-space (instance)
Writer: (setf kernel-iteration-space) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

iteration-space.

Function: kernel-load-stencils (kernel buffer)
Package

petalisp.ir.

Source

ir.lisp.

Reader: kernel-number (instance)
Writer: (setf kernel-number) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number.

Function: kernel-number-of-loads (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: kernel-number-of-outputs (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: kernel-number-of-stores (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: kernel-program (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: kernel-reuse-potential (kernel)
Package

petalisp.ir.

Source

ir.lisp.

Reader: kernel-shard-iteration-space (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

iteration-space.

Reader: kernel-shard-kernel (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

kernel.

Function: kernel-shard-more-important-p (kernel-shard-1 kernel-shard-2)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: kernel-shard-p (object)
Package

petalisp.ir.

Source

partitioning.lisp.

Reader: kernel-shard-sources (instance)
Writer: (setf kernel-shard-sources) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

sources.

Reader: kernel-shard-targets (instance)
Writer: (setf kernel-shard-targets) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

targets.

Reader: kernel-sources (instance)
Writer: (setf kernel-sources) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

sources.

Function: kernel-store-stencils (kernel buffer)
Package

petalisp.ir.

Source

ir.lisp.

Reader: kernel-targets (instance)
Writer: (setf kernel-targets) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

targets.

Reader: kernel-task (instance)
Writer: (setf kernel-task) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

task.

Function: kernelp (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: lazy (function &rest arrays)

Returns a lazy array whose contents are the results of applying the supplied function element-wise to the contents of the remaining argument arrays. If the arguments don’t agree in shape, they are first broadcast with the function LAZY-BROADCAST-LIST-OF-ARRAYS.

Examples:

(compute (lazy #’*))
=> 1

(compute (lazy #’+ 2 3))
=> 5

(compute (lazy #’+ #(1 2) #(3 4)))
=> #(4 6)

(compute (lazy #’+ 2 #(1 2 3 4 5)))
=> #(3 4 5 6 7)

(compute (lazy #’* #(2 3) #2A((1 2) (3 4))))
=> #2A((2 4) (9 12))

Package

petalisp.api.

Source

lazy.lisp.

Function: lazy-array (object)

Returns a lazy array that is derived from the supplied object in the following way:

- If the supplied object is a lazy array, the result is that lazy array.

- If the supplied object is a regular array, the result is a lazy array
of the same shape, and whose indices map to the same elements.

- If the supplied object is neither a lazy array, nor a regular array, it is treated like an array of rank zero whose sole element is that supplied object.

By convention, all functions that expect an argument to be a lazy array actually accept any kind of object and use the LAZY-ARRAY function to convert that object to a lazy array. Unless user code violates this convention, scalars, regular arrays, and lazy arrays can be used interchangeably in any argument position.

Examples:

(lazy-array #2A((1 2 3) (4 5 6)))
=> #<lazy-array t (~ 2 ~ 3)>

(lazy-array #(1 2 3))
=> #<lazy-array t (~ 3)>

(lazy-array 5)
=> #<lazy-array (eql 5) (~*)>

(lazy-array (lazy-array 5))
=> #<lazy-array (eql 5) (~*)>

(lazy-array (make-array 2 :element-type ’double-float :initial-element 0.0d0)) => #<lazy-array double-float (~ 2)>

Package

petalisp.core.

Source

lazy-array.lisp.

Reader: lazy-array-delayed-action (instance)
Writer: (setf lazy-array-delayed-action) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

delayed-action.

Reader: lazy-array-depth (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

depth.

Function: lazy-array-dimension (lazy-array axis)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-dimensions (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-element-type (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-from-array (array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-from-range (range)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-from-scalar (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-inputs (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: lazy-array-ntype (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

ntype.

Function: lazy-array-p (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-range (lazy-array axis)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-ranges (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-array-rank (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Reader: lazy-array-refcount (instance)
Writer: (setf lazy-array-refcount) (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

refcount.

Reader: lazy-array-shape (instance)
Package

petalisp.core.

Source

lazy-array.lisp.

Target Slot

shape.

Function: lazy-array-size (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-broadcast (&rest arrays)
Package

petalisp.api.

Source

lazy-broadcast.lisp.

Function: lazy-broadcast-list-of-arrays (list-of-arrays)

Returns a list of lazy arrays of the same shape, where each lazy array is a broadcasting reference to the corresponding element of the supplied list of arrays. As a second value, returns the shape of all the resulting lazy arrays. Signals an error if there is no suitable shape to which all the supplied arrays can be broadcast.

The resulting shape is constructed according to the following rules:

1. The rank of the resulting shape is the maximum of the rank of all the supplied arrays.

2. Each range of any of the supplied arrays must either have a size of one, or it must be equal to the range of the resulting shape in the same axis.

3. In case there is an axis in which all supplied arrays have a range with only a single element, the resulting shape uses the range of the first supplied array.

Examples:

(lazy-broadcast-list-of-arrays (list #(1 2 3) 5))
=> (#<lazy-array t (~ 3)> #<lazy-array (eql 5) (~ 3)>)
=> (~ 3)

(apply #’compute (lazy-broadcast-list-of-arrays (list #(1 2 3) 5)))
=> #(1 2 3)
=> #(5 5 5)

(apply #’compute (lazy-broadcast-list-of-arrays (list #(1 2 3) #(5)))) => #(1 2 3)
=> #(5 5 5)

(apply #’compute
(lazy-broadcast-list-of-arrays (list #2A((1 2) (3 4)) #(7 8)))) => #2A((1 2) (3 4))
=> #2A((7 7) (8 8))

Package

petalisp.api.

Source

lazy-broadcast.lisp.

Function: lazy-drop-axes (array &rest axes)

Returns a lazy array with the same contents as the supplied array, but whose shape has all ranges referred to by the supplied axes removed. All of the ranges being referred to must have a size of one.

Examples:

(lazy-drop-axes (lazy-reshape 1 (~ 1 2 ~ 2 3)) 1)
=> #<lazy-array (eql 1) (~ 1 2)>

(compute (lazy-drop-axes (lazy-reshape 1 (~ 1 2 ~ 2 3)) 1))
=> #*1

(compute (lazy-drop-axes (lazy-reshape 1 (~ 1 2 ~ 2 3)) 0 1))
=> 1

(compute (lazy-drop-axes (lazy-reshape 1 (~ 1 2 ~ 2 5)) 0))
=> #*111

Package

petalisp.api.

Source

lazy-drop-axes.lisp.

Function: lazy-fuse (array &rest more-arrays)

Returns a lazy array that is a combination of all the values of all the supplied arrays. Signals an error if any of the supplied arrays overlap, don’t have the same rank, or if the union of all their shapes cannot be represented as a shape.

Examples:

(compute (lazy-fuse (lazy-reshape 1 (~ 0 2)) (lazy-reshape 2 (~ 2 4)))) => #(1 1 2 2)

(compute (lazy-fuse (lazy-reshape 1 (~ 0 7 2)) (lazy-reshape 2 (~ 1 7 2)))) => #(1 2 1 2 1 2 1)

(compute
(lazy-fuse (lazy-reshape 1 (~ 0 2 ~ 0 2)) (lazy-reshape 2 (~ 0 2 ~ 2 4)) (lazy-reshape 3 (~ 2 4 ~ 0 2)) (lazy-reshape 4 (~ 2 4 ~ 2 4)))) => #2A((1 1 2 2) (1 1 2 2) (3 3 4 4) (3 3 4 4))

Package

petalisp.core.

Source

lazy-fuse.lisp.

Function: lazy-fuse-and-harmonize (array &rest more-arrays)

Returns the result of first harmonizing all the supplied arrays, and then passing them to LAZY-FUSE.

Package

petalisp.api.

Source

lazy-harmonize.lisp.

Function: lazy-harmonize (&rest arrays)

Lazily coerce each of the supplied arrays to the common harmonized element type, and return the resulting lazy arrays as multiple values.

Example:

(multiple-value-call #’compute (lazy-harmonize 5 6.0))
=> 5.0
=> 6.0

Package

petalisp.api.

Source

lazy-harmonize.lisp.

Function: lazy-harmonize-list-of-arrays (arrays)

Lazily coerce each array in the supplied list of arrays to the common harmonized element type, and return a list of the resulting lazy arrays.

Example:

(apply #’compute (lazy-harmonize-list-of-arrays (list 5 6.0)))
=> 5.0
=> 6.0

Package

petalisp.api.

Source

lazy-harmonize.lisp.

Function: lazy-index-components (shape-designator &optional axis)

Returns a lazy array containing the index components of the designated shape in the supplied axis. If the first argument is not a shape, the function SHAPE-DESIGNATOR-SHAPE is used to convert it a shape. If no axis is not supplied, it defaults to zero.

Examples:

(compute (lazy-index-components (~ 9)))
=> #(0 1 2 3 4 5 6 7 8)

(compute (lazy-index-components (~ 0 4 2 ~ 1 5 2) 0))
=> #2A((0 0) (2 2))

(compute (lazy-index-components (~ 0 4 2 ~ 1 5 2) 1))
=> #2A((1 3) (1 3))

(compute (lazy-index-components #2A((1 2) (3 4))))
=> #2A((0 0) (1 1))

(compute (lazy-index-components #2A((1 2) (3 4)) 1))
=> #2A((0 1) (0 1))

Package

petalisp.api.

Source

lazy-index-components.lisp.

Function: lazy-map (function inputs)
Package

petalisp.core.

Source

lazy-map.lisp.

Function: lazy-multiple-value (n-values function &rest arrays)

Returns as many lazy arrays as indicated by the integer that is the first supplied argument, whose contents are the results of applying the function that is the second supplied argument element-wise to the contents of the remaining argument arrays. If the arguments don’t agree in shape, they are first broadcast with the function LAZY-BROADCAST-LIST-OF-ARRAYS.

Examples:

(multiple-value-call #’compute (lazy-multiple-value 0 #’*))

(multiple-value-call #’compute (lazy-multiple-value 1 #’*))
=> 1

(multiple-value-call #’compute (lazy-multiple-value 2 #’*))
=> 1
=> nil

(multiple-value-call #’compute
(lazy-multiple-value 2 #’floor #(2 3) #2A((1 2) (3 4))))
=> #2A((2 1) (1 0))
=> #2A((0 0) (0 3))

(multiple-value-call #’compute
(lazy-multiple-value 3 #’values-list #((1 2 3) (4 5 6))))
=> #(1 4)
=> #(2 5)
=> #(3 6)

Package

petalisp.api.

Source

lazy-multiple-value.lisp.

Function: lazy-multiple-value-map (n-outputs function inputs)
Package

petalisp.core.

Source

lazy-map.lisp.

Function: lazy-multireduce (number-of-axes function &rest arrays)

Returns the lazy array obtained by repeatedly invoking LAZY-REDUCE as often as indicated by the supplied first argument. The remaining arguments are the function to be used for the reduction and a number of lazy arrays that are broadcast and reduced along their first axes.

Examples:

(compute (lazy-multireduce 0 #’+ #2A((1 2) (3 4))))
=> #2A((1 2) (3 4))

(compute (lazy-multireduce 1 #’+ #2A((1 2) (3 4))))
=> #(4 6)

(compute (lazy-multireduce 2 #’+ #2A((1 2) (3 4))))
=> 10

Package

petalisp.api.

Source

lazy-multireduce.lisp.

Function: lazy-overwrite (array &rest more-arrays)

Returns a lazy array that is a combination of all the values of all the supplied arrays. If any of the supplied arrays overlap at some index, the value of the result in that index is that of the rightmost array containing that index. Signals an error unless all the supplied arrays have the same rank, or if the union of all their shapes cannot be represented as a shape.

Examples:

(compute (lazy-overwrite (lazy-reshape 1 (~ 0 4)) (lazy-reshape 2 (~ 2 4)))) => #(1 1 2 2)

(compute
(lazy-overwrite (lazy-reshape 1 (~ 3 ~ 3)) (lazy-reshape 2 (~ 1 2 ~ 1 2)))) => #2A((1 1 1) (1 2 1) (1 1 1))

Package

petalisp.api.

Source

lazy-overwrite.lisp.

Function: lazy-overwrite-and-harmonize (array &rest more-arrays)

Returns the result of first harmonizing all the supplied arrays, and then passing them to LAZY-OVERWRITE.

Package

petalisp.api.

Source

lazy-harmonize.lisp.

Function: lazy-reduce (function &rest arrays)

Returns one or more lazy arrays whose contents are the multiple value reduction with the supplied function, when applied pairwise to the elements of the first axis of each of the supplied arrays. If the supplied arrays don’t agree in shape, they are first broadcast with the function BROADCAST-ARRAYS.

The supplied function F must accept 2k arguments and return k values, where k is the number of supplied arrays. All supplied arrays must have the same shape S, which is the cartesian product of some ranges, i.e., S = r_1 x ... r_n, where each range r_k is a set of integers, e.g., {0, 1, ..., m}. Then β returns k arrays of shape s = r_2 x ... x r_n, whose elements are a combination of the elements along the first axis of each array according to the following rules:

1. If the given arrays are empty, return k empty arrays.

2. If the first axis of each given array contains exactly one element, drop that axis and return arrays with the same content, but with shape s.

3. If the first axis of each given array contains more than one element, partition the indices of this axis into a lower half l and an upper half u. Then split each given array into a part with shape l x s and a part with shape u x s. Recursively process the lower and the upper halves of each array independently to obtain 2k new arrays of shape s. Finally, combine these 2k arrays element-wise with f to obtain k new arrays with all values returned by f. Return these arrays.

Examples:

(compute (lazy-reduce #’+ #(1 2 3 4)))
=> 10

(compute (lazy-reduce #’+ #2A((1 2) (3 4))))
=> #(4 6)

(let ((a #(5 2 7 1 9)))
(multiple-value-bind (max index)
(lazy-reduce
(lambda (lv li rv ri)
(if (> lv rv)
(values lv li)
(values rv ri)))
a (lazy-index-components a 0))
(compute max index)))
=> 9
=> 4

Package

petalisp.api.

Source

lazy-reduce.lisp.

Function: lazy-ref (input shape transformation)
Package

petalisp.core.

Source

lazy-ref.lisp.

Function: lazy-reshape (array &rest modifiers)

Returns the lazy array that is obtained by successively reshaping the supplied array with the supplied modifiers in left-to-right order. There are four kinds of modifiers: Integers that express an increase or decrease in the number of active axes, transformations that describe a reordering of values, functions which are applied to the shape consisting of all active axes to obtain additional modifiers, and shape designators that describe a selection, move, or broadcasting of values, depending on whether the designated shape has fewer, equal, or more elements than the active axes of the current lazy array.

More precisely, the processing maintains a lazy array L that is initialized to the result of applying LAZY-ARRAY constructor to the supplied first argument, a number of active ranges K that initialized to the rank of L. For each modifier, L and K are updated while maintaining the invariant that K is less than or equal to the rank of L. The rules for updating L and K are as follows:

1. If the modifier is a non-negative integer N, compare it with the number of active ranges K. If N is less than or equal to K, set K to N and leave L as it is. Otherwise, if N is larger than K, create a new lazy array with the same contents as L, whose shape starts with N minus K ranges that only contain the integer zero, followed by the ranges of L. Then, set L to that newly created lazy array, and set K to N.

2. If the modifier is an invertible transformation with input rank M (which must be less than the number of active ranges K) and output rank N, extend the transformation with trailing identity mappings such that it has an input rank equal to the rank of L. Create a new lazy array by reordering L with that extended transformation. Set L to that newly created lazy array, and K to N.

3. If the modifier is a function, apply it to the shape consisting of the first K ranges of L to obtain a number of new modifiers as multiple values. Process the new modifiers as if they were supplied instead of this function modifier.

4. If the modifier is a shape designator, compare the designated shape M with the shape S that consists of the first K ranges of L, and chose one of the following rules to update L and K.

a) If the shape M has rank K and denotes a strict subset of S, create a new lazy array whose first N ranges are equal to those of M, whose remaining ranges are equal to the corresponding ones of L, and where each index maps to the same value as L. Then, set L to that newly created lazy array.

b) If the shape M has the same number of elements as S, create a new lazy array with the same contents and the same lexicographical ordering as L, whose shape consists of the ranges of M followed by all but the first K ranges of L. Then, set L to that newly created lazy array, and set K to the rank of M.

c) If the shape M has more elements than the current shape, create a new lazy array that is a broadcasting reference to L, whose shape consists of the ranges of M, followed by all but the first K ranges of L. Then, set L to the newly created lazy array, and set K to the rank of M.

The result of this function is the final value of the lazy array L after processing all modifiers.

Examples:

(compute (lazy-reshape #(1 2 3 4 5 6) (~ 1 5)))
=> #(2 3 4 5)

(compute (lazy-reshape #(1 2 3 4 5 6) (~ 2 ~ 3)))
=> #2A((1 2 3) (4 5 6))

(compute (lazy-reshape #(1 2 3 4 5 6) (~ 6 ~ 2)))
=> #2A((1 1) (2 2) (3 3) (4 4) (5 5) (6 6))

(compute (lazy-reshape #(1 2 3 4) (transform i to (- i))))
=> #(4 3 2 1)

(compute (lazy-reshape #(1 2 3 4) (transform i to (- i)) (~ -2 0)))
=> #(3 2)

(compute (lazy-reshape #2A((1 2) (3 4)) (transform i j to j i)))
=> #2A((1 3) (2 4))

(compute (lazy-reshape #2A((1 2) (3 4)) 1 (~ 2 ~ 2)))
=> #3A(((1 2) (1 2)) ((3 4) (3 4)))

(compute (lazy-reshape #(1 2 3) 0 1))
=> #2A((1 2 3))

(compute (lazy-reshape #2A((1 2) (3 4)) (lambda (s) (~ (shape-size s))))) => #(1 2 3 4)

Package

petalisp.core.

Source

lazy-reshape.lisp.

Function: lazy-reshape-using-transformation (lazy-array transformation)
Package

petalisp.core.

Source

lazy-ref.lisp.

Function: lazy-slice (array index &optional axis)

Returns a lazy array whose rank is one less than the rank of the supplied array, and that contains all entries of the supplied array whose index component is equal to the supplied index in the optionally supplied axis. If the axis is not supplied, it defaults to zero.

Examples:

(compute (lazy-slice #(1 2 3 4) 2))
=> 3

(compute (lazy-slice #2A((1 2) (3 4)) 0))
=> #(1 2)

(compute (lazy-slice #2A((1 2) (3 4)) 1))
=> #(3 4)

(compute (lazy-slice #2A((1 2) (3 4)) 0 1))
=> #(1 3)

(compute (lazy-slice #2A((1 2) (3 4)) 1 1))
=> #(2 4)

Package

petalisp.api.

Source

lazy-slice.lisp.

Function: lazy-slices (array range &optional axis)

Returns a lazy array containing all those elements of the supplied array whose index components in the optionally supplied axis are contained in the supplied range. If the axis is not supplied, it defaults to zero. The resulting array has the same shape as the supplied array, except that its range in the axis being sliced along is the supplied range. Signals an error if the supplied range is not fully contained in the original range of that axis.

Examples:

(compute (lazy-slices #(1 2 3 4) (range 0 3 2)))
=> #(1 3)

(compute (lazy-slices #2A((1 0 0) (0 1 0) (0 0 1)) (range 2)))
=> #2A((1 0 0) (0 1 0))

(compute (lazy-slices #2A((1 0 0) (0 1 0) (0 0 1)) (range 0 3 2)))
=> #2A((1 0 0) (0 0 1))

(compute (lazy-slices #2A((1 0 0) (0 1 0) (0 0 1)) (range 0 3 2) 1)) => #2A((1 0) (0 0) (0 1))

Package

petalisp.api.

Source

lazy-slices.lisp.

Function: lazy-sort (array predicate)

Returns a lazy array containing the elements of the supplied array, but sorted along the first axis with the supplied predicate.

Examples:

(compute (lazy-sort #(1 3 7 5 0 6 4 9 8 2) #’<))
=> #(0 1 2 3 4 5 6 7 8 9)

(compute (lazy-sort "Sphinx of black quartz, judge my vow." #’char-lessp)) => " ,.aabcdefghijklmnoopqrStuuvwxyz"

(compute (lazy-sort #2A((9 8 7) (6 5 4) (3 2 1)) #’<))
=> #2A((3 2 1) (6 5 4) (9 8 7))

Package

petalisp.api.

Source

lazy-sort.lisp.

Function: lazy-stack (axis array &rest more-arrays)

Returns a lazy array whose contents are the supplied arrays, stacked next to each other along the specified AXIS such that the leftmost array will have the lowest index components, and the rightmost array will have the highest index components.

The supplied arrays must all have the same rank, and also the same ranges in all but the one axis that is being stacked along. The range of the resulting lazy array in that axis that is being stacked along has the same start as the leftmost corresponding argument range that is non-empty, a size that is the sum of the sizes of all corresponding ranges, and a step size is that of the leftmost corresponding argument range that has more than one element, or one if there is no such range. Signals an error if multiple arguments have a range with more than one element but differing step sizes in the axis being stacked along.

Examples:

(compute (lazy-stack 0 #(1) #(2) #(3)))
=> #(1 2 3)

(compute (lazy-stack 0 #(1 2) #(3 4) #(5 6)))
=> #(1 2 3 4 5 6)

(compute (lazy-stack 0 #2A((1 2) (3 4)) #2A((5 6) (7 8))))
=> #2A((1 2) (3 4) (5 6) (7 8))

(compute (lazy-stack 1 #2A((1 2) (3 4)) #2A((5 6) (7 8))))
=> #2A((1 2 5 6) (3 4 7 8))

Package

petalisp.api.

Source

lazy-stack.lisp.

Function: lazy-unknown-p (lazy-array)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: lazy-unknowns (graph-roots)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: leaf-buffer-p (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: load-foreign-code (source-code &key compiler language standard flags)
Package

petalisp.codegen.

Source

load-foreign-code.lisp.

Function: load-instruction-buffer (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf load-instruction-buffer) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: load-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: load-instruction-transformation (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf load-instruction-transformation) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: load-or-store-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-array-from-shape-and-ntype (shape ntype)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-buffer (&key shape ntype depth writers readers task storage number)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-buffer-like-array (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-cgraph (&key table)
Package

petalisp.utilities.

Source

graph-coloring.lisp.

Function: make-cqueue ()
Package

petalisp.cqueue.

Source

cqueue.lisp.

Function: make-delayed-array (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: make-graph (&key object-nodes)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Function: make-ir-backend (&key mode)
Package

petalisp.codegen.

Source

ir-backend.lisp.

Function: make-kernel (&key iteration-space sources targets instruction-vector task data number)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-kernel-lambda (client bpinfo body)
Package

petalisp.codegen.

Source

lisp-compiler.lisp.

Function: make-native-backend (&key threads debug)
Package

petalisp.native-backend.

Source

backend.lisp.

Function: make-network (&rest outputs)

Creates a network with the supplied inputs and outputs.

An error is signaled of any of the inputs is not of type NETWORK-INPUT, or if additional network inputs are reachable from the network outputs.

Package

petalisp.api.

Source

network.lisp.

Function: make-program (&key initial-task final-task leaf-alist root-buffers task-vector number-of-buffers number-of-kernels)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-rank-zero-array (value)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: make-reference-backend ()
Package

petalisp.core.

Source

reference-backend.lisp.

Function: make-shape (ranges)

Returns a shape whose axes are determined by the supplied list of ranges.

Package

petalisp.core.

Source

shape.lisp.

Function: make-shape-table ()
Package

petalisp.core.

Source

shape.lisp.

Function: make-stencil (instructions)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-task (&key program predecessors successors kernels defined-buffers number)
Package

petalisp.ir.

Source

ir.lisp.

Function: make-testing-backend ()
Package

petalisp.test-suite.

Source

testing-backend.lisp.

Function: make-transformation (&key input-rank output-rank input-mask output-mask scalings offsets)

Returns a transformation that is created according to the supplied keyword arguments. Valid keyword arguments are:

- :INPUT-RANK A non-negative integer that is the rank of any valid index or shape supplied to this transformation. Defaults to the length of the supplied input mask, or, if no input mask is supplied, to the default value of the output rank. Signals an error if neither the input rank or the output rank can be derived in any way.

- :OUTPUT-RANK A non-negative integer that is the rank of any valid index or shape supplied to this transformation. Defaults to the length of the supplied scalings, offsets, or output mask, or, if none of these are supplied, to the default value of the input rank. Signals an error if neither the input rank or the output rank can be derived in any way.

- :INPUT-MASK A sequence with one element per axis of the transformation’s input. Each element must either be an integer, in which case only this integer may occur in the corresponding axis of the input, or NIL, in which case any integer may occur in the corresponding axis.

- :OUTPUT-MASK A sequence with one element per axis of the transformation’s output. Each element must either be an integer, in which case this integer denotes the axis of the input that is to be scaled, shifted and sent to the current position’s output, or NIL, in which case only the corresponding offset value is sent to the current output. This way, the output mask can encode both permutations of the input, as well as insertion and removal of axes. If this keyword argument is not supplied, it defaults to a sequence of consecutive integers as long as the minimum of the input rank and the output rank, followed by entries of NIL in case the output rank exceeds the input rank.

- :SCALINGS A sequence with one element per axis of the transformation’s output. Each element must be a rational number. Every transformation output is the input denoted by the output mask, scaled with its corresponding entry in this sequence, and then added to the corresponding offset. In case of an output mask entry of NIL, the corresponding scaling is ignored and the offset of that output axis is returned as is. If this keyword argument is not supplied, it defaults to a sequence of ones.

- :OFFSETS A sequence with one element per axis of the transformation’s output. Each element must be a rational number that is added to the corresponding output value after scaling has taken place. If this keyword argument is not supplied, it defaults to a sequence of zeros.

Signals an error if some of the sequences supplied as :OUTPUT-MASK, :SCALINGS, or :OFFSETS differ in length.

Examples:

(make-transformation :input-rank 2)
=> (transform a b to a b)

(make-transformation :input-rank 2 :output-rank 1)
=> (transform a b to a)

(make-transformation :input-mask ’(2 nil 3))
=> (transform 2 b 3 to 2 b 3)

(make-transformation :output-mask #(1 0 nil))
=> (transform a b c to b a 0)

(make-transformation :offsets #(1 2 3) :scalings #(4 5 6))
=> (transform a b c to (1+ (* 4 a)) (+ (* 5 b) 2) (+ (* 6 c) 3))

Package

petalisp.core.

Source

transformation-constructors.lisp.

Function: make-unknown (&key shape element-type)

Returns a lazy array whose contents are not known and consequently cannot be computed. Lazy arrays depending on such an array also cannot be computed. The main
purpose such unknown lazy arrays is to construct the arguments to the
EVALUATOR function.

Examples:

(make-unknown :shape (~ 5 ~ 5))
=> #<lazy-array t (~ 5 ~ 5)>

(make-unknown :element-type ’double-float)
=> #<lazy-array double-float (~*)>

Package

petalisp.core.

Source

lazy-array.lisp.

Function: map-buffer-inputs (function buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-buffer-load-instructions (function buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-buffer-outputs (function buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-buffer-store-instructions (function buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-buffers (function root-buffers)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-buffers-and-kernels (buffer-fn kernel-fn root-buffers)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-instruction-inputs (function instruction)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-inputs (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-instructions (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-load-instructions (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-outputs (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-stencils (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernel-store-instructions (function kernel)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-kernels (function root-buffers)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-program-buffer-groups (function program)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-program-buffers (function program)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-program-kernels (function program)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-program-tasks (function program)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-range (function range)

Takes a function and a range and applies the function to all integers of that range, in ascending order. Returns the range being mapped over.

Example:

(let ((l ’nil))
(map-range (lambda (i) (push i l)) (range 1 9 2))
(nreverse l))
=> (1 3 5 7)

Package

petalisp.core.

Source

range.lisp.

Function: map-shape (function shape)

Takes a function and a shape and applies the function to all integer tuples of that range, in ascending order.

Example:

(let ((l ’nil))
(map-shape (lambda (i) (push i l)) (~ 1 3 ~ 3 5))
(nreverse l))
=> ((1 3) (2 3) (1 4) (2 4))

Package

petalisp.core.

Source

shape.lisp.

Function: map-stencil-instructions (function stencil)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-task-defined-buffers (function task)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-task-kernels (function task)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-task-predecessors (function task)
Package

petalisp.ir.

Source

ir.lisp.

Function: map-task-successors (function task)
Package

petalisp.ir.

Source

ir.lisp.

Function: move-axis-to-front (array axis)
Package

petalisp.core.

Source

differentiator.lisp.

Reader: node-depth (instance)
Writer: (setf node-depth) (instance)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Target Slot

depth.

Reader: node-height (instance)
Writer: (setf node-height) (instance)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Target Slot

height.

Reader: node-predecessor-alist (instance)
Writer: (setf node-predecessor-alist) (instance)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Target Slot

predecessor-alist.

Reader: node-successor-alist (instance)
Writer: (setf node-successor-alist) (instance)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Target Slot

successor-alist.

Function: nodep (object)
Package

petalisp.scheduling.

Source

scheduling.lisp.

Function: non-empty-range-p (object)
Package

petalisp.core.

Source

range.lisp.

Function: normalizing-transformation (shape)
Package

petalisp.core.

Source

transformation-constructors.lisp.

Function: number-of-cpus ()
Package

petalisp.utilities.

Source

number-of-cpus.lisp.

Function: partition-program (program &key split-priority split-min-priority split-max-redundancy split-max-imbalance debug)

Partition all buffers and kernels in the supplied program into shards. Returns, as multiple values, a vector mapping each buffer to its corresponding primogenitor buffer shard, a vector mapping each kernel to its corresponding primogenitor kernel shard, and a vector mapping each buffer to its corresponding ghostspec.

SPLIT-PRIORITY - A function that takes a buffer shard and returns an unsigned integer that is the priority when considering whether to split that buffer shard. Buffer shards with higher priority are split first, and buffer shards whose priority is below a certain minimum priority are not split at all.

SPLIT-MIN-PRIORITY - An unsigned integer that is the priority a buffer shard must exceed to be considered for splitting.

SPLIT-MAX-REDUNDANCY - A real number that is the maximum permissible ratio of ghost points to interior points for a split.

Package

petalisp.ir.

Source

partitioning.lisp.

Function: peeling-reshaper (&key layers lower-layers upper-layers strides)

Returns a function that can be supplied as modifier to LAZY-RESHAPE to turn any lazy array shape into modifiers that select certain interior points of that shape. The nature of this function is determined by the four keyword arguments :LAYERS, :LOWER-LAYERS, :UPPER-LAYERS, and :STRIDES. Each of these keyword arguments can be a non-negative integer, in which case it applies to each axis of the lazy array being reshaped, or it can be a sequence of non-negative integers, in which case each element of that sequence applies only to the corresponding axis.

The :LOWER-LAYERS keyword argument describes how many of the lowest integers in each range are to be peeled off, and the :UPPER-LAYERS keyword argument describes how many of the highest integers in each range are to be peeled off. The :LAYERS keyword argument, which defaults to zero, describes the default values for both of the lower and upper layers when they aren’t specified explicitly. The :STRIDES keyword argument, which defaults to one, denotes a factor for scaling the original step size of each range, such that a stride of K means selecting only every Kth element.

The resulting function signals an error if an attempt is made to peel more layers from a lazy array than the size of the range in that axis.

Examples:

(compute
(lazy-reshape #2A((1 2 3) (4 5 6) (7 8 9)) (peeling-reshaper :layers 1))) => #2A((5))

(compute
(lazy-reshape #2A((1 2 3) (4 5 6) (7 8 9))
(peeling-reshaper :lower-layers 1)))
=> #2A((5 6) (8 9))

(compute
(lazy-reshape #2A((1 2 3) (4 5 6) (7 8 9))
(peeling-reshaper :upper-layers 1)))
=> #2A((1 2) (4 5))

(compute
(lazy-reshape #2A((1 2 3) (4 5 6) (7 8 9))
(peeling-reshaper :lower-layers ’(0 2))))
=> #2A((3) (6) (9))

Package

petalisp.api.

Source

reshapers.lisp.

Function: permuting-reshaper (&rest indices)

Returns a function that can be supplied as a modifier to LAZY-RESHAPE to turn any lazy array shape into a permuting transformation. The supplied arguments must be non-negative integers that denote the ordering of axes that is established by that transformation.

Examples:

(compute (lazy-reshape #2A((1 2) (3 4)) (permuting-reshaper 1 0))) => #2A((1 3) (2 4))

(compute
(lazy-reshape #3A(((1 2 3) (4 5 6)) ((7 8 9) (10 11 12))) (permuting-reshaper 0 2 1)))
=> #3A(((1 4) (2 5) (3 6)) ((7 10) (8 11) (9 12)))

(compute
(lazy-reshape #3A(((1 2 3) (4 5 6)) ((7 8 9) (10 11 12))) (permuting-reshaper 2 0 1)))
=> #3A(((1 4) (7 10)) ((2 5) (8 11)) ((3 6) (9 12)))

Package

petalisp.api.

Source

reshapers.lisp.

Function: prime-factors (integer)

Return the list of prime factors of INTEGER in ascending order.

Package

petalisp.utilities.

Source

prime-factors.lisp.

Function: primep (n)
Package

petalisp.utilities.

Source

prime-factors.lisp.

Function: program-buffer (program buffer-number)
Package

petalisp.ir.

Source

ir.lisp.

Reader: program-final-task (instance)
Writer: (setf program-final-task) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

final-task.

Function: program-from-lazy-arrays (lazy-arrays &key kernel-size-threshold debug)
Package

petalisp.ir.

Source

ir-conversion.lisp.

Reader: program-initial-task (instance)
Writer: (setf program-initial-task) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

initial-task.

Function: program-kernel (program kernel-number)
Package

petalisp.ir.

Source

ir.lisp.

Reader: program-leaf-alist (instance)
Writer: (setf program-leaf-alist) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

leaf-alist.

Reader: program-number-of-buffers (instance)
Writer: (setf program-number-of-buffers) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number-of-buffers.

Reader: program-number-of-kernels (instance)
Writer: (setf program-number-of-kernels) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number-of-kernels.

Function: program-number-of-tasks (program)
Package

petalisp.ir.

Source

ir.lisp.

Reader: program-root-buffers (instance)
Writer: (setf program-root-buffers) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

root-buffers.

Reader: program-task-vector (instance)
Writer: (setf program-task-vector) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

task-vector.

Function: programp (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: range (first &optional end step)

Returns a new, normalized range from the supplied parameters.

This function can be invoked with one, two or three integers. If it is called with a single argument, the result is a range starting from zero, with step size one, up to but excluding the supplied argument. In other words, a single argument is treated just like one of the dimensions of a regular array. If the range constructor is called with two arguments, then the result is still a range with a step size of one, but with the first argument as the inclusive lower bound, and with the second argument as the exclusive upper bound. The three argument version behaves just like the two argument version, except that the additional third argument denotes the step size. The sign of the step size gives the direction of the range: If the sign is positive, then the exclusive upper bound must be larger than the inclusive lower bound or the resulting range is empty. If the sign is negative, the first argument is used as an inclusive upper bound, and the second argument is used as an exclusive lower bound.

It is worth mentioning that the range constructor has the exact same name and semantics as the range constructor in the Python programming language.

Examples:

(range 5)
=> #<range(0 ... 4)>

(range 5 9)
=> #<range(5 6 7 8)>

(range 5 13 2)
=> #<range(5 7 9 11)>

(range 5 14 2)
=> #<range(5 7 ... 13)>

(range 1 7 -2)
=> #<empty-range>

(range 7 1 -2)
=> #<range(3 5 7)>

Package

petalisp.core.

Source

range.lisp.

Function: range-contains (range integer)

Returns whether the supplied range contains a particular integer.

Examples:

(range-contains (range 1 10) 5)
=> t

(range-contains (range 1 10) -5)
=> nil

(range-contains (range 1 10 3) 4)
=> t

Package

petalisp.core.

Source

range.lisp.

Function: range-difference-list (range1 range2)

Compute the difference of the two supplied ranges RANGE1 and RANGE2. Returns a list of disjoint subranges of RANGE1 that describe exactly those integers appearing in RANGE1 but not in RANGE2.

Package

petalisp.core.

Source

range.lisp.

Function: range-end (range)

Returns an integer that is larger than any integer in the supplied range. An error is signaled in case the range has zero elements.

Package

petalisp.core.

Source

range.lisp.

Function: range-intersection (range1 range2)

Returns the range containing exactly those elements that occur in both supplied ranges..

Examples:

(range-intersection (range 1 10) (range 2 20))
=> #<range(2 ... 9)>

(range-intersection (range 3 14 2) (range 1 14 3))
=> #<range(7 13)>

Package

petalisp.core.

Source

range.lisp.

Function: range-intersectionp (range1 range2)

Returns whether two supplied ranges have at least one common element.

Examples:

(range-intersectionp (range 1 10) (range 2 20))
=> t

(range-intersectionp (range 0 7 2) (range 1 8 2))
=> nil

Package

petalisp.core.

Source

range.lisp.

Function: range-last (range)

Returns the highest integer contained in the supplied range. An error is signaled in case the range has zero elements.

Package

petalisp.core.

Source

range.lisp.

Reader: range-size (instance)

Returns the number of elements in the supplied range.

Package

petalisp.core.

Source

range.lisp.

Target Slot

size.

Reader: range-start (instance)

Returns the lowest integer contained in the supplied range. An error is signaled in case the range has zero elements.

Package

petalisp.core.

Source

range.lisp.

Target Slot

start.

Reader: range-step (instance)

Returns the difference between any two successive integers in the supplied range. An error is signaled in case the range has zero elements.

Package

petalisp.core.

Source

range.lisp.

Target Slot

step.

Function: range= (range1 range2)

Returns whether two supplied ranges describe the same set of integers.

Examples:

(range= (range 1) (range 2))
=> nil

(range= (range 2) (range 2))
=> t

(range= (range 0 8 2) (range 0 9 2))
=> nil

(range= (range 0 8 3) (range 0 9 3))
=> t

Package

petalisp.core.

Source

range.lisp.

Function: rangep (object)

Returns whether a supplied object is a range.

Examples:

(rangep 42)
=> nil

(rangep (range 1 3 2))
=> t

Package

petalisp.core.

Source

range.lisp.

Function: remove-shape-table-entry (shape-table shape)
Package

petalisp.core.

Source

shape.lisp.

Function: reuse-optimizing-transformation (reuse-potential)

Takes a vector of single-precision floating-point numbers that describes the potential for memory reuse along each axis, returns a transformation that sorts all axes by increasing reuse potential.

Package

petalisp.ir.

Source

ir.lisp.

Function: root-buffer-p (buffer)
Package

petalisp.ir.

Source

ir.lisp.

Function: run-petalisp-test-suite ()
Package

petalisp.test-suite.

Source

run-petalisp-test-suite.lisp.

Function: run-tests (&rest tests)
Package

petalisp.test-suite.

Source

run-petalisp-test-suite.lisp.

Function: shape-contains (shape index)

Returns whether the supplied shape contains the index denoted by the supplied list of integers.

Examples:

(shape-contains (~ 1 9) (list 4))
=> t

(shape-contains (~ 1 2 9) (list 4))
=> nil

Package

petalisp.core.

Source

shape.lisp.

Function: shape-difference-list (shape1 shape2)

Computes the difference of two shapes S1 and S2. Returns a list of disjoint subshapes of S1 that describe exactly those integer tuples appearing in S1 but not in S2.

Examples:

(shape-difference-list (~ 1 11) (~ 2 10))
=> ((~ 1 2) (~ 10 11))

(shape-difference-list (~ 1 11) (~ 4 8))
=> ((~ 1 4) (~ 8 11))

(shape-difference-list (~ 1 11) (~ 2 9 2))
=> ((~ 1 10 2) (~ 10 11))

(shape-difference-list (~ 1 11) (~ 2 21))
=> ((~ 1 2))

(shape-difference-list (~ 1 21 2) (~ 1 21 3))
=> ((~ 3 16 6) (~ 5 18 6))

Package

petalisp.core.

Source

shape.lisp.

Function: shape-dimension (shape axis)
Package

petalisp.core.

Source

shape.lisp.

Function: shape-dimensions (shape)

Return the array dimensions corresponding to a shape. Signal an error if any of the ranges of the shape have a nonzero start or a step size other than one.

Examples:

(shape-dimensions (~*))
=> nil

(shape-dimensions (~ 0 9))
=> (9)

(shape-dimensions (~ 1 9))
=> (8)

(shape-dimensions (~ 0 2 9))
=> (1)

(shape-dimensions (~ 0 4 ~ 0 5 ~ 0 6))
=> (4 5 6)

Package

petalisp.core.

Source

shape.lisp.

Function: shape-intersection (shape1 shape2)

Returns the shape whose ranges are the RANGE-INTERSECTION of each pair of ranges of the two supplied shapes. Signals an error if the supplied shapes don’t have the same rank.

Examples:

(shape-intersection (~ 1 11 ~ 3 14 2) (~ 1 6 ~ 1 14 3))
=> (~ 1 6 ~ 7 14 6)

(shape-intersection (~ 1 6) (~ 6 11))
=> (~ 0)

Package

petalisp.core.

Source

shape.lisp.

Function: shape-intersectionp (shape1 shape2)

Returns whether two supplied shapes have at least one common element.

Examples:

(shape-intersectionp (~ 1 6) (~ 6 10))
=> nil

(shape-intersectionp (~ 1 5) (~ 6 10))
=> nil

Package

petalisp.core.

Source

shape.lisp.

Function: shape-prefix (shape n)

Returns the shape that consists of the lower axes of the supplied first argument, and whose rank is given by the second argument.

Examples:

(shape-prefix (~ 1 ~ 2 ~ 3) 0)
=> (~*)

(shape-prefix (~ 1 ~ 2 ~ 3) 1)
=> (~ 1)

(shape-prefix (~ 1 ~ 2 ~ 3) 2)
=> (~ 1 ~ 2)

Package

petalisp.core.

Source

shape.lisp.

Function: shape-range (shape axis)

Returns the range denoted by the supplied SHAPE and AXIS.

Examples:

(shape-range (~ 1 ~ 2 ~ 3) 0)
=> #<range(0)>

(shape-range (~ 1 ~ 2 ~ 3) 2)
=> #<range(0 1 2)>

Package

petalisp.core.

Source

shape.lisp.

Reader: shape-ranges (instance)

Returns a list of all ranges contained in the supplied shape.

Examples:

(shape-ranges (~*))
=> nil

(shape-ranges (~ 1 ~ 2 ~ 3))
=> (#<range(0)> #<range(0 1)> #<range(0 1 2)>)

(shape-ranges (~ 0 9 ~ 0 9))
=> (#<range(0 ... 8)> #<range(0 ... 8)>)

Package

petalisp.core.

Source

shape.lisp.

Target Slot

ranges.

Reader: shape-rank (instance)

Returns the rank of the supplied shape, i.e., the number of ranges it contains.

Examples:

(shape-rank (~*))
=> 0

(shape-rank (~ 1 ~ 2 ~ 3))
=> 3

(shape-rank (~ 0 9 ~ 0 9))
=> 2

Package

petalisp.core.

Source

shape.lisp.

Target Slot

rank.

Reader: shape-size (instance)

Returns that number of integer tuples denoted by the supplied shape.

Examples:

(shape-size (~*))
=> 1

(shape-size (~ 2 9))
=> 7

(shape-size (~ 1 9 ~ 1 8))
=> 56

Package

petalisp.core.

Source

shape.lisp.

Target Slot

size.

Function: shape-subseq (shape start &optional end)

Returns the shape consisting of all ranges of the supplied shape in the axes interval between the supplied start and end. If the end argument is not supplied, it defaults to the rank of the supplied shape.

Examples:

(shape-subseq (~ 2 ~ 3 ~ 4) 0)
=> (~ 2 ~ 3 ~ 4)

(shape-subseq (~ 2 ~ 3 ~ 4) 2)
=> (~ 4)

(shape-subseq (~ 2 ~ 3 ~ 4) 1 2)
=> (~ 3)

Package

petalisp.core.

Source

shape.lisp.

Function: shape-suffix (shape n)

Returns the shape that consists of the higher axes of the supplied first argument, and whose rank is given by the second argument.

Examples:

(shape-suffix (~ 1 ~ 2 ~ 3) 0)
=> (~*)

(shape-suffix (~ 1 ~ 2 ~ 3) 1)
=> (~ 3)

(shape-suffix (~ 1 ~ 2 ~ 3) 2)
=> (~ 2 ~ 3)

Package

petalisp.core.

Source

shape.lisp.

Function: shape-table-p (object)
Package

petalisp.core.

Source

shape.lisp.

Function: shape-table-value (shape-table shape &optional default)
Package

petalisp.core.

Source

shape.lisp.

Function: (setf shape-table-value) (shape-table shape &optional default)
Package

petalisp.core.

Source

shape.lisp.

Function: shape< (shape1 shape2)

Returns whether SHAPE1 has less elements than SHAPE2, or, if both shapes have the same size, whether SHAPE1 has lower rank than SHAPE2, or, if both shapes have the same rank, whether the range of SHAPE1 is smaller than the range of SHAPE2 ranges in the lowest axis where both ranges differ in size.

The main use case for this function is to sort sequences of shapes, such that they can be accessed in logarithmic time.

Examples:

(shape< (~ 2) (~ 3))
=> t

(shape< (~ 3) (~ 2))
=> nil

(shape< (~ 2 ~ 4) (~ 2 ~ 2 ~ 2))
=> t

(shape< (~ 2 ~ 2 ~ 2) (~ 2 ~ 4))
=> nil

(shape< (~ 2 ~ 2 ~ 4) (~ 2 ~ 4 ~ 2))
=> t

(shape< (~ 2 ~ 4 ~ 2) (~ 2 ~ 2 ~ 4))
=> nil

Package

petalisp.core.

Source

shape.lisp.

Function: shape= (shape1 shape2)

Returns whether two supplied shapes denote the same set of integer tuples.

Examples:

(shape= (~*) (~*))
=> t

(shape= (~ 42) (~ 42))
=> t

(shape= (~ 1 42) (~ 1 42))
=> t

(shape= (~ 1 42) (~ 2 42))
=> nil

Package

petalisp.core.

Source

shape.lisp.

Function: shapep (object)

Returns whether the supplied object is a shape.

Examples:

(shapep 42)
=> nil

(shapep (~ 1 ~ 2 ~ 3 4))
=> t

Package

petalisp.core.

Source

shape.lisp.

Function: shrink-shape (shape)

This function expects a single shape with one or more ranges R1 to Rn. It returns a shape with the ranges R2 to R1, and, as a second value, the range R1 that has been peeled off.

Examples:

(shrink-shape (~ 1 10))
=> (~*)
=> #<range(1 ... 9)>

(shrink-shape (~ 1 10 ~ 0 2))
=> (~ 2)
=> #<range(1 ... 9)>

Package

petalisp.core.

Source

shape.lisp.

Function: size-one-range-p (range)

Returns whether the supplied range has a size of one.

Examples:

(size-one-range-p (range 5))
=> nil

(size-one-range-p (range 5 7 2))
=> t

(size-one-range-p (range 5 7 3))
=> t

Package

petalisp.core.

Source

range.lisp.

Reader: split-axis (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

axis.

Reader: split-left-child (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

left-child.

Function: split-parent (split)
Package

petalisp.ir.

Source

partitioning.lisp.

Reader: split-position (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

position.

Function: split-range (range &optional position)

Splits the supplied range R into a lower and an upper half and returns those two halves as multiple values. In case R has an odd number of elements, the lower half will have one more element than the upper half.

The optional POSITION argument is a real number that can be used to prescribe the point at which to split the range.

Examples:

(split-range (range 0))
=> #<empty-range>
=> #<empty-range>

(split-range (range 1))
=> #<range(0)>
=> #<empty-range>

(split-range (range 1 10))
=> #<range(1 ... 5)>
=> #<range(6 7 8 9)>

(split-range (range 1 10) 3)
=> #<range(1 2)>
=> #<range(3 ... 9)>

(split-range (range 1 10) 1)
=> #<empty-range>
=> #<range(1 ... 9)>

(split-range (range 1 10) 10)
=> #<range(1 ... 9)>
=> #<empty-range>

(split-range (range 1 9))
=> #<range(1 2 3 4)>
=> #<range(5 6 7 8)>

(split-range (range 2 9 2))
=> #<range(2 4)>
=> #<range(6 8)>

(split-range (range 2 9 2) 3)
=> #<range(2)>
=> #<range(4 6 8)>

Package

petalisp.core.

Source

range.lisp.

Reader: split-right-child (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

right-child.

Function: split-shape (shape axis &optional position)

Split the supplied SHAPE at AXIS. The optional POSITION argument can be supplied to describe the position at which to split. If no POSITION argument is supplied, split into two halves of roughly equal size. Returns two values, which are two shapes resulting from the split.

Examples:

(split-shape (~ 10 ~ 10) 0)
=> (~ 5 ~ 10)
=> (~ 5 10 ~ 10)

(split-shape (~ 10 ~ 10) 1)
=> (~ 10 ~ 5)
=> (~ 10 ~ 5 10)

(split-shape (~ 10 ~ 10) 0 3)
=> (~ 3 ~ 10)
=> (~ 3 10 ~ 10)

(split-shape (~ 2 9 2 ~ 2 9 2) 0 3)
=> (~ 2 3 ~ 2 9 2)
=> (~ 4 9 2 ~ 2 9 2)

(split-shape (~ 2 9 2 ~ 2 9 2) 1 3)
=> (~ 2 9 2 ~ 2 3)
=> (~ 2 9 2 ~ 4 9 2)

Package

petalisp.core.

Source

shape.lisp.

Function: splitp (object)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: stencil-buffer (stencil)
Package

petalisp.ir.

Source

ir.lisp.

Reader: stencil-center (instance)
Writer: (setf stencil-center) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

center.

Function: stencil-from-instruction (instruction)
Package

petalisp.ir.

Source

ir.lisp.

Function: stencil-input-rank (stencil)
Package

petalisp.ir.

Source

ir.lisp.

Reader: stencil-instructions (instance)
Writer: (setf stencil-instructions) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

instructions.

Function: stencil-output-mask (stencil)
Package

petalisp.ir.

Source

ir.lisp.

Function: stencil-output-rank (stencil)
Package

petalisp.ir.

Source

ir.lisp.

Function: stencil-scalings (stencil)
Package

petalisp.ir.

Source

ir.lisp.

Function: stencilp (object)
Package

petalisp.ir.

Source

ir.lisp.

Reader: storage-allocation (instance)
Writer: (setf storage-allocation) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

allocation.

Reader: storage-ghost-layer-alist (instance)
Writer: (setf storage-ghost-layer-alist) (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

ghost-layer-alist.

Reader: storage-ntype (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

ntype.

Reader: storage-offset (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

offset.

Function: storage-rank (storage)
Package

petalisp.ir.

Source

partitioning.lisp.

Reader: storage-size (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

size.

Reader: storage-strides (instance)
Package

petalisp.ir.

Source

partitioning.lisp.

Target Slot

strides.

Function: storagep (object)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: store-instruction-buffer (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf store-instruction-buffer) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: store-instruction-input (store-instruction)
Package

petalisp.ir.

Source

ir.lisp.

Function: store-instruction-p (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: store-instruction-transformation (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: (setf store-instruction-transformation) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Function: subdivide-arrays (arrays)

Invoke SUBDIVIDE-SHAPES on the shapes of the supplied ARRAYS.

Examples:

(subdivide-arrays (list))
=> nil

(subdivide-arrays (list #()))
=> (((~ 0) . 1))

(subdivide-arrays (list #() #()))
=> (((~ 0) . 1) ((~ 0) . 2))

(subdivide-arrays (list #(1 2 3 4) #(1 2)))
=> (((~ 2) . 3) ((~ 2 4) . 1))

Package

petalisp.core.

Source

lazy-array.lisp.

Function: subdivide-shapes (shapes)

Returns a list of cons cells whose CAR is a shape and whose CDR is an integer. Each shape is a proper subshape of one or more of the supplied shapes and the fusion of all these shapes covers all the supplied shapes. The bits of each integer, when viewed in two’s complement, encode which of the supplied shapes are supersets of that particular resulting shape.

Examples:

(subdivide-shapes (list (~ 1 10) (~ 2 20)))
=> (((~ 2 10) . 3) ((~ 1 2) . 1) ((~ 10 20) . 2))

(subdivide-shapes (list (~ 1 3 ~ 1 3) (~ 1 2 ~ 1 2)))
=> (((~ 1 2 ~ 1 2) . 3) ((~ 1 2 ~ 2 3) . 1) ((~ 2 3 ~ 1 3) . 1))

Package

petalisp.core.

Source

shape.lisp.

Function: subrangep (range1 range2)
Package

petalisp.core.

Source

range.lisp.

Function: subshapep (shape1 shape2)

Returns whether all elements of the first supplied shape are also contained in the second supplied shape. Signals an error if the supplied shapes don’t have the same rank.

Examples:

(subshapep (~*) (~*))
=> t

(subshapep (~ 0 9) (~ 0 9))
=> t

(subshapep (~ 0 3) (~ 1 9))
=> nil

(subshapep (~ 0 3 ~ 0 3) (~ 0 9 ~ 0 9))
=> t

Package

petalisp.core.

Source

shape.lisp.

Function: substitute-lazy-array (lazy-array)
Package

petalisp.core.

Source

substitute-lazy-arrays.lisp.

Function: substitute-lazy-arrays (roots new-lazy-arrays old-lazy-arrays)
Package

petalisp.core.

Source

substitute-lazy-arrays.lisp.

Reader: task-number (instance)
Writer: (setf task-number) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

number.

Reader: task-program (instance)
Writer: (setf task-program) (instance)
Package

petalisp.ir.

Source

ir.lisp.

Target Slot

program.

Function: taskp (object)
Package

petalisp.ir.

Source

ir.lisp.

Function: transformation-blueprint (transformation)
Package

petalisp.codegen.

Source

blueprint.lisp.

Reader: transformation-input-mask (instance)

Returns a vector with one element per axis of any possible input. Each element of this vector is either an integer, meaning the index component of any input index in the corresponding axis must be that integer, or NIL, meaning that the index component can be any integer.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

input-mask.

Reader: transformation-input-rank (instance)

Returns the rank that any shape that can be transformed with this transformation must have.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

input-rank.

Function: transformation-invertiblep (transformation)

Returns whether the supplied object is an invertible transformation.

Examples:

(transformation-invertiblep (transform i j to j i))
=> t

(transformation-invertiblep (transform i j to i))
=> nil

Package

petalisp.core.

Source

transformation.lisp.

Reader: transformation-offsets (instance)

Returns a vector with one element per axis of any possible output. Each element of this vector is a rational number that is added to the input index component indicated by the corresponding output mask entry after it is multiplied with the corresponding scaling.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

offsets.

Reader: transformation-output-mask (instance)

Returns a vector with one element per axis of any possible output. Each element of this vector is either an integer that is the corresponding input axis that is referenced by this output axis, or NIL, if and only if the scaling of that output axis is zero.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

output-mask.

Reader: transformation-output-rank (instance)

Returns the rank that shapes created by applying this transformation will have.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

output-rank.

Reader: transformation-scalings (instance)

Returns a vector with one element per axis of any possible output. Each element of this vector is a rational number that is multiplied with the input index component indicated by the corresponding output mask entry before it is added to the corresponding offset.

Package

petalisp.core.

Source

transformation.lisp.

Target Slot

scalings.

Function: transformationp (object)

Returns whether a supplied object is a transformation.

Examples:

(identity-transformation-p (transform i j to j i)) => nil

(identity-transformation-p (transform i j to i j)) => t

Package

petalisp.core.

Source

transformation.lisp.

Function: unpack-array (array environment)
Package

petalisp.codegen.

Source

lisp-compiler.lisp.

Function: value-array (object)
Package

petalisp.core.

Source

lazy-array.lisp.

Function: vicinity-left-neighbors (vicinity axis)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: vicinity-right-neighbors (vicinity axis)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: vicinityp (object)
Package

petalisp.ir.

Source

partitioning.lisp.

Function: wait (&rest requests)

Blocks until the requests resulting from some COMPUTE-ASYNCHRONOUSLY operations has been completed.

Package

petalisp.core.

Source

backend.lisp.

Function: ~ (&rest tokens)

Returns a shape whose ranges are derived by processing each occurrence of one of the self-evaluating delimiter symbols ~ and ~*, and the arguments following such a delimiter up to the next one. Each such group contributes one or more ranges to the resulting shape. The behavior of each delimiter is as follows:

- The ~ delimiter must be followed by one, two, or three integers that are then supplied to the RANGE function to construct the single resulting range.

- The ~* delimiter must be followed by any number of ranges that are incorporated into the resulting shape as they are.

Examples:

(~*)
=> (~*)

(~ 8)
=> (~ 8)

(~ 1 10)
=> (~ 1 10)

(~ 0 10 2 ~ 0 10 2)
=> (~ 0 9 2 ~ 0 9 2)

(~* (range 1 10) (range 2 9) ~ 42)
=> (~ 1 10 ~ 2 9 ~ 42)

(apply #’~ 1 10
(loop repeat 3
append ’(~ 2 6)))
=> (~ 1 10 ~ 2 6 ~ 2 6 ~ 2 6)

Package

petalisp.api.

Source

shape-syntax.lisp.

Function: ~* (&rest tokens)

Returns a shape whose ranges are derived by processing each occurrence of one of the self-evaluating delimiter symbols ~ and ~*, and the arguments following such a delimiter up to the next one. Each such group contributes one or more ranges to the resulting shape. The behavior of each delimiter is as follows:

- The ~ delimiter must be followed by one, two, or three integers that are then supplied to the RANGE function to construct the single resulting range.

- The ~* delimiter must be followed by any number of ranges that are incorporated into the resulting shape as they are.

Examples:

(~*)
=> (~*)

(~ 8)
=> (~ 8)

(~ 1 10)
=> (~ 1 10)

(~ 0 10 2 ~ 0 10 2)
=> (~ 0 9 2 ~ 0 9 2)

(~* (range 1 10) (range 2 9) ~ 42)
=> (~ 1 10 ~ 2 9 ~ 42)

(apply #’~ 1 10
(loop repeat 3
append ’(~ 2 6)))
=> (~ 1 10 ~ 2 6 ~ 2 6 ~ 2 6)

Package

petalisp.api.

Source

shape-syntax.lisp.


5.1.6 Generic functions

Generic Function: backend-compute (backend lazy-arrays)

Returns a list of delayed local arrays, one for each of the supplied list of LAZY-ARRAYS.

This function is invoked by COMPUTE, which guarantees that the supplied LAZY-ARRAYS are already collapsed. The resulting delayed actions replace the delayed actions of the corresponding LAZY-ARRAYS.

Package

petalisp.core.

Source

backend.lisp.

Methods
Method: backend-compute ((testing-backend testing-backend) (data-structures list))
Source

testing-backend.lisp.

Method: backend-compute ((ir-backend ir-backend) (lazy-arrays list))
Source

ir-backend.lisp.

Method: backend-compute ((backend reference-backend) (lazy-arrays list))
Source

reference-backend.lisp.

Method: backend-compute ((backend backend) (lazy-arrays list))
Method: backend-compute ((backend backend) (lazy-arrays null))
Generic Function: backend-compute-asynchronously (backend lazy-arrays)

Returns a REQUEST object that can be used to wait until all of the supplied LAZY-ARRAYS have been computed.

Package

petalisp.core.

Source

backend.lisp.

Methods
Method: backend-compute-asynchronously ((backend backend) (lazy-arrays list))
Method: backend-compute-asynchronously ((backend backend) (lazy-arrays null))
Generic Reader: backend-debug-flag (backend)

Returns whether the supplied backend runs in debug mode, where it trades performance for ease of debugging.

Package

petalisp.core.

Source

backend.lisp.

Methods
Reader Method: backend-debug-flag ((backend backend))

automatically generated reader method

Target Slot

%debug-flag.

Generic Writer: (setf backend-debug-flag) (backend)

Set the backend’s debug flag to true or false.

Package

petalisp.core.

Source

backend.lisp.

Methods
Writer Method: (setf backend-debug-flag) ((backend backend))

automatically generated writer method

Target Slot

%debug-flag.

Generic Function: backend-evaluator (backend unknowns lazy-arrays)

For a supplied BACKEND, list of UNKNOWNS of length N, and list of LAZY-ARRAYS of length K, returns a function with K+N arguments that returns, as multiple values, the K array values obtained by computing the supplied arrays after substituting the Ith unknown with the supplied argument in position K+I.

The first N arguments specify which storage to use for the results. A value of NIL indicates that the corresponding result shall be a fresh array. A value that is an array ensures that the result is written to that array.

An error is signaled if any of the arguments of an evaluator has a different shape or element type as the corresponding result or unknown.

Package

petalisp.core.

Source

backend.lisp.

Methods
Method: backend-evaluator ((backend backend) (unknowns list) (lazy-arrays list))
Source

evaluator.lisp.

Method: backend-evaluator ((backend backend) (unknowns list) (lazy-arrays list))