The mgl-mat Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The mgl-mat Reference Manual

This is the mgl-mat Reference Manual, version 0.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 05:38:58 2022 GMT+0.

Table of Contents


1 Introduction

# MAT Manual

###### \[in package MGL-MAT\]
## MGL-MAT ASDF System

- Version: 0.1.0
- Description: MAT is library for working with multi-dimensional
  arrays which supports efficient interfacing to foreign and CUDA
  code. BLAS and CUBLAS bindings are available.
- Licence: MIT, see COPYING.
- Author: Gábor Melis 
- Mailto: [mega@retes.hu](mailto:mega@retes.hu)
- Homepage: [http://melisgl.github.io/mgl-mat](http://melisgl.github.io/mgl-mat)
- Bug tracker: [https://github.com/melisgl/mgl-mat/issues](https://github.com/melisgl/mgl-mat/issues)
- Source control: [GIT](https://github.com/melisgl/mgl-mat.git)

## Links

Here is the [official
repository](https://github.com/melisgl/mgl-mat) and the [HTML
documentation](http://melisgl.github.io/mgl-mat/mat-manual.html)
for the latest version.

## Introduction

### What's MGL-MAT?

MGL-MAT is library for working with multi-dimensional arrays
which supports efficient interfacing to foreign and CUDA code with
automatic translations between cuda, foreign and lisp storage. BLAS
and CUBLAS bindings are available.

### What kind of matrices are supported?

Currently only row-major single and double float matrices are
supported, but it would be easy to add single and double precision
complex types too. Other numeric types, such as byte and native
integer, can be added too, but they are not supported by CUBLAS.
There are no restrictions on the number of dimensions, and reshaping
is possible. All functions operate on the visible portion of the
matrix (which is subject to displacement and shaping), invisible
elements are not affected.

### Where to Get it?

All dependencies are in quicklisp except for
[CL-CUDA](https://github.com/takagi/cl-cuda) that needs to be
fetched from github. Just clone CL-CUDA and MGL-MAT into
`quicklisp/local-projects/` and you are set. MGL-MAT itself lives
[at github](https://github.com/melisgl/mgl-mat), too.

Prettier-than-markdown HTML documentation cross-linked with other
libraries is
[available](http://melisgl.github.io/mgl-pax-world/mat-manual.html)
as part of [PAX World](http://melisgl.github.io/mgl-pax-world/).

## Tutorial

We are going to see how to create matrices, access their contents.

Creating matrices is just like creating lisp arrays:

```commonlisp
(make-mat '6)
==> #

(make-mat '(2 3) :ctype :float :initial-contents '((1 2 3) (4 5 6)))
==> #

(make-mat '(2 3 4) :initial-element 1)
==> #                    (1.0d0 1.0d0 1.0d0 1.0d0)
-->                    (1.0d0 1.0d0 1.0d0 1.0d0))
-->                   ((1.0d0 1.0d0 1.0d0 1.0d0)
-->                    (1.0d0 1.0d0 1.0d0 1.0d0)
-->                    (1.0d0 1.0d0 1.0d0 1.0d0)))>
```

The most prominent difference from lisp arrays is that `MAT`s are
always numeric and their element type (called CTYPE here) defaults
to :DOUBLE.

Individual elements can be accessed or set with MREF:

```commonlisp
(let ((m (make-mat '(2 3))))
  (setf (mref m 0 0) 1)
  (setf (mref m 0 1) (* 2 (mref m 0 0)))
  (incf (mref m 0 2) 4)
  m)
==> #
```

Compared to AREF MREF is a very expensive operation and it's best
used sparingly. Instead, typical code relies much more on matrix
level operations:

```commonlisp
(princ (scal! 2 (fill! 3 (make-mat 4))))
.. #
==> #
```

The content of a matrix can be accessed in various representations
called *facets*. MGL-MAT takes care of synchronizing these facets
by copying data around lazily, but doing its best to share storage
for facets that allow it.

Notice the `ABF` in the printed results. It illustrates that behind
the scenes FILL! worked on the [BACKING-ARRAY][facet-name]
facet (hence the `B`) that's basically a 1d lisp array. SCAL! on the
other hand made a foreign call to the BLAS `dscal` function for
which it needed the [FOREIGN-ARRAY][facet-name] facet (`F`).
Finally, the `A` stands for the [ARRAY][facet-name] facet that was
created when the array was printed. All facets are up-to-date (else
some of the characters would be lowercase). This is possible because
these three facets actually share storage which is never the case
for the [CUDA-ARRAY][facet-name] facet. Now if we have a
CUDA-capable GPU, CUDA can be enabled with WITH-CUDA\*:

```commonlisp
(with-cuda* ()
  (princ (scal! 2 (fill! 3 (make-mat 4)))))
.. #
==> #
```

Note the lonely `C` showing that only the [CUDA-ARRAY][facet-name]
facet was used for both FILL! and SCAL!. When WITH-CUDA\* exits and
destroys the CUDA context, it destroys all CUDA facets, moving their
data to the [ARRAY][facet-name] facet, so the returned MAT only has
that facet.

When there is no high-level operation that does what we want, we may
need to add new operations. This is usually best accomplished by
accessing one of the facets directly, as in the following example:

```commonlisp
(defun logdet (mat)
  "Logarithm of the determinant of MAT. Return -1, 1 or 0 (or
  equivalent) to correct for the sign, as the second value."
  (with-facets ((array (mat 'array :direction :input)))
    (lla:logdet array)))

```

Notice that LOGDET doesn't know about CUDA at all. WITH-FACETS
gives it the content of the matrix as a normal multidimensional lisp
array, copying the data from the GPU or elsewhere if necessary. This
allows new representations (`FACET`s) to be added easily and it also
avoids copying if the facet is already up-to-date. Of course, adding
CUDA support to LOGDET could make it more efficient.

Adding support for matrices that, for instance, live on a remote
machine is thus possible with a new facet type and existing code
would continue to work (albeit possibly slowly). Then one could
optimize the bottleneck operations by sending commands over the
network instead of copying data.

It is a bad idea to conflate resource management policy and
algorithms. MGL-MAT does its best to keep them separate.

## Basics

- [class] MAT CUBE

    A MAT is a data CUBE that is much like a lisp
    array, it supports DISPLACEMENT, arbitrary DIMENSIONS and
    INITIAL-ELEMENT with the usual semantics. However, a MAT supports
    different representations of the same data. See @MAT-TUTORIAL for
    an introduction.

- [reader] MAT-CTYPE MAT (:CTYPE = \*DEFAULT-MAT-CTYPE\*)

    One of *SUPPORTED-CTYPES*. The matrix can hold
    only values of this type.

- [reader] MAT-DISPLACEMENT MAT (:DISPLACEMENT = 0)

    A value in the `[0,MAX-SIZE]` interval. This is
    like the DISPLACED-INDEX-OFFSET of a lisp array, but displacement
    is relative to the start of the underlying storage vector.

- [reader] MAT-DIMENSIONS MAT (:DIMENSIONS)

    Like ARRAY-DIMENSIONS. It holds a list of
    dimensions, but it is allowed to pass in scalars too.

- [function] MAT-DIMENSION MAT AXIS-NUMBER

    Return the dimension along AXIS-NUMBER. Similar to
    ARRAY-DIMENSION.

- [reader] MAT-INITIAL-ELEMENT MAT (:INITIAL-ELEMENT = 0)

    If non-nil, then when a facet is created, it is
    filled with INITIAL-ELEMENT coerced to the appropriate numeric
    type. If NIL, then no initialization is performed.

- [reader] MAT-SIZE MAT

    The number of elements in the visible portion of
    the array. This is always the product of the elements
    MAT-DIMENSIONS and is similar to ARRAY-TOTAL-SIZE.

- [reader] MAT-MAX-SIZE MAT (:MAX-SIZE)

    The number of elements for which storage may be
    allocated. This is DISPLACEMENT + MAT-SIZE + `SLACK` where `SLACK`
    is the number of trailing invisible elements.

- [function] MAKE-MAT DIMENSIONS &REST ARGS &KEY (CTYPE \*DEFAULT-MAT-CTYPE\*) (DISPLACEMENT 0) MAX-SIZE INITIAL-ELEMENT INITIAL-CONTENTS (SYNCHRONIZATION \*DEFAULT-SYNCHRONIZATION\*) DISPLACED-TO (CUDA-ENABLED \*DEFAULT-MAT-CUDA-ENABLED\*)

    Return a new MAT object. If INITIAL-CONTENTS is given then the
    matrix contents are initialized with REPLACE!. See class MAT for the
    description of the rest of the parameters. This is exactly
    what (MAKE-INSTANCE 'MAT ...) does except DIMENSIONS is not a
    keyword argument so that MAKE-MAT looks more like MAKE-ARRAY. The
    semantics of SYNCHRONIZATION are desribed in the
    @CUBE-SYNCHRONIZATION section.
    
    If specified, DISPLACED-TO must be a MAT object large enough (in the
    sense of its MAT-SIZE), to hold DISPLACEMENT plus `(REDUCE #'*
    DIMENSIONS)` elements. Just like with MAKE-ARRAY, INITIAL-ELEMENT
    and INITIAL-CONTENTS must not be supplied together with
    DISPLACED-TO. See @MAT-SHAPING for more.

- [function] ARRAY-TO-MAT ARRAY &KEY CTYPE (SYNCHRONIZATION \*DEFAULT-SYNCHRONIZATION\*)

    Create a MAT that's equivalent to ARRAY. Displacement of the
    created array will be 0 and the size will be equal to
    ARRAY-TOTAL-SIZE. If CTYPE is non-nil, then it will be the ctype of
    the new matrix. Else ARRAY's type is converted to a ctype. If there
    is no corresponding ctype, then *DEFAULT-MAT-CTYPE* is used.
    Elements of ARRAY are coerced to CTYPE.
    
    Also see @CUBE-SYNCHRONIZATION.

- [function] MAT-TO-ARRAY MAT

- [function] REPLACE! MAT SEQ-OF-SEQS

    Replace the contents of MAT with the elements of SEQ-OF-SEQS.
    SEQ-OF-SEQS is a nested sequence of sequences similar to the
    INITIAL-CONTENTS argument of MAKE-ARRAY. The total number of
    elements must match the size of MAT. Returns MAT.
    
    SEQ-OF-SEQS may contain multi-dimensional arrays as *leafs*, so the
    following is legal:
    
    ```common-lisp
    (replace! (make-mat '(1 2 3)) '(#2A((1 2 3) (4 5 6))))
    ==> #
    ```


- [function] MREF MAT &REST INDICES

    Like AREF for arrays. Don't use this if you care about performance
    at all. SETFable. When set, the value is coerced to the ctype of MAT
    with COERCE-TO-CTYPE. Note that currently MREF always operates on
    the BACKING-ARRAY facet so it can trigger copying of facets. When
    it's SETF'ed, however, it will update the CUDA-ARRAY if cuda is
    enabled and it is up-to-date or there are no facets at all.

- [function] ROW-MAJOR-MREF MAT INDEX

    Like ROW-MAJOR-AREF for arrays. Don't use this if you care about
    performance at all. SETFable. When set, the value is coerced to the
    ctype of MAT with COERCE-TO-CTYPE. Note that currently
    ROW-MAJOR-MREF always operates on the BACKING-ARRAY facet so it can
    trigger copying of facets. When it's SETF'ed, however, it will
    update the CUDA-ARRAY if cuda is enabled and it is up-to-date or
    there are no facets at all.

- [function] MAT-ROW-MAJOR-INDEX MAT &REST SUBSCRIPTS

    Like ARRAY-ROW-MAJOR-INDEX for arrays.

## Element types

- [variable] *SUPPORTED-CTYPES* (:FLOAT :DOUBLE)

- [type] CTYPE

    This is basically `(MEMBER :FLOAT :DOUBLE)`.

- [variable] *DEFAULT-MAT-CTYPE* :DOUBLE

    By default MATs are created with this ctype. One of :FLOAT
    or :DOUBLE.

- [function] COERCE-TO-CTYPE X &KEY (CTYPE \*DEFAULT-MAT-CTYPE\*)

    Coerce the scalar X to the lisp type corresponding to CTYPE.

## Printing

- [variable] *PRINT-MAT* T

    Controls whether the contents of a MAT object are printed as an
    array (subject to the standard printer control variables).

- [variable] *PRINT-MAT-FACETS* T

    Controls whether a summary of existing and up-to-date facets is
    printed when a MAT object is printed. The summary that looks like
    `ABcfh` indicates that all five facets ([ARRAY][facet-name],
    [BACKING-ARRAY][facet-name], [CUDA-ARRAY][facet-name],
    [FOREIGN-ARRAY][facet-name], [CUDA-HOST-ARRAY][facet-name]) are
    present and the first two are up-to-date. A summary of a single #-
    indicates that there are no facets.

## Shaping

We are going to discuss various ways to change the visible portion
and dimensions of matrices. Conceptually a matrix has an *underlying
non-displaced storage vector*. For `(MAKE-MAT 10 :DISPLACEMENT
7 :MAX-SIZE 21)` this underlying vector looks like this:

    displacement | visible elements  | slack
    . . . . . . . 0 0 0 0 0 0 0 0 0 0 . . . .

Whenever a matrix is reshaped (or *displaced to* in lisp
terminology), its displacement and dimensions change but the
underlying vector does not.

The rules for accessing displaced matrices is the same as always:
multiple readers can run in parallel, but attempts to write will
result in an error if there are either readers or writers on any of
the matrices that share the same underlying vector.

### Comparison to Lisp Arrays

One way to reshape and displace MAT objects is with MAKE-MAT and
its DISPLACED-TO argument whose semantics are similar to that of
MAKE-ARRAY in that the displacement is *relative* to the
displacement of DISPLACED-TO.

```commonlisp
(let* ((base (make-mat 10 :initial-element 5 :displacement 1))
       (mat (make-mat 6 :displaced-to base :displacement 2)))
  (fill! 1 mat)
  (values base mat))
==> #                  5.0d0)>
==> #
```

There are important semantic differences compared to lisp arrays all
which follow from the fact that displacement operates on the
underlying conceptual non-displaced vector.

- Matrices can be displaced and have slack even without DISPLACED-TO
  just like `BASE` in the above example.

- It's legal to alias invisible elements of DISPLACED-TO as long as
  the new matrix fits into the underlying storage.

- Negative displacements are allowed with DISPLACED-TO as long as
  the adjusted displacement is non-negative.

- Further shaping operations can make invisible portions of the
  DISPLACED-TO matrix visible by changing the displacement.

- In contrast to ARRAY-DISPLACEMENT, MAT-DISPLACEMENT only returns
  an offset into the underlying storage vector.


### Functional Shaping

The following functions are collectively called the functional
shaping operations, since they don't alter their arguments in any
way. Still, since storage is aliased modification to the returned
matrix will affect the original.

- [function] RESHAPE-AND-DISPLACE MAT DIMENSIONS DISPLACEMENT

    Return a new matrix of DIMENSIONS that aliases MAT's storage at
    offset DISPLACEMENT. DISPLACEMENT 0 is equivalent to the start of
    the storage of MAT regardless of MAT's displacement.

- [function] RESHAPE MAT DIMENSIONS

    Return a new matrix of DIMENSIONS whose displacement is the same as
    the displacement of MAT.

- [function] DISPLACE MAT DISPLACEMENT

    Return a new matrix that aliases MAT's storage at offset
    DISPLACEMENT. DISPLACEMENT 0 is equivalent to the start of the
    storage of MAT regardless of MAT's displacement. The returned matrix
    has the same dimensions as MAT.

### Destructive Shaping

The following destructive operations don't alter the contents of
the matrix, but change what is visible. ADJUST! is the odd one out,
it may create a new MAT.

- [function] RESHAPE-AND-DISPLACE! MAT DIMENSIONS DISPLACEMENT

    Change the visible (or active) portion of MAT by altering its
    displacement offset and dimensions. Future operations will only
    affect this visible portion as if the rest of the elements were not
    there. Return MAT.
    
    DISPLACEMENT + the new size must not exceed MAT-MAX-SIZE.
    Furthermore, there must be no facets being viewed (with WITH-FACETS)
    when calling this function as the identity of the facets is not
    stable.

- [function] RESHAPE! MAT DIMENSIONS

    Like RESHAPE-AND-DISPLACE! but only alters the dimensions.

- [function] DISPLACE! MAT DISPLACEMENT

    Like RESHAPE-AND-DISPLACE! but only alters the displacement.

- [function] RESHAPE-TO-ROW-MATRIX! MAT ROW

    Reshape the 2d MAT to make only a single ROW visible. This is made
    possible by the row-major layout, hence no column counterpart.
    Return MAT.

- [macro] WITH-SHAPE-AND-DISPLACEMENT (MAT &OPTIONAL (DIMENSIONS NIL) (DISPLACEMENT NIL)) &BODY BODY

    Reshape and displace MAT if DIMENSIONS and/or DISPLACEMENT is given
    and restore the original shape and displacement after BODY is
    executed. If neither is specificed, then nothing will be changed,
    but BODY is still allowed to alter the shape and displacement.

- [function] ADJUST! MAT DIMENSIONS DISPLACEMENT &KEY (DESTROY-OLD-P T)

    Like RESHAPE-AND-DISPLACE! but creates a new matrix if MAT isn't
    large enough. If a new matrix is created, the contents are not
    copied over and the old matrix is destroyed with DESTROY-CUBE if
    DESTROY-OLD-P.

## Assembling

The functions here assemble a single MAT from a number of
[MAT][]s.

- [function] STACK! AXIS MATS MAT

    Stack MATS along AXIS into MAT and return MAT. If AXIS is 0, place
    MATS into MAT below each other starting from the top. If AXIS is 1,
    place MATS side by side starting from the left. Higher AXIS are also
    supported. All dimensions except for AXIS must be the same for all
    MATS.

- [function] STACK AXIS MATS &KEY (CTYPE \*DEFAULT-MAT-CTYPE\*)

    Like STACK! but return a new MAT of CTYPE.
    
    ```commonlisp
    (stack 1 (list (make-mat '(3 2) :initial-element 0)
                   (make-mat '(3 1) :initial-element 1)))
    ==> #                 (0.0d0 0.0d0 1.0d0)
    -->                 (0.0d0 0.0d0 1.0d0))>
    ```


## Caching

Allocating and initializing a MAT object and its necessary facets
can be expensive. The following macros remember the previous value
of a binding in the same thread and /place/. Only weak references
are constructed so the cached objects can be garbage collected.

While the cache is global, thread safety is guaranteed by having
separate subcaches per thread. Each subcache is keyed by a /place/
object that's either explicitly specified or else is unique to each
invocation of the caching macro, so different occurrences of caching
macros in the source never share data. Still, recursion could lead
to data sharing between different invocations of the same function.
To prevent this, the cached object is removed from the cache while
it is used so other invocations will create a fresh one which isn't
particularly efficient but at least it's safe.

- [macro] WITH-THREAD-CACHED-MAT (VAR DIMENSIONS &REST ARGS &KEY (PLACE :SCRATCH) (CTYPE '\*DEFAULT-MAT-CTYPE\*) (DISPLACEMENT 0) MAX-SIZE (INITIAL-ELEMENT 0) INITIAL-CONTENTS) &BODY BODY

    Bind VAR to a matrix of DIMENSIONS, CTYPE, etc. Cache this matrix,
    and possibly reuse it later by reshaping it. When BODY exits the
    cached object is updated with the binding of VAR which BODY may
    change.
    
    There is a separate cache for each thread and each `PLACE` (under
    EQ). Since every cache holds exactly one MAT per CTYPE, nested
    WITH-THREAD-CACHED-MAT often want to use different `PLACE`s. By
    convention, these places are called `:SCRATCH-1`, `:SCRATCH-2`,
    etc.

- [macro] WITH-THREAD-CACHED-MATS SPECS &BODY BODY

    A shorthand for writing nested WITH-THREAD-CACHED-MAT calls.
    
    ```
    (with-thread-cached-mat (a ...)
      (with-thread-cached-mat (b ...)
        ...))
    ```
    
    is equivalent to:
    
    ```
    (with-thread-cached-mat ((a ...)
                             (b ...))
      ...)
    ```


- [macro] WITH-ONES (VAR DIMENSIONS &KEY (CTYPE '\*DEFAULT-MAT-CTYPE\*) (PLACE :ONES)) &BODY BODY

    Bind VAR to a matrix of DIMENSIONS whose every element is 1. The
    matrix is cached for efficiency.

## BLAS Operations

Only some BLAS functions are implemented, but it should be easy to
add more as needed. All of them default to using CUDA, if it is
initialized and enabled (see USE-CUDA-P).

Level 1 BLAS operations

- [function] ASUM X &KEY (N (MAT-SIZE X)) (INCX 1)

    Return the l1 norm of X, that is, sum of the absolute values of its
    elements.

- [function] AXPY! ALPHA X Y &KEY (N (MAT-SIZE X)) (INCX 1) (INCY 1)

    Set Y to ALPHA \* X + Y. Return Y.

- [function] COPY! X Y &KEY (N (MAT-SIZE X)) (INCX 1) (INCY 1)

    Copy X into Y. Return Y.

- [function] DOT X Y &KEY (N (MAT-SIZE X)) (INCX 1) (INCY 1)

    Return the dot product of X and Y.

- [function] NRM2 X &KEY (N (MAT-SIZE X)) (INCX 1)

    Return the l2 norm of X, which is the square root of the sum of the
    squares of its elements.

- [function] SCAL! ALPHA X &KEY (N (MAT-SIZE X)) (INCX 1)

    Set X to ALPHA \* X. Return X.

Level 3 BLAS operations

- [function] GEMM! ALPHA A B BETA C &KEY TRANSPOSE-A? TRANSPOSE-B? M N K LDA LDB LDC

    Basically C = ALPHA \* A' \* B' + BETA \* C. A' is A or its transpose
    depending on TRANSPOSE-A?. B' is B or its transpose depending on
    TRANSPOSE-B?. Returns C.
    
    A' is an MxK matrix. B' is a KxN matrix. C is an MxN matrix.
    
    LDA is the width of the matrix A (not of A'). If A is not transposed,
    then K <= LDA, if it's transposed then M <= LDA.
    
    LDB is the width of the matrix B (not of B'). If B is not transposed,
    then N <= LDB, if it's transposed then K <= LDB.
    
    In the example below M=3, N=2, K=5, LDA=6, LDB=3, LDC=4. The cells
    marked with + do not feature in the calculation.
    
                   N
                  --+
                  --+
                K -B+
                  --+
                  --+
                  +++
            K
          -----+  --++
        M --A--+  -C++
          -----+  --++
          ++++++  ++++


## Destructive API

- [function] .SQUARE! X &KEY (N (MAT-SIZE X))

    Set X to its elementwise square. Return X.

- [function] .SQRT! X &KEY (N (MAT-SIZE X))

    Set X to its elementwise square root. Return X.

- [function] .LOG! X &KEY (N (MAT-SIZE X))

    Set X to its elementwise natural logarithm. Return X.

- [function] .EXP! X &KEY (N (MAT-SIZE X))

    Apply EXP elementwise to X in a destructive manner. Return X.

- [function] .EXPT! X POWER

    Raise matrix X to POWER in an elementwise manner. Return X. Note
    that CUDA and non-CUDA implementations may disagree on the treatment
    of NaNs, infinities and complex results. In particular, the lisp
    implementation always computes the REALPART of the results while
    CUDA's pow() returns NaNs instead of complex numbers.

- [function] .INV! X &KEY (N (MAT-SIZE X))

    Set X to its elementwise inverse `(/ 1 X)`. Return X.

- [function] .LOGISTIC! X &KEY (N (MAT-SIZE X))

    Destructively apply the logistic function to X in an elementwise
    manner. Return X.

- [function] .+! ALPHA X

    Add the scalar ALPHA to each element of X destructively modifying
    X. Return X.

- [function] .*! X Y

- [function] GEEM! ALPHA A B BETA C

    Like GEMM!, but multiplication is elementwise. This is not a
    standard BLAS routine.

- [function] GEERV! ALPHA A X BETA B

    GEneric Elementwise Row - Vector multiplication. `B = beta * B +
    alpha a .* X*` where `X*` is a matrix of the same shape as A whose
    every row is X. Perform elementwise multiplication on each row of A
    with the vector X and add the scaled result to the corresponding row
    of B. Return B. This is not a standard BLAS routine.

- [function] .CTYPE (TYPE-OF X)))

    Return a matrix of one dimension and one element: X. CTYPE, the
    type of the matrix, defaults to the ctype corresponding to the type
    of X.

- [function] M= A B

    Check whether A and B, which must be matrices of the same size, are
    elementwise equal.

- [function] TRANSPOSE A

    Return the transpose of A.

- [function] M* A B &KEY TRANSPOSE-A? TRANSPOSE-B?

    Compute op(A) \* op(B). Where op is either the identity or the
    transpose operation depending on TRANSPOSE-A? and TRANSPOSE-B?.

- [function] MM* M &REST ARGS

    Convenience function to multiply several matrices. 
    
    (mm\* a b c) => a \* b \* c

- [function] M- A B

    Return A - B.

- [function] M+ A B

    Return A + B.

- [function] INVERT A

    Return the inverse of A.

- [function] LOGDET MAT

    Logarithm of the determinant of MAT. Return -1, 1 or 0 (or
    equivalent) to correct for the sign, as the second value.

## Mappings

- [function] MAP-CONCAT FN MATS MAT &KEY KEY PASS-RAW-P

    Call FN with each element of MATS and MAT temporarily reshaped to
    the dimensions of the current element of MATS and return MAT. For
    the next element the displacement is increased so that there is no
    overlap.
    
    MATS is keyed by KEY just like the CL sequence functions. Normally,
    FN is called with the matrix returned by KEY. However, if
    PASS-RAW-P, then the matrix returned by KEY is only used to
    calculate dimensions and the element of MATS that was passed to KEY
    is passed to FN, too.
    
    ```
    (map-concat #'copy! (list (make-mat 2) (make-mat 4 :initial-element 1))
                (make-mat '(2 3)))
    ==> #
    ```


- [function] MAP-DISPLACEMENTS FN MAT DIMENSIONS &KEY (DISPLACEMENT-START 0) DISPLACEMENT-STEP

    Call FN with MAT reshaped to DIMENSIONS, first displaced by
    DISPLACEMENT-START that's incremented by DISPLACEMENT-STEP each
    iteration while there are enough elements left for DIMENSIONS at the
    current displacement. Returns MAT.
    
    ```commonlisp
    (let ((mat (make-mat 14 :initial-contents '(-1 0 1 2 3
                                                4 5 6 7
                                                8 9 10 11 12))))
      (reshape-and-displace! mat '(4 3) 1)
      (map-displacements #'print mat 4))
    ..
    .. # 
    .. # 
    .. # 
    ```


- [function] MAP-MATS-INTO RESULT-MAT FN &REST MATS

    Like CL:MAP-INTO but for MAT objects. Destructively modifies
    RESULT-MAT to contain the results of applying FN to each element in
    the argument MATS in turn.

## Random numbers

Unless noted these work efficiently with CUDA.

- [generic-function] COPY-RANDOM-STATE STATE

    Return a copy of STATE be it a lisp or cuda random
    state.

- [function] UNIFORM-RANDOM! MAT &KEY (LIMIT 1)

    Fill MAT with random numbers sampled uniformly from the \[0,LIMIT)
    interval of MAT's type.

- [function] GAUSSIAN-RANDOM! MAT &KEY (MEAN 0) (STDDEV 1)

    Fill MAT with independent normally distributed random numbers with
    MEAN and STDDEV.

- [function] MV-GAUSSIAN-RANDOM &KEY MEANS COVARIANCES

    Return a column vector of samples from the multivariate normal
    distribution defined by MEANS (Nx1) and COVARIANCES (NxN). No CUDA
    implementation.

- [function] ORTHOGONAL-RANDOM! M &KEY (SCALE 1)

    Fill the matrix M with random values in such a way that `M^T * M`
    is the identity matrix (or something close if M is wide). Return M.

## I/O

- [variable] *MAT-HEADERS* T

    If true, a header with MAT-CTYPE and MAT-SIZE is written by
    WRITE-MAT before the contents and READ-MAT checks that these match
    the matrix into which it is reading.

- [generic-function] WRITE-MAT MAT STREAM

    Write MAT to binary STREAM in portable binary
    format. Return MAT. Displacement and size are taken into account,
    only visible elements are written. Also see *MAT-HEADERS*.

- [generic-function] READ-MAT MAT STREAM

    Destructively modify the visible portion (with
    regards to displacement and shape) of MAT by reading MAT-SIZE number
    of elements from binary STREAM. Return MAT. Also see
    *MAT-HEADERS*.

## Debugging

The largest class of bugs has to do with synchronization of facets
being broken. This is almost always caused by an operation that
mispecifies the DIRECTION argument of WITH-FACET. For example, the
matrix argument of SCAL! should be accessed with direciton :IO. But
if it's :INPUT instead, then subsequent access to the ARRAY facet
will not see the changes made by AXPY!, and if it's :OUTPUT, then
any changes made to the ARRAY facet since the last update of the
CUDA-ARRAY facet will not be copied and from the wrong input SCAL!
will compute the wrong result.

Using the SLIME inspector or trying to access the
[CUDA-ARRAY][facet-name] facet from threads other than the one in
which the corresponding CUDA context was initialized will fail. For
now, the easy way out is to debug the code with CUDA disabled (see
*CUDA-ENABLED*).

Another thing that tends to come up is figuring out where memory is
used.

- [function] MAT-ROOM &KEY (STREAM \*STANDARD-OUTPUT\*) (VERBOSE T)

    Calls FOREIGN-ROOM and CUDA-ROOM.

- [macro] WITH-MAT-COUNTERS (&KEY COUNT N-BYTES) &BODY BODY

    Count all MAT allocations and also the number of bytes they may
    require. *May require* here really means an upper bound,
    because `(MAKE-MAT (EXPT 2 60))` doesn't actually uses memory until
    one of its facets is accessed (don't simply evaluate it though,
    printing the result will access the [ARRAY][facet-name] facet if
    *PRINT-MAT*). Also, while facets today all require the same number
    of bytes, this may change in the future. This is a debugging tool,
    don't use it in production.
    
    ```common-lisp
    (with-mat-counters (:count count :n-bytes n-bytes)
      (assert (= count 0))
      (assert (= n-bytes 0))
      (make-mat '(2 3) :ctype :double)
      (assert (= count 1))
      (assert (= n-bytes (* 2 3 8)))
      (with-mat-counters (:n-bytes n-bytes-1 :count count-1)
        (make-mat '7 :ctype :float)
        (assert (= count-1 1))
        (assert (= n-bytes-1 (* 7 4))))
      (assert (= n-bytes (+ (* 2 3 8) (* 7 4))))
      (assert (= count 2)))
    ```


## Facet API



### Facets

A MAT is a CUBE (see @CUBE-MANUAL) whose facets are different
representations of numeric arrays. These facets can be accessed with
WITH-FACETS with one of the following [FACET-NAME][locative]
locatives:

- [facet-name] BACKING-ARRAY

    The corresponding facet's value is a one dimensional lisp array or
    a static vector that also looks exactly like a lisp array but is
    allocated in foreign memory. See *FOREIGN-ARRAY-STRATEGY*.

- [facet-name] ARRAY

    Same as BACKING-ARRAY if the matrix is one-dimensional, all
    elements are visible (see @MAT-SHAPING), else it's a lisp array
    displaced to the backing array.

- [facet-name] FOREIGN-ARRAY

    The facet's value is a [FOREIGN-ARRAY][class] which is an
    OFFSET-POINTER wrapping a CFFI pointer. See
    *FOREIGN-ARRAY-STRATEGY*.

- [facet-name] CUDA-HOST-ARRAY

    This facet's value is a basically the same as that of
    [FOREIGN-ARRAY][facet-name]. In fact, they share storage. The
    difference is that accessing [CUDA-HOST-ARRAY][facet-name] ensures
    that the foreign memory region is page-locked and registered with
    the CUDA Driver API function cuMemHostRegister(). Copying between
    GPU memory ([CUDA-ARRAY][facet-name]) and registered memory is
    significantly faster than with non-registered memory and also allows
    overlapping copying with computation. See
    WITH-SYNCING-CUDA-FACETS.

- [facet-name] CUDA-ARRAY

    The facet's value is a CUDA-ARRAY, which is an OFFSET-POINTER
    wrapping a CL-CUDA.DRIVER-API:CU-DEVICE-PTR, allocated with
    CL-CUDA.DRIVER-API:CU-MEM-ALLOC and freed automatically.

Facets bound by with WITH-FACETS are to be treated as dynamic
extent: it is not allowed to keep a reference to them beyond the
dynamic scope of WITH-FACETS.

For example, to implement the FILL! operation using only the
BACKING-ARRAY, one could do this:

```commonlisp
(let ((displacement (mat-displacement x))
      (size (mat-size x)))
 (with-facets ((x* (x 'backing-array :direction :output)))
   (fill x* 1 :start displacement :end (+ displacement size))))
```

DIRECTION is :OUTPUT because we clobber all values in `X`. Armed
with this knowledge about the direction, WITH-FACETS will not copy
data from another facet if the backing array is not up-to-date.

To transpose a 2d matrix with the [ARRAY][facet-name] facet:

```commonlisp
(destructuring-bind (n-rows n-columns) (mat-dimensions x)
  (with-facets ((x* (x 'array :direction :io)))
    (dotimes (row n-rows)
      (dotimes (column n-columns)
        (setf (aref x* row column) (aref x* column row))))))
```

Note that DIRECTION is :IO, because we need the data in this facet
to be up-to-date (that's the input part) and we are invalidating all
other facets by changing values (that's the output part).

To sum the values of a matrix using the [FOREIGN-ARRAY][facet-name]
facet:

```commonlisp
(let ((sum 0))
  (with-facets ((x* (x 'foreign-array :direction :input)))
    (let ((pointer (offset-pointer x*)))
      (loop for index below (mat-size x)
            do (incf sum (cffi:mem-aref pointer (mat-ctype x) index)))))
  sum)
```

See DIRECTION for a complete description of :INPUT, :OUTPUT and :IO.
For MAT objects, that needs to be refined. If a MAT is reshaped
and/or displaced in a way that not all elements are visible then
those elements are always kept intact and copied around. This is
accomplished by turning :OUTPUT into :IO automatically on such MATs.

We have finished our introduction to the various facets. It must be
said though that one can do anything without ever accessing a facet
directly or even being aware of them as most operations on `MAT`s
take care of choosing the most appropriate facet behind the scenes.
In particular, most operations automatically use CUDA, if available
and initialized. See WITH-CUDA\* for detail.

### Foreign arrays

One facet of MAT objects is [FOREIGN-ARRAY][facet-name] which is
backed by a memory area that can be a pinned lisp array or is
allocated in foreign memory depending on *FOREIGN-ARRAY-STRATEGY*.

- [class] FOREIGN-ARRAY

    [FOREIGN-ARRAY][class] wraps a foreign pointer (in
    the sense of CFFI:POINTERP). That is, both OFFSET-POINTER and
    BASE-POINTER return a foreign pointer. There are no other public
    operations that work with [FOREIGN-ARRAY][class] objects, their sole
    purpose is represent facets of MAT objects.

- [variable] *FOREIGN-ARRAY-STRATEGY* "-see below-"

    One of :PINNED, :STATIC and :CUDA-HOST (see type
    FOREIGN-ARRAY-STRATEGY). This variable controls how foreign arrays
    are handled and it can be changed at any time.
    
    If it's :PINNED (only supported if (PINNING-SUPPORTED-P), then no
    separate storage is allocated for the foreign array. Instead, it
    aliases the lisp array (via the BACKING-ARRAY facet).
    
    If it's :STATIC, then the lisp backing arrays are allocated
    statically via the static-vectors library. On some implementations,
    explicit freeing of static vectors is necessary, this is taken care
    of by finalizers or can be controlled with WITH-FACET-BARRIER.
    DESTROY-CUBE and DESTROY-FACET may also be of help.
    
    :CUDA-HOST is the same as :STATIC, but any copies to/from the
    GPU (i.e. the [CUDA-ARRAY][facet-name] facet) will be done via the
    [CUDA-HOST-ARRAY][facet-name] facet whose memory pages will also be
    locked and registered with `cuMemHostRegister` which allows quicker
    and asynchronous copying to and from CUDA land.
    
    The default is :PINNED if available, because it's the most
    efficient. If pinning is not available, then it's :STATIC.

- [type] FOREIGN-ARRAY-STRATEGY

    One of :PINNED, :STATIC and :CUDA-HOST. See
    *FOREIGN-ARRAY-STRATEGY* for their semantics.

- [function] PINNING-SUPPORTED-P

    Return true iff the lisp implementation efficiently supports
    pinning lisp arrays. Pinning ensures that the garbage collector
    doesn't move the array in memory. Currently this is only supported on
    SBCL gencgc platforms.

- [function] FOREIGN-ROOM &KEY (STREAM \*STANDARD-OUTPUT\*) (VERBOSE T)

    Print a summary of foreign memory usage to STREAM. If VERBOSE, make
    the output human easily readable, else try to present it in a very
    concise way. Sample output with VERBOSE:
    
    ```
    Foreign memory usage:
    foreign arrays: 450 (used bytes: 3,386,295,808)
    ```
    
    The same data presented with VERBOSE false:
    
    ```
    f: 450 (3,386,295,808)
    ```


### CUDA

- [function] CUDA-AVAILABLE-P &KEY (DEVICE-ID 0)

    Check that a cuda context is already in initialized in the current
    thread or a device with DEVICE-ID is available.

- [macro] WITH-CUDA* (&KEY (ENABLED '\*CUDA-ENABLED\*) (DEVICE-ID '\*CUDA-DEFAULT-DEVICE-ID\*) (RANDOM-SEED '\*CUDA-DEFAULT-RANDOM-SEED\*) (N-RANDOM-STATES '\*CUDA-DEFAULT-N-RANDOM-STATES\*) N-POOL-BYTES) &BODY BODY

    Initializes CUDA with with all bells and whistles before BODY and
    deinitializes it after. Simply wrapping WITH-CUDA\* around a piece
    code is enough to make use of the first available CUDA device or
    fall back on blas and lisp kernels if there is none.
    
    If CUDA is already initialized, then it sets up a facet barrier
    which destroys CUDA-ARRAY and CUDA-HOST-ARRAY facets after ensuring
    that the [ARRAY][facet-name] facet is up-to-date.
    
    Else, if CUDA is available and ENABLED, then in addition to the
    facet barrier, a CUDA context is set up, *N-MEMCPY-HOST-TO-DEVICE*,
    *N-MEMCPY-DEVICE-TO-HOST* are bound to zero, a cublas handle
    created, and *CURAND-STATE* is bound to a CURAND-XORWOW-STATE with
    N-RANDOM-STATES, seeded with RANDOM-SEED, and allocation of device
    memory is limited to N-POOL-BYTES (NIL means no limit, see
    @MAT-CUDA-MEMORY-MANAGEMENT).
    
    Else - that is, if CUDA is not available, BODY is simply executed.

- [function] CALL-WITH-CUDA FN &KEY ((:ENABLED \*CUDA-ENABLED\*) \*CUDA-ENABLED\*) (DEVICE-ID \*CUDA-DEFAULT-DEVICE-ID\*) (RANDOM-SEED \*CUDA-DEFAULT-RANDOM-SEED\*) (N-RANDOM-STATES \*CUDA-DEFAULT-N-RANDOM-STATES\*) N-POOL-BYTES

    Like WITH-CUDA\*, but takes a no argument function instead of the
    macro's BODY.

- [variable] *CUDA-ENABLED* T

    Set or bind this to false to disable all use of cuda. If this is
    done from within WITH-CUDA*, then cuda becomes temporarily disabled.
    If this is done from outside WITH-CUDA*, then it changes the default
    values of the ENABLED argument of any future [WITH-CUDA\*][]s which
    turns off cuda initialization entirely.

- [accessor] CUDA-ENABLED MAT (:CUDA-ENABLED = \*DEFAULT-MAT-CUDA-ENABLED\*)

    The control provided by *CUDA-ENABLED* can be too
    coarse. This flag provides a per-object mechanism to turn cuda
    off. If it is set to NIL, then any operation that pays attention
    to this flag will not create or access the CUDA-ARRAY facet.
    Implementationally speaking, this is easily accomplished by using
    USE-CUDA-P.

- [variable] *DEFAULT-MAT-CUDA-ENABLED* T

    The default for [CUDA-ENABLED][(accessor mat)].

- [variable] *N-MEMCPY-HOST-TO-DEVICE* 0

    Incremented each time a host to device copy is performed. Bound to
    0 by WITH-CUDA\*. Useful for tracking down performance problems.

- [variable] *N-MEMCPY-DEVICE-TO-HOST* 0

    Incremented each time a device to host copy is performed. Bound to
    0 by WITH-CUDA\*. Useful for tracking down performance problems.

- [variable] *CUDA-DEFAULT-DEVICE-ID* 0

    The default value of WITH-CUDA\*'s :DEVICE-ID argument.

- [variable] *CUDA-DEFAULT-RANDOM-SEED* 1234

    The default value of WITH-CUDA\*'s :RANDOM-SEED argument.

- [variable] *CUDA-DEFAULT-N-RANDOM-STATES* 4096

    The default value of WITH-CUDA\*'s :N-RANDOM-STATES argument.

#### CUDA Memory Management

The GPU (called *device* in CUDA terminology) has its own memory
and it can only perform computation on data in this *device memory*
so there is some copying involved to and from main memory. Efficient
algorithms often allocate device memory up front and minimize the
amount of copying that has to be done by computing as much as
possible on the GPU.

MGL-MAT reduces the cost of device of memory allocations by
maintaining a cache of currently unused allocations from which it
first tries to satisfy allocation requests. The total size of all
the allocated device memory regions (be they in use or currently
unused but cached) is never more than N-POOL-BYTES as specified in
WITH-CUDA\*. N-POOL-BYTES being NIL means no limit.

- [condition] CUDA-OUT-OF-MEMORY STORAGE-CONDITION

    If an allocation request cannot be
    satisfied (either because of N-POOL-BYTES or physical device memory
    limits being reached), then CUDA-OUT-OF-MEMORY is signalled.

- [function] CUDA-ROOM &KEY (STREAM \*STANDARD-OUTPUT\*) (VERBOSE T)

    When CUDA is in use (see USE-CUDA-P), print a summary of memory
    usage in the current CUDA context to STREAM. If VERBOSE, make the
    output human easily readable, else try to present it in a very
    concise way. Sample output with VERBOSE:
    
    ```
    CUDA memory usage:
    device arrays: 450 (used bytes: 3,386,295,808, pooled bytes: 1,816,657,920)
    host arrays: 14640 (used bytes: 17,380,147,200)
    host->device copies: 154,102,488, device->host copies: 117,136,434
    ```
    
    The same data presented with VERBOSE false:
    
    ```
    d: 450 (3,386,295,808 + 1,816,657,920), h: 14640 (17,380,147,200)
    h->d: 154,102,488, d->h: 117,136,434
    ```


That's it about reducing the cost allocations. The other important
performance consideration, minimizing the amount copying done, is
very hard to do if the data doesn't fit in device memory which is
often a very limited resource. In this case the next best thing is
to do the copying concurrently with computation.

- [macro] WITH-SYNCING-CUDA-FACETS (MATS-TO-CUDA MATS-TO-CUDA-HOST &KEY (SAFEP '\*SYNCING-CUDA-FACETS-SAFE-P\*)) &BODY BODY

    Update CUDA facets in a possibly asynchronous way while BODY
    executes. Behind the scenes, a separate CUDA stream is used to copy
    between registered host memory and device memory. When
    WITH-SYNCING-CUDA-FACETS finishes either by returning normally or by
    a performing a non-local-exit the following are true:
    
    - All `MAT`s in MATS-TO-CUDA have an up-to-date
      [CUDA-ARRAY][facet-name] facet.
    
    - All `MAT`s in MATS-TO-CUDA-HOST have an up-to-date
      [CUDA-HOST-ARRAY][facet-name] facet and no
      [CUDA-ARRAY][facet-name].
    
    It is an error if the same matrix appears in both MATS-TO-CUDA and
    MATS-TO-CUDA-HOST, but the same matrix may appear any number of
    times in one of them.
    
    If SAFEP is true, then the all matrices in either of the two lists
    are effectively locked for output until WITH-SYNCING-CUDA-FACETS
    finishes. With SAFE NIL, unsafe accesses to facets of these matrices
    are not detected, but the whole operation has a bit less overhead.

- [variable] *SYNCING-CUDA-FACETS-SAFE-P* T

    The default value of the SAFEP argument of
    WITH-SYNCING-CUDA-FACETS.

Also note that often the easiest thing to do is to prevent the use
of CUDA (and consequently the creation of [CUDA-ARRAY][facet-name]
facets, and allocations). This can be done either by binding
*CUDA-ENABLED* to NIL or by setting CUDA-ENABLED to NIL on specific
matrices.

## Writing Extensions

New operations are usually implemented in lisp, CUDA, or by calling
a foreign function in, for instance, BLAS, CUBLAS, CURAND.

### Lisp Extensions

- [macro] DEFINE-LISP-KERNEL (NAME &KEY (CTYPES '(:FLOAT :DOUBLE))) (&REST PARAMS) &BODY BODY

    This is very much like DEFINE-CUDA-KERNEL but for normal lisp code.
    It knows how to deal with MAT objects and can define the same
    function for multiple CTYPES. Example:
    
    ```commonlisp
    (define-lisp-kernel (lisp-.+!)
        ((alpha single-float) (x :mat :input) (start-x index) (n index))
      (loop for xi of-type index upfrom start-x
              below (the! index (+ start-x n))
            do (incf (aref x xi) alpha)))
    ```
    
    Parameters are either of the form `(  :MAT )`. In the latter case, the appropriate
    CFFI pointer is passed to the kernel. `` is passed on to
    the WITH-FACET that's used to acquire the foreign array. Note that
    the return type is not declared.
    
    Both the signature and the body are written as if for single floats,
    but one function is defined for each ctype in CTYPES by transforming
    types, constants and code by substituting them with their ctype
    equivalents. Currently this means that one needs to write only one
    kernel for SINGLE-FLOAT and DOUBLE-FLOAT. All such functions get the
    declaration from *DEFAULT-LISP-KERNEL-DECLARATIONS*.
    
    Finally, a dispatcher function with NAME is defined which determines
    the ctype of the MAT objects passed for :MAT typed parameters. It's
    an error if they are not of the same type. Scalars declared
    SINGLE-FLOAT are coerced to that type and the appropriate kernel is
    called.

- [variable] *DEFAULT-LISP-KERNEL-DECLARATIONS* ((OPTIMIZE SPEED (SB-C::INSERT-ARRAY-BOUNDS-CHECKS 0)))

    These declarations are added automatically to kernel functions.

### CUDA Extensions

- [function] USE-CUDA-P &REST MATS

    Return true if cuda is enabled (*CUDA-ENABLED*), it's initialized
    and all MATS have [CUDA-ENABLED][(accessor mat)]. Operations of
    matrices use this to decide whether to go for the CUDA
    implementation or BLAS/Lisp. It's provided for implementing new
    operations.

- [function] CHOOSE-1D-BLOCK-AND-GRID N MAX-N-WARPS-PER-BLOCK

    Return two values, one suitable as the :BLOCK-DIM, the other as
    the :GRID-DIM argument for a cuda kernel call where both are
    one-dimensional (only the first element may be different from 1).
    
    The number of threads in a block is a multiple of *CUDA-WARP-SIZE*.
    The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*. This
    means that the kernel must be able handle any number of elements in
    each thread. For example, a strided kernel that adds a constant to
    each element of a length N vector looks like this:
    
    ```
    (let ((stride (* block-dim-x grid-dim-x)))
      (do ((i (+ (* block-dim-x block-idx-x) thread-idx-x)
              (+ i stride)))
          ((>= i n))
        (set (aref x i) (+ (aref x i) alpha))))
    ```
    
    It is often the most efficient to have MAX-N-WARPS-PER-BLOCK around
    4. Note that the maximum number of threads per block is limited by
    hardware (512 for compute capability < 2.0, 1024 for later
    versions), so *CUDA-MAX-N-BLOCKS* times MAX-N-WARPS-PER-BLOCK must
    not exceed that limit.

- [function] CHOOSE-2D-BLOCK-AND-GRID DIMENSIONS MAX-N-WARPS-PER-BLOCK

    Return two values, one suitable as the :BLOCK-DIM, the other as
    the :GRID-DIM argument for a cuda kernel call where both are
    two-dimensional (only the first two elements may be different from
    1).
    
    The number of threads in a block is a multiple of *CUDA-WARP-SIZE*.
    The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*.
    Currently - but this may change - the BLOCK-DIM-X is always
    *CUDA-WARP-SIZE* and GRID-DIM-X is always 1.
    
    This means that the kernel must be able handle any number of
    elements in each thread. For example, a strided kernel that adds a
    constant to each element of a HEIGHT\*WIDTH matrix looks like this:
    
    ```
    (let ((id-x (+ (* block-dim-x block-idx-x) thread-idx-x))
          (id-y (+ (* block-dim-y block-idx-y) thread-idx-y))
          (stride-x (* block-dim-x grid-dim-x))
          (stride-y (* block-dim-y grid-dim-y)))
      (do ((row id-y (+ row stride-y)))
          ((>= row height))
        (let ((i (* row width)))
          (do ((column id-x (+ column stride-x)))
              ((>= column width))
            (set (aref x i) (+ (aref x i) alpha))
            (incf i stride-x)))))
    ```


- [function] CHOOSE-3D-BLOCK-AND-GRID DIMENSIONS MAX-N-WARPS-PER-BLOCK

    Return two values, one suitable as the :BLOCK-DIM, the other as
    the :GRID-DIM argument for a cuda kernel call where both are
    two-dimensional (only the first two elements may be different from
    1).
    
    The number of threads in a block is a multiple of *CUDA-WARP-SIZE*.
    The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*.
    Currently - but this may change - the BLOCK-DIM-X is always
    *CUDA-WARP-SIZE* and GRID-DIM-X is always 1.
    
    This means that the kernel must be able handle any number of
    elements in each thread. For example, a strided kernel that adds a
    constant to each element of a THICKNESS \* HEIGHT \* WIDTH 3d array
    looks like this:
    
    ```
    (let ((id-x (+ (* block-dim-x block-idx-x) thread-idx-x))
          (id-y (+ (* block-dim-y block-idx-y) thread-idx-y))
          (id-z (+ (* block-dim-z block-idx-z) thread-idx-z))
          (stride-x (* block-dim-x grid-dim-x))
          (stride-y (* block-dim-y grid-dim-y))
          (stride-z (* block-dim-z grid-dim-z)))
      (do ((plane id-z (+ plane stride-z)))
          ((>= plane thickness))
        (do ((row id-y (+ row stride-y)))
            ((>= row height))
          (let ((i (* (+ (* plane height) row)
                      width)))
            (do ((column id-x (+ column stride-x)))
                ((>= column width))
              (set (aref x i) (+ (aref x i) alpha))
              (incf i stride-x))))))
    ```


- [macro] DEFINE-CUDA-KERNEL (NAME &KEY (CTYPES '(:FLOAT :DOUBLE))) (RETURN-TYPE PARAMS) &BODY BODY

    This is an extended CL-CUDA:DEFKERNEL macro. It knows how to deal
    with MAT objects and can define the same function for multiple
    CTYPES. Example:
    
    ```commonlisp
    (define-cuda-kernel (cuda-.+!)
        (void ((alpha float) (x :mat :input) (n int)))
      (let ((stride (* block-dim-x grid-dim-x)))
        (do ((i (+ (* block-dim-x block-idx-x) thread-idx-x)
                (+ i stride)))
            ((>= i n))
          (set (aref x i) (+ (aref x i) alpha)))))
    ```
    
    The signature looks pretty much like in CL-CUDA:DEFKERNEL, but
    parameters can take the form of `( :MAT )` too, in
    which case the appropriate CL-CUDA.DRIVER-API:CU-DEVICE-PTR is
    passed to the kernel. `` is passed on to the WITH-FACET
    that's used to acquire the cuda array.
    
    Both the signature and the body are written as if for single floats,
    but one function is defined for each ctype in CTYPES by transforming
    types, constants and code by substituting them with their ctype
    equivalents. Currently this means that one needs to write only one
    kernel for FLOAT and DOUBLE.
    
    Finally, a dispatcher function with NAME is defined which determines
    the ctype of the MAT objects passed for :MAT typed parameters. It's
    an error if they are not of the same type. Scalars declared
    FLOAT are coerced to that type and the appropriate
    kernel is called.

#### CUBLAS

In a WITH-CUDA\* @MAT-BLAS will automatically use CUBLAS. No need to
use these at all.

- [condition] CUBLAS-ERROR ERROR

- [reader] CUBLAS-ERROR-FUNCTION-NAME CUBLAS-ERROR (:FUNCTION-NAME)

- [reader] CUBLAS-ERROR-STATUS CUBLAS-ERROR (:STATUS)

- [variable] *CUBLAS-HANDLE*

- [function] CUBLAS-CREATE HANDLE

- [function] CUBLAS-DESTROY &KEY (HANDLE \*CUBLAS-HANDLE\*)

- [macro] WITH-CUBLAS-HANDLE NIL &BODY BODY

- [function] CUBLAS-GET-VERSION VERSION &KEY (HANDLE \*CUBLAS-HANDLE\*)

#### CURAND

This the low level CURAND API. You probably want @MAT-RANDOM
instead.

- [macro] WITH-CURAND-STATE (STATE) &BODY BODY

- [variable] *CURAND-STATE*

- [class] CURAND-XORWOW-STATE

- [reader] N-STATES CURAND-XORWOW-STATE (:N-STATES)

- [reader] STATES CURAND-XORWOW-STATE (:STATES)
# Cube Manual

###### \[in package MGL-CUBE\]
## Links

Here is the [official
repository](https://github.com/melisgl/mgl-mat) and the [HTML
documentation](http://melisgl.github.io/mgl-mat/cube-manual.html)
for the latest version.

## Introduction

This is the library on which MGL-MAT (see MGL-MAT:@MAT-MANUAL) is
built. The idea of automatically translating between various
representations may be useful for other applications, so this got
its own package and all ties to MGL-MAT has been severed.

This package defines CUBE, an abstract base class that provides a
framework for automatic conversion between various representations
of the same data. To define a cube, CUBE needs to be subclassed and
the @CUBE-FACET-EXTENSION-API be implemented.

If you are only interested in how to use cubes in general, read
@CUBE-BASICS, @CUBE-LIFETIME and @CUBE-FACET-BARRIER.

If you want to implement a new cube datatype, then see @CUBE-FACETS,
@CUBE-FACET-EXTENSION-API, and @CUBE-DEFAULT-CALL-WITH-FACET\*.

## Basics

Here we learn what a CUBE is and how to access the data in it with
WITH-FACET.

- [class] CUBE

    A datacube that has various representations of the
    same stuff. These representations go by the name \`facet'. Clients
    must use WITH-FACET to acquire a dynamic extent reference to a
    facet. With the information provided in the DIRECTION argument of
    WITH-FACET, the cube keeps track of which facets are up-to-date and
    copies data between them as necessary.
    
    The cube is an abstract class, it does not provide useful behavior
    in itself. One must subclass it and implement the
    @CUBE-FACET-EXTENSION-API.
    
    Also see @CUBE-LIFETIME and @CUBE-FACET-BARRIER.

- [macro] WITH-FACET (VAR (CUBE FACET-NAME &KEY (DIRECTION :IO) TYPE)) &BODY BODY

    Find or create the facet with FACET-NAME in CUBE and bind VAR to
    the representation of CUBE's data provided by that facet. This
    representation is called the facet's *value*. The value is to be
    treated as dynamic extent: it is not allowed to keep a reference to
    it. For the description of the DIRECTION parameter, see the type
    DIRECTION.
    
    If TYPE is specified, then VAR is declared to be of that type.

- [type] DIRECTION

    Used by WITH-FACET, DIRECTION can be :INPUT, :OUTPUT or :IO.
    
    - :INPUT promises that the facet will only be read and never
      written. Other up-to-date facets of the same cube remain
      up-to-date. If the facet in question is not up-to-date then data
      is copied to it from one of the up-to-date facets (see
      SELECT-COPY-SOURCE-FOR-FACET\*).
    
    - :OUTPUT promises that *all* data will be overwritten without
      reading any data. All up-to-date facets become non-up-to-date,
      while this facet is marked as up-to-date. No copying of data takes
      place.
    
    - :IO promises nothing about the type of access. All up-to-date
      facets become non-up-to-date, while this facet is marked as
      up-to-date. If the facet in question is not up-to-date then data
      is copied to it from one of the up-to-date facets (see
      SELECT-COPY-SOURCE-FOR-FACET\*).
    
    Any number of `WITH-FACET`s with direction :INPUT may be active at
    the same time, but :IO and :OUTPUT cannot coexists with another
    WITH-FACET regardless of the direction. The exception for this rule
    is that an inner WITH-FACET does not conflict with an enclosing
    WITH-FACET if they are for the same facet (but inner `WITH-FACET`s
    for another facet or for the same facet from another thread do).
    
    See CHECK-NO-WRITERS and CHECK-NO-WATCHERS called by
    @CUBE-DEFAULT-CALL-WITH-FACET\*.

- [macro] WITH-FACETS (&REST FACET-BINDING-SPECS) &BODY BODY

    A shorthand for writing nested WITH-FACET calls.
    
    ```
    (with-facet (f1 (c1 'name1 :direction :input))
      (with-facet (f2 (c2 'name2 :direction :output))
        ...))
    ```
    
    is equivalent to:
    
    ```
    (with-facets ((f1 (c1 'name1 :direction :input))
                  (f2 (c2 'name2 :direction :output)))
      ...)
    ```


## Synchronization

Cubes keep track of which facets are used, which are up-to-date to
be able to perform automatic translation between facets. WITH-FACET
and other operations access and make changes to this metadata so
thread safety is a concern. In this section, we detail how to relax
the default thread safety guarantees.

A related concern is async signal safety which arises most often
when C-c'ing or killing a thread or when the extremely nasty
WITH-TIMEOUT macro is used. In a nutshell, changes to cube metadata
are always made with interrupts disabled so things should be async
signal safe.

- [accessor] SYNCHRONIZATION CUBE (:SYNCHRONIZATION = \*DEFAULT-SYNCHRONIZATION\*)

    By default, setup and teardown of facets by
    WITH-FACET is performed in a thread safe way. Corrupting internal
    data structures of cubes is not fun, but in the name of
    performance, synchronization can be turned off either dynamically
    or on a per instance basis.
    
    If T, then access to cube metadata is always synchronized. If NIL,
    then never. If :MAYBE, then whether access is synchronized is
    determined by *MAYBE-SYNCHRONIZE-CUBE* that's true by default.
    
    The default is the value of *DEFAULT-SYNCHRONIZATION*
    that's :MAYBE by default.
    
    Note that the body of a WITH-FACET is never synchronized with
    anyone, apart from the implicit reader/writer conflict (see
    DIRECTION).

- [variable] *DEFAULT-SYNCHRONIZATION* :MAYBE

    The default value for SYNCHRONIZATION of new cubes.

- [variable] *MAYBE-SYNCHRONIZE-CUBE* T

    Determines whether access the cube metadata is synchronized for
    cubes with SYNCHRONIZATION :MAYBE.

## Facets

The basic currency for implementing new cube types is the FACET.
Simply using a cube only involves facet names and values, never
facets themselves.

- [function] FACETS CUBE

    Return the facets of CUBE.

- [function] FIND-FACET CUBE FACET-NAME

    Return the facet of CUBE for the facet with FACET-NAME or NIL if no
    such facet exists.

- [class] FACET STRUCTURE-OBJECT

    A cube has facets, as we discussed in @CUBE-BASICS. Facets holds
    the data in a particular representation, this is called the *value*
    of the facet. A facet holds one such value and some metadata
    pertaining to it: its FACET-NAME, whether it's
    up-to-date (FACET-UP-TO-DATE-P), etc. FACET objects are never seen
    when simply using a cube, they are for implementing the
    @CUBE-FACET-EXTENSION-API.

- [structure-accessor] FACET-NAME

    A symbol that uniquely identifies the facet within a cube.

- [structure-accessor] FACET-VALUE

    This is what's normally exposed by WITH-FACET.

- [structure-accessor] FACET-DESCRIPTION

    Returned by MAKE-FACET\* as its second value, this is an
    arbitrary object in which additional information can be
    stored.

- [structure-accessor] FACET-UP-TO-DATE-P

    Whether the cube has changed since this facet has been last
    updated. See FACET-UP-TO-DATE-P\*.

- [structure-accessor] FACET-N-WATCHERS

    The number of active `WITH-FACET`s. Updated by WATCH-FACET and
    UNWATCH-FACET.

- [structure-accessor] FACET-WATCHER-THREADS

    The threads (one for each watcher) that have active
    `WITH-FACET`s.

- [structure-accessor] FACET-DIRECTION

    The direction of the last WITH-FACET on this facet.

## Facet Extension API

Many of the generic functions in this section take FACET arguments.
FACET is a structure and is not intended to be subclassed. To be
able to add specialized methods, the name of the
facet ([FACET-NAME][structure-accessor]) is also passed as the
argument right in front of the corresponding facet argument.

In summary, define EQL specializers on facet name arguments, and use
FACET-DESCRIPTION to associate arbitrary information with facets.

- [generic-function] MAKE-FACET* CUBE FACET-NAME

    Called by WITH-FACET (or more directly WATCH-FACET)
    when there is no facet with FACET-NAME. As the first value, return a
    new object capable of storing CUBE's data in the facet with
    FACET-NAME. As the second value, return a facet description which
    will be available as FACET-DESCRIPTION. As the third value, return a
    generalized boolean indicating whether this facet must be explicitly
    destroyed (in which case a finalizer will be added to CUBE).

- [generic-function] DESTROY-FACET* FACET-NAME FACET

    Free the resources associated with FACET with
    FACET-NAME. The cube this facet belongs to is not among the
    parameters because this method can be called from a finalizer on the
    cube (so we can't have a reference to the cube portably) which also
    means that it may run in an unpredictable thread.

- [generic-function] COPY-FACET* CUBE FROM-FACET-NAME FROM-FACET TO-FACET-NAME TO-FACET

    Copy the CUBE's data from FROM-FACET with
    FROM-FACET-NAME to TO-FACET with TO-FACET-NAME. Called by
    WITH-FACET (or more directly WATCH-FACET) when necessary. FROM-FACET
    is what SELECT-COPY-SOURCE-FOR-FACET\* returned.

- [generic-function] CALL-WITH-FACET* CUBE FACET-NAME DIRECTION FN

    Call FN with an up-to-date FACET-VALUE that belongs
    to FACET-NAME of CUBE. WITH-FACET is directly implemented in terms
    of this function. See @CUBE-DEFAULT-CALL-WITH-FACET\* for the gory
    details.
    
    Specializations will most likely want to call the default
    implementation (with CALL-NEXT-METHOD) but with a lambda that
    transforms FACET-VALUE before passing it on to FN.

- [generic-function] FACET-UP-TO-DATE-P* CUBE FACET-NAME FACET

    Check if FACET with FACET-NAME has been updated
    since the latest change to CUBE (that is, since the access to other
    facets with DIRECTION of :IO or :OUTPUT). The default method simply
    calls FACET-UP-TO-DATE-P on FACET.
    
    One reason to specialize this is when some facets actually share
    common storage, so updating one make the other up-to-date as well.

- [generic-function] SELECT-COPY-SOURCE-FOR-FACET* CUBE TO-NAME TO-FACET

    Called when TO-FACET with TO-NAME is about to be
    updated by copying data from an up-to-date facet. Return the
    facet (or its name) from which data shall be copied. Note that if
    the returned facet is not FACET-UP-TO-DATE-P*, then it will be
    updated first and another SELECT-COPY-SOURCE-FOR-FACET* will take
    place, so be careful not to get into endless recursion. The default
    method simply returns the first up-to-date facet.

PAX integration follows, don't worry about it if you don't use PAX,
but you really should (see MGL-PAX::@MGL-PAX-MANUAL).

- [locative] FACET-NAME

    The FACET-NAME locative is to refer to stuff defined with
    DEFINE-FACET-NAME.

- [macro] DEFINE-FACET-NAME SYMBOL LAMBDA-LIST &BODY DOCSTRING

    Just a macro to document that SYMBOL refers to a facet name (as in
    the [FACET-NAME][locative]). This is totally confusing, so here is
    an example of how MGL-MAT (see MGL-MAT:@MAT-MANUAL) documents the
    MGL-MAT:BACKING-ARRAY facet:
    
    ```commonlisp
    (define-facet-name backing-array ()
      "The corresponding facet is a one dimensional lisp array.")
    ```
    
    Which makes it possible to refer to this definition (refer as in
    link and `M-.` to) MGL-MAT:BACKING-ARRAY facet-name. See
    MGL-PAX:@MGL-PAX-MANUAL for more.

Also see @CUBE-DEFAULT-CALL-WITH-FACET\*.

## The Default Implementation of CALL-WITH-FACET\*

- [method] CALL-WITH-FACET* (CUBE CUBE) FACET-NAME DIRECTION FN

    The default implementation of CALL-WITH-FACET\* is defined in terms
    of the WATCH-FACET and the UNWATCH-FACET generic functions. These
    can be considered part of the @CUBE-FACET-EXTENSION-API.

- [generic-function] WATCH-FACET CUBE FACET-NAME DIRECTION

    This is what the default CALL-WITH-FACET\* method,
    in terms of which WITH-FACET is implemented, calls first. The
    default method takes care of creating facets, copying and tracking
    up-to-dateness.
    
    Calls CHECK-NO-WRITERS (unless *LET-INPUT-THROUGH-P*) and
    CHECK-NO-WATCHERS (unless *LET-OUTPUT-THROUGH-P*) depending on
    DIRECTION to detect situations with a writer being concurrent to
    readers/writers because that would screw up the tracking of
    up-to-dateness.
    
    The default implementation should suffice most of the time.
    MGL-MAT specializes it to override the DIRECTION arg, if
    it's :OUTPUT but not all elements are visible due to reshaping, so
    that invisible elements are still copied over.

- [generic-function] UNWATCH-FACET CUBE FACET-NAME

    This is what the default CALL-WITH-FACET\* method,
    in terms of which WITH-FACET is implemented, calls last. The default
    method takes care of taking down facets. External resource managers
    may want to hook into this to handle unused facets.

- [variable] *LET-INPUT-THROUGH-P* NIL

    If true, WITH-FACETS (more precisely, the default implementation of
    CALL-WITH-FACET\*) with :DIRECTION :INPUT does not call
    CHECK-NO-WRITERS. This knob is intended to be bound locally for
    debugging purposes.

- [variable] *LET-OUTPUT-THROUGH-P* NIL

    If true, WITH-FACETS (more precisely, the default implementation of
    CALL-WITH-FACET\*) with :DIRECTION :IO or :OUTPUT does not call
    CHECK-NO-WATCHERS. This knob is intended to be bound locally for
    debugging purposes.

- [function] CHECK-NO-WRITERS CUBE FACET-NAME MESSAGE-FORMAT &REST MESSAGE-ARGS

    Signal an error if CUBE has facets (with names other than
    FACET-NAME) being written (i.e. direction is :IO or :OUTPUT).

- [function] CHECK-NO-WATCHERS CUBE FACET-NAME MESSAGE-FORMAT &REST MESSAGE-ARGS

    Signal an error if CUBE has facets (with names other than
    FACET-NAME) being regardless of the direction.

## Lifetime

Lifetime management of facets is manual (but facets of garbage
cubes are freed automatically by a finalizer, see MAKE-FACET\*). One
may destroy a single facet or all facets of a cube with
DESTROY-FACET and DESTROY-CUBE, respectively. Also see
@CUBE-FACET-BARRIER.

- [function] DESTROY-FACET CUBE FACET-NAME

    Free resources associated with the facet with FACET-NAME and remove
    it from FACETS of CUBE.

- [function] DESTROY-CUBE CUBE

    Destroy all facets of CUBE with DESTROY-FACET.

In some cases it is useful to declare the intent to use a facet in
the future to prevent its destruction. Hence, every facet has
reference count which starts from 0. The reference count is
incremented and decremented by ADD-FACET-REFERENCE-BY-NAME and
REMOVE-FACET-REFERENCE-BY-NAME, respectively. If it is positive,
then the facet will not be destroyed by explicit DESTROY-FACET and
DESTROY-CUBE calls, but it will still be destroyed by the finalizer
to prevent resource leaks caused by stray references.

- [function] ADD-FACET-REFERENCE-BY-NAME CUBE FACET-NAME

    Make sure FACET-NAME exists on CUBE and increment its reference
    count. Return the FACET behind FACET-NAME.

- [function] REMOVE-FACET-REFERENCE-BY-NAME CUBE FACET-NAME

    Decrement the reference count of the facet with FACET-NAME of CUBE.
    It is an error if the facet does not exists or if the reference
    count becomes negative.

- [function] REMOVE-FACET-REFERENCE FACET

    Decrement the reference count of FACET. It is an error if the facet
    is already destroyed or if the reference count becomes negative.
    This function has the same purpose as
    REMOVE-FACET-REFERENCE-BY-NAME, but by having a single FACET
    argument, it's more suited for use in finalizers because it does not
    keep the whole CUBE alive.

### Facet Barriers

A facility to control lifetime of facets tied to a dynamic extent.
Also see @CUBE-LIFETIME.

- [macro] WITH-FACET-BARRIER (CUBE-TYPE ENSURES DESTROYS) &BODY BODY

    When BODY exits, destroy facets which:
    
    - are of cubes with CUBE-TYPE
    
    - have a facet name among DESTROYS
    
    - were created in the dynamic extent of BODY
    
    Before destroying the facets, it is ensured that facets with names
    among ENSURES are up-to-date. WITH-FACET-BARRIERs can be nested, in
    case of multiple barriers matching the cube's type and the created
    facet's name, the innermost one takes precedence.
    
    The purpose of this macro is twofold. First, it makes it easy to
    temporarily work with a certain facet of many cubes without leaving
    newly created facets around. Second, it can be used to make sure
    that facets whose extent is tied to some dynamic boundary (such as
    the thread in which they were created) are destroyed.

- [function] COUNT-BARRED-FACETS FACET-NAME &KEY (TYPE 'CUBE)

    Count facets with FACET-NAME of cubes of TYPE which will be
    destroyed by a facet barrier.

* * *
###### \[generated by [MGL-PAX](https://github.com/melisgl/mgl-pax)\]


2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 mgl-mat

MAT is library for working with multi-dimensional
arrays which supports efficient interfacing to foreign and CUDA code. BLAS and CUBLAS bindings are available.

Author

Gábor Melis <mega@retes.hu>

Contact

mega@retes.hu

Home Page

http://melisgl.github.io/mgl-mat

Source Control

(GIT https://github.com/melisgl/mgl-mat.git)

Bug Tracker

https://github.com/melisgl/mgl-mat/issues

License

MIT, see COPYING.

Version

0.1.0

Dependencies
  • alexandria (system).
  • bordeaux-threads (system).
  • cffi (system).
  • cffi-grovel (system).
  • cl-cuda (system).
  • flexi-streams (system).
  • ieee-floats (system).
  • lla (system).
  • mgl-pax (system).
  • static-vectors (system).
  • trivial-garbage (system).
Source

mgl-mat.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 mgl-mat/src

Source

mgl-mat.asd.

Parent Component

mgl-mat (system).

Child Components

4 Files

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


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 mgl-mat/mgl-mat.asd

Source

mgl-mat.asd.

Parent Component

mgl-mat (system).

ASDF Systems

mgl-mat.


4.1.2 mgl-mat/src/package.lisp

Source

mgl-mat.asd.

Parent Component

src (module).

Packages

4.1.3 mgl-mat/src/cube.lisp

Dependency

package.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.4 mgl-mat/src/util.lisp

Dependency

cube.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.5 mgl-mat/src/blas.lisp

Dependency

util.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Internals

4.1.6 mgl-mat/src/blas-functions.lisp

Dependency

blas.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Internals

4.1.7 mgl-mat/src/cublas-grovel.lisp

If Feature

:cuda-sdk

Dependency

blas-functions.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).


4.1.8 mgl-mat/src/cublas.lisp

Dependencies
Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.9 mgl-mat/src/cublas-functions.lisp

Dependency

cublas.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Internals

4.1.10 mgl-mat/src/foreign.lisp

Dependency

cublas-functions.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.11 mgl-mat/src/cuda-early.lisp

Dependency

foreign.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.12 mgl-mat/src/cuda-kernel.lisp

Dependency

cuda-early.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface

define-cuda-kernel (macro).

Internals

4.1.13 mgl-mat/src/lisp-kernel.lisp

Dependency

cuda-kernel.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.14 mgl-mat/src/curand.lisp

Dependency

lisp-kernel.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.15 mgl-mat/src/cuda-late.lisp

Dependency

curand.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

with-cuda-stream (macro).


4.1.16 mgl-mat/src/vec.lisp

Dependency

cuda-late.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.17 mgl-mat/src/mat.lisp

Dependency

vec.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.18 mgl-mat/src/convolve.lisp

Dependency

mat.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.19 mgl-mat/src/max-pool.lisp

Dependency

convolve.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.20 mgl-mat/src/doc.lisp

Dependency

max-pool.lisp (file).

Source

mgl-mat.asd.

Parent Component

src (module).

Internals

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 mgl-cube

See MGL-CUBE:@CUBE-MANUAL.

Source

package.lisp.

Use List
  • common-lisp.
  • mgl-pax.
Used By List

mgl-mat.

Public Interface
Internals

Previous: , Up: Packages   [Contents][Index]

5.2 mgl-mat

See MGL-MAT:@MAT-MANUAL.

Source

package.lisp.

Use List
  • cl-cuda.
  • common-lisp.
  • mgl-cube.
  • mgl-pax.
Public Interface
Internals

6 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


Next: , Previous: , Up: Public Interface   [Contents][Index]

6.1.1 Special variables

Special Variable: *cublas-handle*
Package

mgl-mat.

Source

cublas.lisp.

Special Variable: *cuda-default-device-id*

The default value of WITH-CUDA*’s :DEVICE-ID argument.

Package

mgl-mat.

Source

cuda-late.lisp.

Special Variable: *cuda-default-n-random-states*

The default value of WITH-CUDA*’s :N-RANDOM-STATES argument.

Package

mgl-mat.

Source

cuda-late.lisp.

Special Variable: *cuda-default-random-seed*

The default value of WITH-CUDA*’s :RANDOM-SEED argument.

Package

mgl-mat.

Source

cuda-late.lisp.

Special Variable: *cuda-enabled*

Set or bind this to false to disable all use of cuda. If this is done from within WITH-CUDA*, then cuda becomes temporarily disabled. If this is done from outside WITH-CUDA*, then it changes the default values of the ENABLED argument of any future [WITH-CUDA*][]s which turns off cuda initialization entirely.

Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *curand-state*
Package

mgl-mat.

Source

curand.lisp.

Special Variable: *default-lisp-kernel-declarations*

These declarations are added automatically to kernel functions.

Package

mgl-mat.

Source

lisp-kernel.lisp.

Special Variable: *default-mat-ctype*

By default MATs are created with this ctype. One of :FLOAT or :DOUBLE.

Package

mgl-mat.

Source

util.lisp.

Special Variable: *default-mat-cuda-enabled*

The default for [CUDA-ENABLED][(accessor mat)].

Package

mgl-mat.

Source

mat.lisp.

Special Variable: *default-synchronization*

The default value for SYNCHRONIZATION of new cubes.

Package

mgl-cube.

Source

cube.lisp.

Special Variable: *foreign-array-strategy*

One of :PINNED, :STATIC and :CUDA-HOST (see type FOREIGN-ARRAY-STRATEGY). This variable controls how foreign arrays are handled and it can be changed at any time.

If it’s :PINNED (only supported if (PINNING-SUPPORTED-P), then no separate storage is allocated for the foreign array. Instead, it aliases the lisp array (via the BACKING-ARRAY facet).

If it’s :STATIC, then the lisp backing arrays are allocated statically via the static-vectors library. On some implementations, explicit freeing of static vectors is necessary, this is taken care of by finalizers or can be controlled with WITH-FACET-BARRIER. DESTROY-CUBE and DESTROY-FACET may also be of help.

:CUDA-HOST is the same as :STATIC, but any copies to/from the GPU (i.e. the [CUDA-ARRAY][facet-name] facet) will be done via the [CUDA-HOST-ARRAY][facet-name] facet whose memory pages will also be locked and registered with ‘cuMemHostRegister‘ which allows quicker and asynchronous copying to and from CUDA land.

The default is :PINNED if available, because it’s the most efficient. If pinning is not available, then it’s :STATIC.

Package

mgl-mat.

Source

foreign.lisp.

Special Variable: *let-input-through-p*

If true, WITH-FACETS (more precisely, the default implementation of CALL-WITH-FACET*) with :DIRECTION :INPUT does not call CHECK-NO-WRITERS. This knob is intended to be bound locally for debugging purposes.

Package

mgl-cube.

Source

cube.lisp.

Special Variable: *let-output-through-p*

If true, WITH-FACETS (more precisely, the default implementation of CALL-WITH-FACET*) with :DIRECTION :IO or :OUTPUT does not call CHECK-NO-WATCHERS. This knob is intended to be bound locally for debugging purposes.

Package

mgl-cube.

Source

cube.lisp.

Special Variable: *mat-headers*

If true, a header with MAT-CTYPE and MAT-SIZE is written by WRITE-MAT before the contents and READ-MAT checks that these match the matrix into which it is reading.

Package

mgl-mat.

Source

mat.lisp.

Special Variable: *maybe-synchronize-cube*

Determines whether access the cube metadata is synchronized for cubes with SYNCHRONIZATION :MAYBE.

Package

mgl-cube.

Source

cube.lisp.

Special Variable: *n-memcpy-device-to-host*

Incremented each time a device to host copy is performed. Bound to 0 by WITH-CUDA*. Useful for tracking down performance problems.

Package

mgl-mat.

Source

cuda-late.lisp.

Special Variable: *n-memcpy-host-to-device*

Incremented each time a host to device copy is performed. Bound to 0 by WITH-CUDA*. Useful for tracking down performance problems.

Package

mgl-mat.

Source

cuda-late.lisp.

Special Variable: *print-mat*

Controls whether the contents of a MAT object are printed as an array (subject to the standard printer control variables).

Package

mgl-mat.

Source

mat.lisp.

Special Variable: *print-mat-facets*

Controls whether a summary of existing and up-to-date facets is printed when a MAT object is printed. The summary that looks like ‘ABcfh‘ indicates that all five facets ([ARRAY][facet-name], [BACKING-ARRAY][facet-name], [CUDA-ARRAY][facet-name], [FOREIGN-ARRAY][facet-name], [CUDA-HOST-ARRAY][facet-name]) are present and the first two are up-to-date. A summary of a single #- indicates that there are no facets.

Package

mgl-mat.

Source

mat.lisp.

Special Variable: *supported-ctypes*
Package

mgl-mat.

Source

util.lisp.

Special Variable: *syncing-cuda-facets-safe-p*

The default value of the SAFEP argument of WITH-SYNCING-CUDA-FACETS.

Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: @cube-basics
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-default-call-with-facet*
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-facet-barrier
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-facet-extension-api
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-facets
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-introduction
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-lifetime
Package

mgl-cube.

Source

cube.lisp.

Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-manual
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @cube-synchronization
Package

mgl-cube.

Source

cube.lisp.

Special Variable: @mat-assembling
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-basics
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-blas
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-caching
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-ctypes
Package

mgl-mat.

Source

util.lisp.

Special Variable: @mat-cublas
Package

mgl-mat.

Source

cublas.lisp.

Special Variable: @mat-cuda
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: @mat-cuda-extensions
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: @mat-cuda-memory-management
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: @mat-curand
Package

mgl-mat.

Source

curand.lisp.

Special Variable: @mat-debugging
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-destructive-api
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-extensions
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-facet-api
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-facets
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-foreign
Package

mgl-mat.

Source

foreign.lisp.

Special Variable: @mat-installation
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-introduction
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-io
Package

mgl-mat.

Source

mat.lisp.

Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-lisp-extensions
Package

mgl-mat.

Source

lisp-kernel.lisp.

Special Variable: @mat-manual
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-mappings
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-non-destructive-api
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-printing
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-random
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-shaping
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-shaping-comparison-to-lisp
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-shaping-destructive
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-shaping-functional
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-tutorial
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-what-is-it
Package

mgl-mat.

Source

mat.lisp.

Special Variable: @mat-what-kind-of-matrices
Package

mgl-mat.

Source

mat.lisp.


6.1.2 Macros

Macro: define-cuda-kernel ((name &key ctypes) (return-type params) &body body)

This is an extended CL-CUDA:DEFKERNEL macro. It knows how to deal with MAT objects and can define the same function for multiple CTYPES. Example:

“‘commonlisp
(define-cuda-kernel (cuda-.+!)
(void ((alpha float) (x :mat :input) (n int)))
(let ((stride (* block-dim-x grid-dim-x)))
(do ((i (+ (* block-dim-x block-idx-x) thread-idx-x)
(+ i stride)))
((>= i n))
(set (aref x i) (+ (aref x i) alpha)))))
“‘

The signature looks pretty much like in CL-CUDA:DEFKERNEL, but parameters can take the form of ‘(<NAME> :MAT <DIRECTION>)‘ too, in which case the appropriate CL-CUDA.DRIVER-API:CU-DEVICE-PTR is passed to the kernel. ‘<DIRECTION>‘ is passed on to the WITH-FACET that’s used to acquire the cuda array.

Both the signature and the body are written as if for single floats, but one function is defined for each ctype in CTYPES by transforming types, constants and code by substituting them with their ctype equivalents. Currently this means that one needs to write only one kernel for [FLOAT][dislocated] and DOUBLE.

Finally, a dispatcher function with NAME is defined which determines the ctype of the MAT objects passed for :MAT typed parameters. It’s an error if they are not of the same type. Scalars declared [FLOAT][dislocated] are coerced to that type and the appropriate kernel is called.

Package

mgl-mat.

Source

cuda-kernel.lisp.

Macro: define-facet-name (symbol lambda-list &body docstring)

Just a macro to document that SYMBOL refers to a facet name (as in the [FACET-NAME][locative]). This is totally confusing, so here is an example of how \MGL-MAT (see MGL-MAT:@MAT-MANUAL) documents the MGL-MAT:BACKING-ARRAY facet:

“‘commonlisp
(define-facet-name backing-array ()
"The corresponding facet is a one dimensional lisp array.") “‘

Which makes it possible to refer to this definition (refer as in link and ‘M-.‘ to) MGL-MAT:BACKING-ARRAY facet-name. See MGL-PAX:@MGL-PAX-MANUAL for more.

Package

mgl-cube.

Source

cube.lisp.

Macro: define-lisp-kernel ((name &key ctypes) (&rest params) &body body)

This is very much like DEFINE-CUDA-KERNEL but for normal lisp code. It knows how to deal with MAT objects and can define the same function for multiple CTYPES. Example:

“‘commonlisp
(define-lisp-kernel (lisp-.+!)
((alpha single-float) (x :mat :input) (start-x index) (n index)) (loop for xi of-type index upfrom start-x
below (the! index (+ start-x n))
do (incf (aref x xi) alpha)))
“‘

Parameters are either of the form ‘(<NAME> <LISP-TYPE)‘
or ‘(<NAME> :MAT <DIRECTION>)‘. In the latter case, the appropriate CFFI pointer is passed to the kernel. ‘<DIRECTION>‘ is passed on to the WITH-FACET that’s used to acquire the foreign array. Note that the return type is not declared.

Both the signature and the body are written as if for single floats, but one function is defined for each ctype in CTYPES by transforming types, constants and code by substituting them with their ctype equivalents. Currently this means that one needs to write only one kernel for SINGLE-FLOAT and DOUBLE-FLOAT. All such functions get the declaration from *DEFAULT-LISP-KERNEL-DECLARATIONS*.

Finally, a dispatcher function with NAME is defined which determines the ctype of the MAT objects passed for :MAT typed parameters. It’s an error if they are not of the same type. Scalars declared SINGLE-FLOAT are coerced to that type and the appropriate kernel is called.

Package

mgl-mat.

Source

lisp-kernel.lisp.

Macro: with-cublas-handle (() &body body)
Package

mgl-mat.

Source

cublas.lisp.

Macro: with-cuda* ((&key enabled device-id random-seed n-random-states n-pool-bytes) &body body)

Initializes CUDA with with all bells and whistles before BODY and deinitializes it after. Simply wrapping WITH-CUDA* around a piece code is enough to make use of the first available CUDA device or fall back on blas and lisp kernels if there is none.

If CUDA is already initialized, then it sets up a facet barrier which destroys CUDA-ARRAY and CUDA-HOST-ARRAY facets after ensuring that the [ARRAY][facet-name] facet is up-to-date.

Else, if CUDA is available and ENABLED, then in addition to the facet barrier, a CUDA context is set up, *N-MEMCPY-HOST-TO-DEVICE*, *N-MEMCPY-DEVICE-TO-HOST* are bound to zero, a cublas handle created, and *CURAND-STATE* is bound to a CURAND-XORWOW-STATE with N-RANDOM-STATES, seeded with RANDOM-SEED, and allocation of device memory is limited to N-POOL-BYTES (NIL means no limit, see @MAT-CUDA-MEMORY-MANAGEMENT).

Else - that is, if CUDA is not available, BODY is simply executed.

Package

mgl-mat.

Source

cuda-late.lisp.

Macro: with-curand-state ((state) &body body)
Package

mgl-mat.

Source

curand.lisp.

Macro: with-facet ((var (cube facet-name &key direction type)) &body body)

Find or create the facet with FACET-NAME in CUBE and bind VAR to the representation of CUBE’s data provided by that facet. This representation is called the facet’s _value_. The value is to be treated as dynamic extent: it is not allowed to keep a reference to it. For the description of the DIRECTION parameter, see the type DIRECTION.

If TYPE is specified, then VAR is declared to be of that type.

Package

mgl-cube.

Source

cube.lisp.

Macro: with-facet-barrier ((cube-type ensures destroys) &body body)

When BODY exits, destroy facets which:

- are of cubes with CUBE-TYPE

- have a facet name among DESTROYS

- were created in the dynamic extent of BODY

Before destroying the facets, it is ensured that facets with names among ENSURES are up-to-date. WITH-FACET-BARRIERs can be nested, in case of multiple barriers matching the cube’s type and the created facet’s name, the innermost one takes precedence.

The purpose of this macro is twofold. First, it makes it easy to temporarily work with a certain facet of many cubes without leaving newly created facets around. Second, it can be used to make sure that facets whose extent is tied to some dynamic boundary (such as the thread in which they were created) are destroyed.

Package

mgl-cube.

Source

cube.lisp.

Macro: with-facets ((&rest facet-binding-specs) &body body)

A shorthand for writing nested WITH-FACET calls.

“‘
(with-facet (f1 (c1 ’name1 :direction :input)) (with-facet (f2 (c2 ’name2 :direction :output)) ...))
“‘

is equivalent to:

“‘
(with-facets ((f1 (c1 ’name1 :direction :input)) (f2 (c2 ’name2 :direction :output))) ...)
“‘

Package

mgl-cube.

Source

cube.lisp.

Macro: with-mat-counters ((&key count n-bytes) &body body)

Count all MAT allocations and also the number of bytes they may require. _May require_ here really means an upper bound, because ‘(MAKE-MAT (EXPT 2 60))‘ doesn’t actually uses memory until one of its facets is accessed (don’t simply evaluate it though, printing the result will access the [ARRAY][facet-name] facet if *PRINT-MAT*). Also, while facets today all require the same number of bytes, this may change in the future. This is a debugging tool, don’t use it in production.

“‘cl-transcript
(with-mat-counters (:count count :n-bytes n-bytes)
(assert (= count 0))
(assert (= n-bytes 0))
(make-mat ’(2 3) :ctype :double)
(assert (= count 1))
(assert (= n-bytes (* 2 3 8)))
(with-mat-counters (:n-bytes n-bytes-1 :count count-1) (make-mat ’7 :ctype :float)
(assert (= count-1 1))
(assert (= n-bytes-1 (* 7 4))))
(assert (= n-bytes (+ (* 2 3 8) (* 7 4))))
(assert (= count 2)))
“‘

Package

mgl-mat.

Source

mat.lisp.

Macro: with-ones ((var dimensions &key ctype place) &body body)

Bind VAR to a matrix of DIMENSIONS whose every element is 1. The matrix is cached for efficiency.

Package

mgl-mat.

Source

mat.lisp.

Macro: with-shape-and-displacement ((mat &optional dimensions displacement) &body body)

Reshape and displace MAT if DIMENSIONS and/or DISPLACEMENT is given and restore the original shape and displacement after BODY is executed. If neither is specificed, then nothing will be changed, but BODY is still allowed to alter the shape and displacement.

Package

mgl-mat.

Source

mat.lisp.

Macro: with-syncing-cuda-facets ((mats-to-cuda mats-to-cuda-host &key safep) &body body)

Update CUDA facets in a possibly asynchronous way while BODY executes. Behind the scenes, a separate CUDA stream is used to copy between registered host memory and device memory. When WITH-SYNCING-CUDA-FACETS finishes either by returning normally or by a performing a non-local-exit the following are true:

- All ‘MAT‘s in MATS-TO-CUDA have an up-to-date [CUDA-ARRAY][facet-name] facet.

- All ‘MAT‘s in MATS-TO-CUDA-HOST have an up-to-date [CUDA-HOST-ARRAY][facet-name] facet and no [CUDA-ARRAY][facet-name].

It is an error if the same matrix appears in both MATS-TO-CUDA and MATS-TO-CUDA-HOST, but the same matrix may appear any number of times in one of them.

If SAFEP is true, then the all matrices in either of the two lists are effectively locked for output until WITH-SYNCING-CUDA-FACETS finishes. With SAFE NIL, unsafe accesses to facets of these matrices are not detected, but the whole operation has a bit less overhead.

Package

mgl-mat.

Source

cuda-early.lisp.

Macro: with-thread-cached-mat ((var dimensions &rest args &key place ctype displacement max-size initial-element initial-contents) &body body)

Bind VAR to a matrix of DIMENSIONS, CTYPE, etc. Cache this matrix, and possibly reuse it later by reshaping it. When BODY exits the cached object is updated with the binding of VAR which BODY may change.

There is a separate cache for each thread and each ‘PLACE‘ (under EQ). Since every cache holds exactly one MAT per CTYPE, nested WITH-THREAD-CACHED-MAT often want to use different ‘PLACE‘s. By convention, these places are called ‘:SCRATCH-1‘, ‘:SCRATCH-2‘, etc.

Package

mgl-mat.

Source

mat.lisp.

Macro: with-thread-cached-mats (specs &body body)

A shorthand for writing nested WITH-THREAD-CACHED-MAT calls.

“‘
(with-thread-cached-mat (a ...) (with-thread-cached-mat (b ...)
...))
“‘

is equivalent to:

“‘
(with-thread-cached-mat ((a ...)
(b ...))
...)
“‘

Package

mgl-mat.

Source

mat.lisp.


6.1.3 Setf expanders

Setf Expander: (setf mref) (mat &rest indices)
Package

mgl-mat.

Source

mat.lisp.

Reader

mref (function).

Setf Expander: (setf row-major-mref) (mat index)
Package

mgl-mat.

Source

mat.lisp.

Reader

row-major-mref (function).

Writer

set-row-major-mref (function).


6.1.4 Ordinary functions

Function: .*! (x y)
Package

mgl-mat.

Source

mat.lisp.

Function: .+! (alpha x)

Add the scalar ALPHA to each element of X destructively modifying X. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .<! (x y)

For each element of X and Y set Y to 1 if the element in Y is greater than the element in X, and to 0 otherwise. Return Y.

Package

mgl-mat.

Source

mat.lisp.

Function: .cos! (x &key n)

Apply COS elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .cosh! (x &key n)

Apply COSH elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .exp! (x &key n)

Apply EXP elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .expt! (x power)

Raise matrix X to POWER in an elementwise manner. Return X. Note that CUDA and non-CUDA implementations may disagree on the treatment of NaNs, infinities and complex results. In particular, the lisp implementation always computes the REALPART of the results while CUDA’s pow() returns NaNs instead of complex numbers.

Package

mgl-mat.

Source

mat.lisp.

Function: .inv! (x &key n)

Set X to its elementwise inverse ‘(/ 1 X)‘. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .log! (x &key n)

Set X to its elementwise natural logarithm. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .logistic! (x &key n)

Destructively apply the logistic function to X in an elementwise manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .max! (alpha x)

Set each element of X to ALPHA if it’s less than ALPHA. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .min! (alpha x)

Set each element of X to ALPHA if it’s greater than ALPHA. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .sin! (x &key n)

Apply SIN elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .sinh! (x &key n)

Apply SINH elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .sqrt! (x &key n)

Set X to its elementwise square root. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .square! (x &key n)

Set X to its elementwise square. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .tan! (x &key n)

Apply TAN elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: .tanh! (x &key n)

Apply TANH elementwise to X in a destructive manner. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: add-facet-reference-by-name (cube facet-name)

Make sure FACET-NAME exists on CUBE and increment its reference count. Return the FACET behind FACET-NAME.

Package

mgl-cube.

Source

cube.lisp.

Function: add-sign! (alpha a beta b)

Add the elementwise sign (-1, 0 or 1 for negative, zero and positive numbers respectively) of A times ALPHA to BETA * B. Return B.

Package

mgl-mat.

Source

mat.lisp.

Function: adjust! (mat dimensions displacement &key destroy-old-p)

Like RESHAPE-AND-DISPLACE! but creates a new matrix if MAT isn’t large enough. If a new matrix is created, the contents are not copied over and the old matrix is destroyed with DESTROY-CUBE if DESTROY-OLD-P.

Package

mgl-mat.

Source

mat.lisp.

Function: array-to-mat (array &key ctype synchronization)

Create a MAT that’s equivalent to ARRAY. Displacement of the created array will be 0 and the size will be equal to ARRAY-TOTAL-SIZE. If CTYPE is non-nil, then it will be the ctype of the new matrix. Else ARRAY’s type is converted to a ctype. If there is no corresponding ctype, then *DEFAULT-MAT-CTYPE* is used. Elements of ARRAY are coerced to CTYPE.

Also see @CUBE-SYNCHRONIZATION.

Package

mgl-mat.

Source

mat.lisp.

Function: asum (x &key n incx)

Return the l1 norm of X, that is, sum of the absolute values of its elements.

Package

mgl-mat.

Source

mat.lisp.

Function: axpy! (alpha x y &key n incx incy)

Set Y to ALPHA * X + Y. Return Y.

Package

mgl-mat.

Source

mat.lisp.

Function: call-with-cuda (fn &key enabled device-id random-seed n-random-states n-pool-bytes)

Like WITH-CUDA*, but takes a no argument function instead of the macro’s BODY.

Package

mgl-mat.

Source

cuda-late.lisp.

Function: check-no-watchers (cube facet-name message-format &rest message-args)

Signal an error if CUBE has facets (with names other than FACET-NAME) being regardless of the direction.

Package

mgl-cube.

Source

cube.lisp.

Function: check-no-writers (cube facet-name message-format &rest message-args)

Signal an error if CUBE has facets (with names other than FACET-NAME) being written (i.e. direction is :IO or :OUTPUT).

Package

mgl-cube.

Source

cube.lisp.

Function: choose-1d-block-and-grid (n max-n-warps-per-block)

Return two values, one suitable as the :BLOCK-DIM, the other as the :GRID-DIM argument for a cuda kernel call where both are one-dimensional (only the first element may be different from 1).

The number of threads in a block is a multiple of *CUDA-WARP-SIZE*. The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*. This means that the kernel must be able handle any number of elements in each thread. For example, a strided kernel that adds a constant to each element of a length N vector looks like this:

“‘
(let ((stride (* block-dim-x grid-dim-x)))
(do ((i (+ (* block-dim-x block-idx-x) thread-idx-x)
(+ i stride)))
((>= i n))
(set (aref x i) (+ (aref x i) alpha))))
“‘

It is often the most efficient to have MAX-N-WARPS-PER-BLOCK around 4. Note that the maximum number of threads per block is limited by hardware (512 for compute capability < 2.0, 1024 for later versions), so *CUDA-MAX-N-BLOCKS* times MAX-N-WARPS-PER-BLOCK must not exceed that limit.

Package

mgl-mat.

Source

cuda-early.lisp.

Function: choose-2d-block-and-grid (dimensions max-n-warps-per-block)

Return two values, one suitable as the :BLOCK-DIM, the other as the :GRID-DIM argument for a cuda kernel call where both are two-dimensional (only the first two elements may be different from 1).

The number of threads in a block is a multiple of *CUDA-WARP-SIZE*. The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*. Currently - but this may change - the BLOCK-DIM-X is always *CUDA-WARP-SIZE* and GRID-DIM-X is always 1.

This means that the kernel must be able handle any number of elements in each thread. For example, a strided kernel that adds a constant to each element of a HEIGHT*WIDTH matrix looks like this:

“‘
(let ((id-x (+ (* block-dim-x block-idx-x) thread-idx-x))
(id-y (+ (* block-dim-y block-idx-y) thread-idx-y)) (stride-x (* block-dim-x grid-dim-x))
(stride-y (* block-dim-y grid-dim-y)))
(do ((row id-y (+ row stride-y)))
((>= row height))
(let ((i (* row width)))
(do ((column id-x (+ column stride-x)))
((>= column width))
(set (aref x i) (+ (aref x i) alpha))
(incf i stride-x)))))
“‘

Package

mgl-mat.

Source

cuda-early.lisp.

Function: choose-3d-block-and-grid (dimensions max-n-warps-per-block)

Return two values, one suitable as the :BLOCK-DIM, the other as the :GRID-DIM argument for a cuda kernel call where both are two-dimensional (only the first two elements may be different from 1).

The number of threads in a block is a multiple of *CUDA-WARP-SIZE*. The number of blocks is between 1 and and *CUDA-MAX-N-BLOCKS*. Currently - but this may change - the BLOCK-DIM-X is always *CUDA-WARP-SIZE* and GRID-DIM-X is always 1.

This means that the kernel must be able handle any number of elements in each thread. For example, a strided kernel that adds a constant to each element of a THICKNESS * HEIGHT * WIDTH 3d array looks like this:

“‘
(let ((id-x (+ (* block-dim-x block-idx-x) thread-idx-x))
(id-y (+ (* block-dim-y block-idx-y) thread-idx-y))
(id-z (+ (* block-dim-z block-idx-z) thread-idx-z)) (stride-x (* block-dim-x grid-dim-x))
(stride-y (* block-dim-y grid-dim-y))
(stride-z (* block-dim-z grid-dim-z)))
(do ((plane id-z (+ plane stride-z)))
((>= plane thickness))
(do ((row id-y (+ row stride-y)))
((>= row height))
(let ((i (* (+ (* plane height) row) width)))
(do ((column id-x (+ column stride-x)))
((>= column width))
(set (aref x i) (+ (aref x i) alpha))
(incf i stride-x))))))
“‘

Package

mgl-mat.

Source

cuda-early.lisp.

Function: coerce-to-ctype (x &key ctype)

Coerce the scalar X to the lisp type corresponding to CTYPE.

Package

mgl-mat.

Source

util.lisp.

Function: convolve! (x w y &key start stride anchor batched)

Y = Y + conv(X, W) and return Y. If BATCHED, then the first dimension of X and Y is the number of elements in the batch (B), else B is assumed to be 1. The rest of the dimensions encode the input (X) and output (Y} N dimensional feature maps. START, STRIDE and ANCHOR are lists of length N. START is the multi-dimensional index of the first element of the input feature map (for each element in the batch) for which the convolution must be computed. Then (ELT STRIDE (- N 1)) is added to the last element of START and so on until (ARRAY-DIMENSION X 1) is reached. Then the last element of START is reset, (ELT STRIDE (- N 2)) is added to the first but last element of START and we scan the last dimension again. Take a 2d example, START is (0 0), STRIDE is (1 2), and X is a B*2x7 matrix.

W is:

1 2 1
2 4 2
1 2 1

and ANCHOR is (1 1) which refers to the element of W whose value is 4. This anchor point of W is placed over elements of X whose multi dimensional index is in numbers in this figure (only one element in the batch is shown):

0,0 . 0,2 . 0,4 . 0,6
1,0 . 1,2 . 1,4 . 1,6

When applying W at position P of X, the convolution is the sum of the products of overlapping elements of X and W when W’s ANCHOR is placed at P. Elements of W over the edges of X are multiplied with 0 so are effectively ignored. The order of application of W to positions defined by START, STRIDE and ANCHOR is undefined.

Y must be a B*2x4 (or 2x4 if not BATCHED) matrix in this example, just large enough to hold the results of the convolutions.

Package

mgl-mat.

Source

convolve.lisp.

Function: copy! (x y &key n incx incy)

Copy X into Y. Return Y.

Package

mgl-mat.

Source

mat.lisp.

Function: copy-column (a column)

Return COLUMN of A as a new 1d matrix.

Package

mgl-mat.

Source

mat.lisp.

Function: copy-mat (a)

Return a copy of the active portion with regards to displacement and shape of A.

Package

mgl-mat.

Source

mat.lisp.

Function: copy-row (a row)

Return ROW of A as a new 1d matrix.

Package

mgl-mat.

Source

mat.lisp.

Function: count-barred-facets (facet-name &key type)

Count facets with FACET-NAME of cubes of TYPE which will be destroyed by a facet barrier.

Package

mgl-cube.

Source

cube.lisp.

Function: cublas-create (handle)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-destroy (&key handle)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-get-version (version &key handle)
Package

mgl-mat.

Source

cublas.lisp.

Function: cuda-available-p (&key device-id)

Check that a cuda context is already in initialized in the current thread or a device with DEVICE-ID is available.

Package

mgl-mat.

Source

cuda-late.lisp.

Function: cuda-room (&key stream verbose)

When CUDA is in use (see USE-CUDA-P), print a summary of memory
usage in the current CUDA context to STREAM. If VERBOSE, make the output human easily readable, else try to present it in a very
concise way. Sample output with VERBOSE:

“‘
CUDA memory usage:
device arrays: 450 (used bytes: 3,386,295,808, pooled bytes: 1,816,657,920) host arrays: 14640 (used bytes: 17,380,147,200)
host->device copies: 154,102,488, device->host copies: 117,136,434 “‘

The same data presented with VERBOSE false:

“‘
d: 450 (3,386,295,808 + 1,816,657,920), h: 14640 (17,380,147,200)
h->d: 154,102,488, d->h: 117,136,434
“‘

Package

mgl-mat.

Source

cuda-late.lisp.

Function: derive-convolve! (x xd w wd yd &key start stride anchor batched)

Add the dF/dX to XD and and dF/dW to WD where YD is dF/dY for some function F where Y is the result of convolution with the same arguments.

Package

mgl-mat.

Source

convolve.lisp.

Function: derive-max-pool! (x xd y yd &key start stride anchor batched pool-dimensions)

Add the dF/dX to XD and and dF/dW to WD where YD is dF/dY for some function F where Y is the result of MAX-POOL! with the same arguments.

Package

mgl-mat.

Source

max-pool.lisp.

Function: destroy-cube (cube)

Destroy all facets of CUBE with DESTROY-FACET.

Package

mgl-cube.

Source

cube.lisp.

Function: destroy-facet (cube facet-name)

Free resources associated with the facet with FACET-NAME and remove it from FACETS of CUBE.

Package

mgl-cube.

Source

cube.lisp.

Function: displace (mat displacement)

Return a new matrix that aliases MAT’s storage at offset DISPLACEMENT. DISPLACEMENT 0 is equivalent to the start of the storage of MAT regardless of MAT’s displacement. The returned matrix has the same dimensions as MAT.

Package

mgl-mat.

Source

mat.lisp.

Function: displace! (mat displacement)

Like RESHAPE-AND-DISPLACE! but only alters the displacement.

Package

mgl-mat.

Source

mat.lisp.

Reader: facet-description (instance)

Returned by MAKE-FACET* as its second value, this is an arbitrary object in which additional information can be stored.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

description.

Writer: (setf facet-description) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

description.

Reader: facet-direction (instance)

The direction of the last WITH-FACET on this facet.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

direction.

Writer: (setf facet-direction) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

direction.

Reader: facet-n-watchers (instance)

The number of active ‘WITH-FACET‘s. Updated by WATCH-FACET and UNWATCH-FACET.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

n-watchers.

Writer: (setf facet-n-watchers) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

n-watchers.

Reader: facet-name (instance)

A symbol that uniquely identifies the facet within a cube.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

name.

Writer: (setf facet-name) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

name.

Reader: facet-up-to-date-p (instance)

Whether the cube has changed since this facet has been last updated. See FACET-UP-TO-DATE-P*.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

up-to-date-p.

Writer: (setf facet-up-to-date-p) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

up-to-date-p.

Reader: facet-value (instance)

This is what’s normally exposed by WITH-FACET.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

value.

Writer: (setf facet-value) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

value.

Reader: facet-watcher-threads (instance)

The threads (one for each watcher) that have active ‘WITH-FACET‘s.

Package

mgl-cube.

Source

cube.lisp.

Target Slot

watcher-threads.

Writer: (setf facet-watcher-threads) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

watcher-threads.

Function: facets (cube)

Return the facets of CUBE.

Package

mgl-cube.

Source

cube.lisp.

Function: fill! (alpha x &key n)

Fill matrix X with ALPHA. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: find-facet (cube facet-name)

Return the facet of CUBE for the facet with FACET-NAME or NIL if no such facet exists.

Package

mgl-cube.

Source

cube.lisp.

Function: foreign-room (&key stream verbose)

Print a summary of foreign memory usage to STREAM. If VERBOSE, make the output human easily readable, else try to present it in a very concise way. Sample output with VERBOSE:

“‘
Foreign memory usage:
foreign arrays: 450 (used bytes: 3,386,295,808)
“‘

The same data presented with VERBOSE false:

“‘
f: 450 (3,386,295,808)
“‘

Package

mgl-mat.

Source

foreign.lisp.

Function: gaussian-random! (mat &key mean stddev)

Fill MAT with independent normally distributed random numbers with MEAN and STDDEV.

Package

mgl-mat.

Source

mat.lisp.

Function: geem! (alpha a b beta c)

Like GEMM!, but multiplication is elementwise. This is not a standard BLAS routine.

Package

mgl-mat.

Source

mat.lisp.

Function: geerv! (alpha a x beta b)

GEneric Elementwise Row - Vector multiplication. ‘B = beta * B + alpha a .* X*‘ where ‘X*‘ is a matrix of the same shape as A whose every row is X. Perform elementwise multiplication on each row of A with the vector X and add the scaled result to the corresponding row of B. Return B. This is not a standard BLAS routine.

Package

mgl-mat.

Source

mat.lisp.

Function: gemm! (alpha a b beta c &key transpose-a? transpose-b? m n k lda ldb ldc)

Basically C = ALPHA * A’ * B’ + BETA * C. A’ is A or its transpose depending on TRANSPOSE-A?. B’ is B or its transpose depending on TRANSPOSE-B?. Returns C.

A’ is an MxK matrix. B’ is a KxN matrix. C is an MxN matrix.

LDA is the width of the matrix A (not of A’). If A is not transposed, then K <= LDA, if it’s transposed then M <= LDA.

LDB is the width of the matrix B (not of B’). If B is not transposed, then N <= LDB, if it’s transposed then K <= LDB.

In the example below M=3, N=2, K=5, LDA=6, LDB=3, LDC=4. The cells marked with + do not feature in the calculation.

N
–+
–+
K -B+
–+
–+
+++
K
—–+ –++
M –A–+ -C++
—–+ –++
++++++ ++++

Package

mgl-mat.

Source

mat.lisp.

Function: invert (a)

Return the inverse of A.

Package

mgl-mat.

Source

mat.lisp.

Function: logdet (mat)

Logarithm of the determinant of MAT. Return -1, 1 or 0 (or equivalent) to correct for the sign, as the second value.

Package

mgl-mat.

Source

mat.lisp.

Function: m* (a b &key transpose-a? transpose-b?)

Compute op(A) * op(B). Where op is either the identity or the transpose operation depending on TRANSPOSE-A? and TRANSPOSE-B?.

Package

mgl-mat.

Source

mat.lisp.

Function: m+ (a b)

Return A + B.

Package

mgl-mat.

Source

mat.lisp.

Function: m- (a b)

Return A - B.

Package

mgl-mat.

Source

mat.lisp.

Function: m= (a b)

Check whether A and B, which must be matrices of the same size, are elementwise equal.

Package

mgl-mat.

Source

mat.lisp.

Function: make-mat (dimensions &rest args &key ctype displacement max-size initial-element initial-contents synchronization displaced-to cuda-enabled)

Return a new MAT object. If INITIAL-CONTENTS is given then the matrix contents are initialized with REPLACE!. See class MAT for the description of the rest of the parameters. This is exactly
what (MAKE-INSTANCE ’MAT ...) does except DIMENSIONS is not a keyword argument so that MAKE-MAT looks more like MAKE-ARRAY. The semantics of SYNCHRONIZATION are desribed in the @CUBE-SYNCHRONIZATION section.

If specified, DISPLACED-TO must be a MAT object large enough (in the sense of its MAT-SIZE), to hold DISPLACEMENT plus ‘(REDUCE #’* DIMENSIONS)‘ elements. Just like with MAKE-ARRAY, INITIAL-ELEMENT and INITIAL-CONTENTS must not be supplied together with DISPLACED-TO. See @MAT-SHAPING for more.

Package

mgl-mat.

Source

mat.lisp.

Function: map-concat (fn mats mat &key key pass-raw-p)

Call FN with each element of MATS and MAT temporarily reshaped to
the dimensions of the current element of MATS and return MAT. For the next element the displacement is increased so that there is no overlap.

MATS is keyed by KEY just like the CL sequence functions. Normally, FN is called with the matrix returned by KEY. However, if PASS-RAW-P, then the matrix returned by KEY is only used to calculate dimensions and the element of MATS that was passed to KEY is passed to FN, too.

“‘
(map-concat #’copy! (list (make-mat 2) (make-mat 4 :initial-element 1)) (make-mat ’(2 3)))
==> #<MAT 2x3 AB #2A((0.0d0 0.0d0 1.0d0) (1.0d0 1.0d0 1.0d0))> “‘

Package

mgl-mat.

Source

mat.lisp.

Function: map-displacements (fn mat dimensions &key displacement-start displacement-step)

Call FN with MAT reshaped to DIMENSIONS, first displaced by DISPLACEMENT-START that’s incremented by DISPLACEMENT-STEP each iteration while there are enough elements left for DIMENSIONS at the current displacement. Returns MAT.

“‘commonlisp
(let ((mat (make-mat 14 :initial-contents ’(-1 0 1 2 3
4 5 6 7
8 9 10 11 12)))) (reshape-and-displace! mat ’(4 3) 1)
(map-displacements #’print mat 4))
..
.. #<MAT 1+4+9 B #(0.0d0 1.0d0 2.0d0 3.0d0)>
.. #<MAT 5+4+5 B #(4.0d0 5.0d0 6.0d0 7.0d0)>
.. #<MAT 9+4+1 B #(8.0d0 9.0d0 10.0d0 11.0d0)>
“‘

Package

mgl-mat.

Source

mat.lisp.

Function: map-mats-into (result-mat fn &rest mats)

Like CL:MAP-INTO but for MAT objects. Destructively modifies RESULT-MAT to contain the results of applying FN to each element in the argument MATS in turn.

Package

mgl-mat.

Source

mat.lisp.

Function: mat-as-scalar (a)

Return the first element of A. A must be of size 1.

Package

mgl-mat.

Source

mat.lisp.

Function: mat-dimension (mat axis-number)

Return the dimension along AXIS-NUMBER. Similar to ARRAY-DIMENSION.

Package

mgl-mat.

Source

mat.lisp.

Function: mat-room (&key stream verbose)

Calls FOREIGN-ROOM and CUDA-ROOM.

Package

mgl-mat.

Source

mat.lisp.

Function: mat-row-major-index (mat &rest subscripts)

Like ARRAY-ROW-MAJOR-INDEX for arrays.

Package

mgl-mat.

Source

mat.lisp.

Function: mat-to-array (mat)
Package

mgl-mat.

Source

mat.lisp.

Function: max-pool! (x y &key start stride anchor batched pool-dimensions)
Package

mgl-mat.

Source

max-pool.lisp.

Function: mm* (m &rest args)

Convenience function to multiply several matrices.

(mm* a b c) => a * b * c

Package

mgl-mat.

Source

mat.lisp.

Function: mref (mat &rest indices)

Like AREF for arrays. Don’t use this if you care about performance at all. SETFable. When set, the value is coerced to the ctype of MAT with COERCE-TO-CTYPE. Note that currently MREF always operates on the BACKING-ARRAY facet so it can trigger copying of facets. When it’s SETF’ed, however, it will update the CUDA-ARRAY if cuda is enabled and it is up-to-date or there are no facets at all.

Package

mgl-mat.

Source

mat.lisp.

Setf expander for this function

(setf mref).

Function: mv-gaussian-random (&key means covariances)

Return a column vector of samples from the multivariate normal distribution defined by MEANS (Nx1) and COVARIANCES (NxN). No CUDA implementation.

Package

mgl-mat.

Source

mat.lisp.

Function: nrm2 (x &key n incx)

Return the l2 norm of X, which is the square root of the sum of the squares of its elements.

Package

mgl-mat.

Source

mat.lisp.

Function: orthogonal-random! (m &key scale)

Fill the matrix M with random values in such a way that ‘M^T * M‘ is the identity matrix (or something close if M is wide). Return M.

Package

mgl-mat.

Source

mat.lisp.

Function: pinning-supported-p ()

Return true iff the lisp implementation efficiently supports pinning lisp arrays. Pinning ensures that the garbage collector doesn’t move the array in memory. Currently this is only supported on SBCL gencgc platforms.

Package

mgl-mat.

Source

foreign.lisp.

Function: remove-facet-reference (facet)

Decrement the reference count of FACET. It is an error if the facet is already destroyed or if the reference count becomes negative. This function has the same purpose as REMOVE-FACET-REFERENCE-BY-NAME, but by having a single FACET argument, it’s more suited for use in finalizers because it does not keep the whole CUBE alive.

Package

mgl-cube.

Source

cube.lisp.

Function: remove-facet-reference-by-name (cube facet-name)

Decrement the reference count of the facet with FACET-NAME of CUBE. It is an error if the facet does not exists or if the reference count becomes negative.

Package

mgl-cube.

Source

cube.lisp.

Function: replace! (mat seq-of-seqs)

Replace the contents of MAT with the elements of SEQ-OF-SEQS. SEQ-OF-SEQS is a nested sequence of sequences similar to the INITIAL-CONTENTS argument of MAKE-ARRAY. The total number of elements must match the size of MAT. Returns MAT.

SEQ-OF-SEQS may contain multi-dimensional arrays as _leafs_, so the following is legal:

“‘common-lisp
(replace! (make-mat ’(1 2 3)) ’(#2A((1 2 3) (4 5 6))))
==> #<MAT 1x2x3 AB #3A(((1.0d0 2.0d0 3.0d0) (4.0d0 5.0d0 6.0d0)))> “‘

Package

mgl-mat.

Source

mat.lisp.

Function: reshape (mat dimensions)

Return a new matrix of DIMENSIONS whose displacement is the same as the displacement of MAT.

Package

mgl-mat.

Source

mat.lisp.

Function: reshape! (mat dimensions)

Like RESHAPE-AND-DISPLACE! but only alters the dimensions.

Package

mgl-mat.

Source

mat.lisp.

Function: reshape-and-displace (mat dimensions displacement)

Return a new matrix of DIMENSIONS that aliases MAT’s storage at offset DISPLACEMENT. DISPLACEMENT 0 is equivalent to the start of the storage of MAT regardless of MAT’s displacement.

Package

mgl-mat.

Source

mat.lisp.

Function: reshape-and-displace! (mat dimensions displacement)

Change the visible (or active) portion of MAT by altering its displacement offset and dimensions. Future operations will only affect this visible portion as if the rest of the elements were not there. Return MAT.

DISPLACEMENT + the new size must not exceed MAT-MAX-SIZE. Furthermore, there must be no facets being viewed (with WITH-FACETS) when calling this function as the identity of the facets is not stable.

Package

mgl-mat.

Source

mat.lisp.

Function: reshape-to-row-matrix! (mat row)

Reshape the 2d MAT to make only a single ROW visible. This is made possible by the row-major layout, hence no column counterpart. Return MAT.

Package

mgl-mat.

Source

mat.lisp.

Function: row-major-mref (mat index)

Like ROW-MAJOR-AREF for arrays. Don’t use this if you care about performance at all. SETFable. When set, the value is coerced to the ctype of MAT with COERCE-TO-CTYPE. Note that currently ROW-MAJOR-MREF always operates on the BACKING-ARRAY facet so it can trigger copying of facets. When it’s SETF’ed, however, it will update the CUDA-ARRAY if cuda is enabled and it is up-to-date or there are no facets at all.

Package

mgl-mat.

Source

mat.lisp.

Setf expander for this function

(setf row-major-mref).

Function: scal! (alpha x &key n incx)

Set X to ALPHA * X. Return X.

Package

mgl-mat.

Source

mat.lisp.

Function: scalar-as-mat (x &key ctype)

Return a matrix of one dimension and one element: X. CTYPE, the type of the matrix, defaults to the ctype corresponding to the type of X.

Package

mgl-mat.

Source

mat.lisp.

Function: scale-columns! (scales a &key result)

Set RESULT to ‘A*DIAG(SCALES)‘ and return it. ‘A‘ is an ‘MxN‘ matrix, SCALES is treated as a length ‘N‘ vector.

Package

mgl-mat.

Source

mat.lisp.

Function: scale-rows! (scales a &key result)

Set RESULT to ‘DIAG(SCALES)*A‘ and return it. ‘A‘ is an ‘MxN‘ matrix, SCALES is treated as a length ‘M‘ vector.

Package

mgl-mat.

Source

mat.lisp.

Function: stack (axis mats &key ctype)

Like STACK! but return a new MAT of CTYPE.

“‘commonlisp
(stack 1 (list (make-mat ’(3 2) :initial-element 0) (make-mat ’(3 1) :initial-element 1))) ==> #<MAT 3x3 B #2A((0.0d0 0.0d0 1.0d0)
–> (0.0d0 0.0d0 1.0d0)
–> (0.0d0 0.0d0 1.0d0))>
“‘

Package

mgl-mat.

Source

mat.lisp.

Function: stack! (axis mats mat)

Stack MATS along AXIS into MAT and return MAT. If AXIS is 0, place MATS into MAT below each other starting from the top. If AXIS is 1, place MATS side by side starting from the left. Higher AXIS are also supported. All dimensions except for AXIS must be the same for all MATS.

Package

mgl-mat.

Source

mat.lisp.

Function: sum! (x y &key axis alpha beta)

Sum matrix X along AXIS and add ALPHA * SUMS to BETA * Y destructively modifying Y. Return Y. On a 2d matrix (nothing else is supported currently), if AXIS is 0, then columns are summed, if AXIS is 1 then rows are summed.

Package

mgl-mat.

Source

mat.lisp.

Function: transpose (a)

Return the transpose of A.

Package

mgl-mat.

Source

mat.lisp.

Function: uniform-random! (mat &key limit)

Fill MAT with random numbers sampled uniformly from the [0,LIMIT) interval of MAT’s type.

Package

mgl-mat.

Source

mat.lisp.

Function: use-cuda-p (&rest mats)

Return true if cuda is enabled (*CUDA-ENABLED*), it’s initialized and all MATS have [CUDA-ENABLED][(accessor mat)]. Operations of matrices use this to decide whether to go for the CUDA implementation or BLAS/Lisp. It’s provided for implementing new operations.

Package

mgl-mat.

Source

cuda-early.lisp.


6.1.5 Generic functions

Generic Function: call-with-facet* (cube facet-name direction fn)

Call FN with an up-to-date FACET-VALUE that belongs
to FACET-NAME of CUBE. WITH-FACET is directly implemented in terms of this function. See @CUBE-DEFAULT-CALL-WITH-FACET* for the gory details.

Specializations will most likely want to call the default implementation (with CALL-NEXT-METHOD) but with a lambda that transforms FACET-VALUE before passing it on to FN.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: call-with-facet* ((mat mat) (facet-name (eql mgl-mat:cuda-host-array)) direction fn)
Source

mat.lisp.

Method: call-with-facet* ((mat mat) (facet-name (eql mgl-mat:cuda-array)) direction fn)
Source

mat.lisp.

Method: call-with-facet* ((mat mat) (facet-name (eql mgl-mat:foreign-array)) direction fn)
Source

mat.lisp.

Method: call-with-facet* ((mat mat) (facet-name (eql mgl-mat:backing-array)) direction fn)
Source

mat.lisp.

Method: call-with-facet* ((mat mat) (facet-name (eql array)) direction fn)
Source

mat.lisp.

Method: call-with-facet* ((cube cube) facet-name direction fn)

The default implementation of CALL-WITH-FACET* is defined in terms of the WATCH-FACET and the UNWATCH-FACET generic functions. These can be considered part of the @CUBE-FACET-EXTENSION-API.

Generic Function: copy-facet* (cube from-facet-name from-facet to-facet-name to-facet)

Copy the CUBE’s data from FROM-FACET with
FROM-FACET-NAME to TO-FACET with TO-FACET-NAME. Called by WITH-FACET (or more directly WATCH-FACET) when necessary. FROM-FACET is what SELECT-COPY-SOURCE-FOR-FACET* returned.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: copy-facet* ((mat mat) from-facet-name from-facet to-facet-name to-facet)
Source

mat.lisp.

Method: copy-facet* ((vec vec) (from-name (eql mgl-mat::cuda-vector)) cuda-vector-facet (to-name (eql mgl-mat::lisp-vector)) lisp-vector-facet)
Source

vec.lisp.

Method: copy-facet* ((vec vec) (from-name (eql mgl-mat::lisp-vector)) lisp-vector-facet (to-name (eql mgl-mat::cuda-vector)) cuda-vector-facet)
Source

vec.lisp.

Method: copy-facet* ((vec vec) (from-name (eql mgl-mat::cuda-vector)) cuda-vector-facet (to-name (eql static-vectors:static-vector)) static-vector-facet)
Source

vec.lisp.

Method: copy-facet* ((vec vec) (from-name (eql static-vectors:static-vector)) static-vector-facet (to-name (eql mgl-mat::cuda-vector)) cuda-vector-facet)
Source

vec.lisp.

Method: copy-facet* ((vec vec) (from-name (eql static-vectors:static-vector)) static-vector-facet (to-name (eql mgl-mat::lisp-vector)) lisp-vector-facet)
Source

vec.lisp.

Method: copy-facet* ((vec vec) (from-name (eql mgl-mat::lisp-vector)) lisp-vector-facet (to-name (eql static-vectors:static-vector)) static-vector-facet)
Source

vec.lisp.

Generic Function: copy-random-state (state)

Return a copy of STATE be it a lisp or cuda random state.

Package

mgl-mat.

Source

mat.lisp.

Methods
Method: copy-random-state ((state curand-state))
Method: copy-random-state ((state random-state))
Generic Reader: cublas-error-function-name (condition)
Package

mgl-mat.

Methods
Reader Method: cublas-error-function-name ((condition cublas-error))
Source

cublas.lisp.

Target Slot

function-name.

Generic Reader: cublas-error-status (condition)
Package

mgl-mat.

Methods
Reader Method: cublas-error-status ((condition cublas-error))
Source

cublas.lisp.

Target Slot

status.

Generic Reader: cuda-enabled (object)
Generic Writer: (setf cuda-enabled) (object)
Package

mgl-mat.

Methods
Reader Method: cuda-enabled ((mat mat))
Writer Method: (setf cuda-enabled) ((mat mat))

The control provided by *CUDA-ENABLED* can be too
coarse. This flag provides a per-object mechanism to turn cuda off. If it is set to NIL, then any operation that pays attention to this flag will not create or access the CUDA-ARRAY facet. Implementationally speaking, this is easily accomplished by using USE-CUDA-P.

Source

mat.lisp.

Target Slot

cuda-enabled.

Generic Function: destroy-facet* (facet-name facet)

Free the resources associated with FACET with
FACET-NAME. The cube this facet belongs to is not among the parameters because this method can be called from a finalizer on the cube (so we can’t have a reference to the cube portably) which also means that it may run in an unpredictable thread.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: destroy-facet* ((facet-name (eql mgl-mat:cuda-host-array)) facet)
Source

mat.lisp.

Method: destroy-facet* ((facet-name (eql mgl-mat:cuda-array)) facet)
Source

mat.lisp.

Method: destroy-facet* ((facet-name (eql mgl-mat:foreign-array)) facet)
Source

mat.lisp.

Method: destroy-facet* ((facet-name (eql mgl-mat:backing-array)) facet)
Source

mat.lisp.

Method: destroy-facet* ((facet-name (eql array)) facet)
Source

mat.lisp.

Method: destroy-facet* ((facet-name (eql mgl-mat::cuda-vector)) facet)
Source

vec.lisp.

Method: destroy-facet* ((facet-name (eql static-vectors:static-vector)) facet)
Source

vec.lisp.

Method: destroy-facet* ((facet-name (eql mgl-mat::lisp-vector)) facet)
Source

vec.lisp.

Generic Function: facet-up-to-date-p* (cube facet-name facet)

Check if FACET with FACET-NAME has been updated
since the latest change to CUBE (that is, since the access to other facets with DIRECTION of :IO or :OUTPUT). The default method simply calls FACET-UP-TO-DATE-P on FACET.

One reason to specialize this is when some facets actually share common storage, so updating one make the other up-to-date as well.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: facet-up-to-date-p* ((mat mat) facet-name facet)
Source

mat.lisp.

Method: facet-up-to-date-p* (cube facet-name facet)
Generic Function: make-facet* (cube facet-name)

Called by WITH-FACET (or more directly WATCH-FACET)
when there is no facet with FACET-NAME. As the first value, return a new object capable of storing CUBE’s data in the facet with FACET-NAME. As the second value, return a facet description which will be available as FACET-DESCRIPTION. As the third value, return a generalized boolean indicating whether this facet must be explicitly destroyed (in which case a finalizer will be added to CUBE).

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: make-facet* ((mat mat) (facet-name (eql mgl-mat:cuda-host-array)))
Source

mat.lisp.

Method: make-facet* ((mat mat) (facet-name (eql mgl-mat:cuda-array)))
Source

mat.lisp.

Method: make-facet* ((mat mat) (facet-name (eql mgl-mat:foreign-array)))
Source

mat.lisp.

Method: make-facet* ((mat mat) (facet-name (eql mgl-mat:backing-array)))
Source

mat.lisp.

Method: make-facet* ((mat mat) (facet-name (eql array)))
Source

mat.lisp.

Method: make-facet* ((vec vec) (facet-name (eql mgl-mat::cuda-vector)))
Source

vec.lisp.

Method: make-facet* ((vec vec) (facet-name (eql static-vectors:static-vector)))
Source

vec.lisp.

Method: make-facet* ((vec vec) (facet-name (eql mgl-mat::lisp-vector)))
Source

vec.lisp.

Generic Reader: mat-ctype (object)
Package

mgl-mat.

Methods
Reader Method: mat-ctype ((mat mat))
Source

mat.lisp.

Target Slot

ctype.

Generic Reader: mat-dimensions (object)
Package

mgl-mat.

Methods
Reader Method: mat-dimensions ((mat mat))

Like ARRAY-DIMENSIONS. It holds a list of
dimensions, but it is allowed to pass in scalars too.

Source

mat.lisp.

Target Slot

dimensions.

Generic Reader: mat-displacement (object)
Package

mgl-mat.

Methods
Reader Method: mat-displacement ((mat mat))

A value in the ‘[0,MAX-SIZE]‘ interval. This is
like the DISPLACED-INDEX-OFFSET of a lisp array, but displacement is relative to the start of the underlying storage vector.

Source

mat.lisp.

Target Slot

displacement.

Generic Reader: mat-initial-element (object)
Package

mgl-mat.

Methods
Reader Method: mat-initial-element ((mat mat))
Source

mat.lisp.

Target Slot

initial-element.

Generic Reader: mat-max-size (object)
Package

mgl-mat.

Methods
Reader Method: mat-max-size ((mat mat))
Source

mat.lisp.

Target Slot

max-size.

Generic Reader: mat-size (object)
Package

mgl-mat.

Methods
Reader Method: mat-size ((mat mat))

The number of elements in the visible portion of
the array. This is always the product of the elements MAT-DIMENSIONS and is similar to ARRAY-TOTAL-SIZE.

Source

mat.lisp.

Target Slot

size.

Generic Reader: n-states (object)
Package

mgl-mat.

Methods
Reader Method: n-states ((curand-xorwow-state curand-xorwow-state))

automatically generated reader method

Source

curand.lisp.

Target Slot

n-states.

Generic Function: read-mat (mat stream)

Destructively modify the visible portion (with
regards to displacement and shape) of MAT by reading MAT-SIZE number of elements from binary STREAM. Return MAT. Also see *MAT-HEADERS*.

Package

mgl-mat.

Source

mat.lisp.

Methods
Method: read-mat ((mat mat) stream)
Generic Function: select-copy-source-for-facet* (cube to-name to-facet)

Called when TO-FACET with TO-NAME is about to be
updated by copying data from an up-to-date facet. Return the facet (or its name) from which data shall be copied. Note that if the returned facet is not FACET-UP-TO-DATE-P*, then it will be updated first and another SELECT-COPY-SOURCE-FOR-FACET* will take place, so be careful not to get into endless recursion. The default method simply returns the first up-to-date facet.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: select-copy-source-for-facet* ((mat mat) (to-name (eql mgl-mat:cuda-array)) facet)
Source

mat.lisp.

Method: select-copy-source-for-facet* (cube to-name to-facet)
Generic Reader: states (object)
Package

mgl-mat.

Methods
Reader Method: states ((curand-xorwow-state curand-xorwow-state))

automatically generated reader method

Source

curand.lisp.

Target Slot

states.

Generic Reader: synchronization (object)
Generic Writer: (setf synchronization) (object)
Package

mgl-cube.

Methods
Reader Method: synchronization ((cube cube))
Writer Method: (setf synchronization) ((cube cube))

By default, setup and teardown of facets by
WITH-FACET is performed in a thread safe way. Corrupting internal data structures of cubes is not fun, but in the name of performance, synchronization can be turned off either dynamically or on a per instance basis.

If T, then access to cube metadata is always synchronized. If NIL, then never. If :MAYBE, then whether access is synchronized is determined by *MAYBE-SYNCHRONIZE-CUBE* that’s true by default.

The default is the value of *DEFAULT-SYNCHRONIZATION*
that’s :MAYBE by default.

Note that the body of a WITH-FACET is never synchronized with anyone, apart from the implicit reader/writer conflict (see DIRECTION).

Source

cube.lisp.

Target Slot

synchronization.

Generic Function: unwatch-facet (cube facet-name)

This is what the default CALL-WITH-FACET* method,
in terms of which WITH-FACET is implemented, calls last. The default method takes care of taking down facets. External resource managers may want to hook into this to handle unused facets.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: unwatch-facet ((cube cube) facet-name)
Generic Function: watch-facet (cube facet-name direction)

This is what the default CALL-WITH-FACET* method,
in terms of which WITH-FACET is implemented, calls first. The default method takes care of creating facets, copying and tracking up-to-dateness.

Calls CHECK-NO-WRITERS (unless *LET-INPUT-THROUGH-P*) and CHECK-NO-WATCHERS (unless *LET-OUTPUT-THROUGH-P*) depending on DIRECTION to detect situations with a writer being concurrent to readers/writers because that would screw up the tracking of up-to-dateness.

The default implementation should suffice most of the time. \MGL-MAT specializes it to override the DIRECTION arg, if
it’s :OUTPUT but not all elements are visible due to reshaping, so that invisible elements are still copied over.

Package

mgl-cube.

Source

cube.lisp.

Methods
Method: watch-facet ((mat mat) facet-name direction)
Source

mat.lisp.

Method: watch-facet ((cube cube) facet-name direction)
Generic Function: write-mat (mat stream)

Write MAT to binary STREAM in portable binary
format. Return MAT. Displacement and size are taken into account, only visible elements are written. Also see *MAT-HEADERS*.

Package

mgl-mat.

Source

mat.lisp.

Methods
Method: write-mat ((mat mat) stream)

6.1.6 Standalone methods

Method: initialize-instance :after ((mat mat) &key ctype initial-element initial-contents displaced-to max-size &allow-other-keys)
Source

mat.lisp.

Method: initialize-instance :after ((vec vec) &key &allow-other-keys)
Source

vec.lisp.

Method: print-object ((mat mat) stream)
Source

mat.lisp.

Method: print-object ((vec vec) stream)
Source

vec.lisp.


6.1.7 Conditions

Condition: cublas-error
Package

mgl-mat.

Source

cublas.lisp.

Direct superclasses

error.

Direct methods
Direct slots
Slot: function-name
Initargs

:function-name

Readers

cublas-error-function-name.

Writers

This slot is read-only.

Slot: status
Initargs

:status

Readers

cublas-error-status.

Writers

This slot is read-only.

Condition: cuda-out-of-memory

If an allocation request cannot be
satisfied (either because of N-POOL-BYTES or physical device memory limits being reached), then CUDA-OUT-OF-MEMORY is signalled.

Package

mgl-mat.

Source

cuda-early.lisp.

Direct superclasses

storage-condition.

Direct methods

n-bytes.

Direct slots
Slot: n-bytes
Initargs

:n-bytes

Readers

n-bytes.

Writers

This slot is read-only.


Next: , Previous: , Up: Public Interface   [Contents][Index]

6.1.8 Structures

Structure: facet

A cube has facets, as we discussed in @CUBE-BASICS. Facets holds the data in a particular representation, this is called the _value_ of the facet. A facet holds one such value and some metadata pertaining to it: its FACET-NAME, whether it’s
up-to-date (FACET-UP-TO-DATE-P), etc. FACET objects are never seen when simply using a cube, they are for implementing the @CUBE-FACET-EXTENSION-API.

Package

mgl-cube.

Source

cube.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: name
Type

symbol

Readers

facet-name.

Writers

(setf facet-name).

Slot: value
Readers

facet-value.

Writers

(setf facet-value).

Slot: description
Readers

facet-description.

Writers

(setf facet-description).

Slot: up-to-date-p
Readers

facet-up-to-date-p.

Writers

(setf facet-up-to-date-p).

Slot: n-watchers
Initform

0

Readers

facet-n-watchers.

Writers

(setf facet-n-watchers).

Slot: watcher-threads
Readers

facet-watcher-threads.

Writers

(setf facet-watcher-threads).

Slot: direction
Type

mgl-cube:direction

Readers

facet-direction.

Writers

(setf facet-direction).

Slot: references
Initform

(mgl-cube::make-references)

Readers

facet-references.

Writers

(setf facet-references).


Next: , Previous: , Up: Public Interface   [Contents][Index]

6.1.9 Classes

Class: cube

A datacube that has various representations of the
same stuff. These representations go by the name ‘facet’. Clients must use WITH-FACET to acquire a dynamic extent reference to a facet. With the information provided in the DIRECTION argument of WITH-FACET, the cube keeps track of which facets are up-to-date and copies data between them as necessary.

The cube is an abstract class, it does not provide useful behavior in itself. One must subclass it and implement the @CUBE-FACET-EXTENSION-API.

Also see @CUBE-LIFETIME and @CUBE-FACET-BARRIER.

Package

mgl-cube.

Source

cube.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: synchronization

By default, setup and teardown of facets by
WITH-FACET is performed in a thread safe way. Corrupting internal data structures of cubes is not fun, but in the name of performance, synchronization can be turned off either dynamically or on a per instance basis.

If T, then access to cube metadata is always synchronized. If NIL, then never. If :MAYBE, then whether access is synchronized is determined by *MAYBE-SYNCHRONIZE-CUBE* that’s true by default.

The default is the value of *DEFAULT-SYNCHRONIZATION*
that’s :MAYBE by default.

Note that the body of a WITH-FACET is never synchronized with anyone, apart from the implicit reader/writer conflict (see DIRECTION).

Type

(member nil :maybe t)

Initform

mgl-cube:*default-synchronization*

Initargs

:synchronization

Readers

synchronization.

Writers

(setf synchronization).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).

Slot: facets
Initform

(cons nil nil)

Readers

%facets.

Writers

This slot is read-only.

Slot: has-finalizer-p
Readers

has-finalizer-p.

Writers

(setf has-finalizer-p).

Class: cuda-array
Package

mgl-mat.

Source

cuda-early.lisp.

Direct superclasses

offset-pointer.

Class: cuda-host-array
Package

mgl-mat.

Source

cuda-early.lisp.

Direct superclasses

offset-pointer.

Direct methods
Direct slots
Slot: cuda-pool
Initform

mgl-mat::*cuda-pool*

Readers

cuda-pool.

Writers

(setf cuda-pool).

Class: curand-xorwow-state
Package

mgl-mat.

Source

curand.lisp.

Direct superclasses

curand-state.

Direct methods
Direct slots
Slot: n-states
Initargs

:n-states

Readers

n-states.

Writers

This slot is read-only.

Slot: states
Initargs

:states

Readers

states.

Writers

This slot is read-only.

Class: foreign-array

[FOREIGN-ARRAY][class] wraps a foreign pointer (in
the sense of CFFI:POINTERP). That is, both OFFSET-POINTER and BASE-POINTER return a foreign pointer. There are no other public operations that work with [FOREIGN-ARRAY][class] objects, their sole purpose is represent facets of MAT objects.

Package

mgl-mat.

Source

foreign.lisp.

Direct superclasses

offset-pointer.

Direct methods
Direct slots
Slot: n-references
Initform

1

Initargs

:n-references

Readers

n-references.

Writers

(setf n-references).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).

Slot: cuda-pool
Readers

cuda-pool.

Writers

(setf cuda-pool).

Class: mat

A MAT is a data CUBE that is much like a lisp
array, it supports DISPLACEMENT, arbitrary DIMENSIONS and INITIAL-ELEMENT with the usual semantics. However, a MAT supports different representations of the same data. See @MAT-TUTORIAL for an introduction.

Package

mgl-mat.

Source

mat.lisp.

Direct superclasses

cube.

Direct methods
Direct slots
Slot: displacement

A value in the ‘[0,MAX-SIZE]‘ interval. This is
like the DISPLACED-INDEX-OFFSET of a lisp array, but displacement is relative to the start of the underlying storage vector.

Initform

0

Initargs

:displacement

Readers

mat-displacement.

Writers

This slot is read-only.

Slot: dimensions

Like ARRAY-DIMENSIONS. It holds a list of
dimensions, but it is allowed to pass in scalars too.

Initargs

:dimensions

Readers

mat-dimensions.

Writers

This slot is read-only.

Slot: size

The number of elements in the visible portion of
the array. This is always the product of the elements MAT-DIMENSIONS and is similar to ARRAY-TOTAL-SIZE.

Readers

mat-size.

Writers

This slot is read-only.

Slot: cuda-enabled

The control provided by *CUDA-ENABLED* can be too
coarse. This flag provides a per-object mechanism to turn cuda off. If it is set to NIL, then any operation that pays attention to this flag will not create or access the CUDA-ARRAY facet. Implementationally speaking, this is easily accomplished by using USE-CUDA-P.

Initform

mgl-mat:*default-mat-cuda-enabled*

Initargs

:cuda-enabled

Readers

cuda-enabled.

Writers

(setf cuda-enabled).

Slot: vec
Initargs

:vec

Readers

vec.

Writers

This slot is read-only.

Slot: ctype

One of *SUPPORTED-CTYPES*. The matrix can hold only values of this type.

Type

mgl-mat:ctype

Initform

mgl-mat:*default-mat-ctype*

Initargs

:ctype

Readers

mat-ctype.

Writers

This slot is read-only.

Slot: initial-element

If non-nil, then when a facet is created, it is
filled with INITIAL-ELEMENT coerced to the appropriate numeric type. If NIL, then no initialization is performed.

Initform

0

Initargs

:initial-element

Readers

mat-initial-element.

Writers

This slot is read-only.

Slot: max-size

The number of elements for which storage may be
allocated. This is DISPLACEMENT + MAT-SIZE + ‘SLACK‘ where ‘SLACK‘ is the number of trailing invisible elements.

Initargs

:max-size

Readers

mat-max-size.

Writers

This slot is read-only.


Previous: , Up: Public Interface   [Contents][Index]

6.1.10 Types

Type: ctype ()

This is basically ‘(MEMBER :FLOAT :DOUBLE)‘.

Package

mgl-mat.

Source

util.lisp.

Type: direction ()

Used by WITH-FACET, DIRECTION can be :INPUT, :OUTPUT or :IO.

- :INPUT promises that the facet will only be read and never written. Other up-to-date facets of the same cube remain up-to-date. If the facet in question is not up-to-date then data is copied to it from one of the up-to-date facets (see SELECT-COPY-SOURCE-FOR-FACET*).

- :OUTPUT promises that _all_ data will be overwritten without reading any data. All up-to-date facets become non-up-to-date, while this facet is marked as up-to-date. No copying of data takes place.

- :IO promises nothing about the type of access. All up-to-date facets become non-up-to-date, while this facet is marked as up-to-date. If the facet in question is not up-to-date then data is copied to it from one of the up-to-date facets (see SELECT-COPY-SOURCE-FOR-FACET*).

Any number of ‘WITH-FACET‘s with direction :INPUT may be active at the same time, but :IO and :OUTPUT cannot coexists with another WITH-FACET regardless of the direction. The exception for this rule is that an inner WITH-FACET does not conflict with an enclosing WITH-FACET if they are for the same facet (but inner ‘WITH-FACET‘s for another facet or for the same facet from another thread do).

See CHECK-NO-WRITERS and CHECK-NO-WATCHERS called by @CUBE-DEFAULT-CALL-WITH-FACET*.

Package

mgl-cube.

Source

cube.lisp.

Type: foreign-array-strategy ()

One of :PINNED, :STATIC and :CUDA-HOST. See *FOREIGN-ARRAY-STRATEGY* for their semantics.

Package

mgl-mat.

Source

foreign.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Special variables

Special Variable: *counters*
Package

mgl-mat.

Source

mat.lisp.

Special Variable: *cuda-copy-stream*
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *cuda-max-n-blocks*
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *cuda-n-streaming-multiprocessors*
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *cuda-pool*
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *cuda-warp-size*
Package

mgl-mat.

Source

cuda-early.lisp.

Special Variable: *facet-barriers*
Package

mgl-cube.

Source

cube.lisp.

Special Variable: *foreign-pool*
Package

mgl-mat.

Source

foreign.lisp.

Special Variable: *lisp-foreign-cuda-lla-types*
Package

mgl-mat.

Source

util.lisp.

Special Variable: *mat-param-type*
Package

mgl-mat.

Source

util.lisp.

Special Variable: *no-array-bounds-check*
Package

mgl-mat.

Source

util.lisp.

Special Variable: *print-vec*
Package

mgl-mat.

Source

vec.lisp.

Special Variable: *print-vec-facets*
Package

mgl-mat.

Source

vec.lisp.

Special Variable: *thread-cache-lock*
Package

mgl-mat.

Source

util.lisp.

Special Variable: *thread-caches*
Package

mgl-mat.

Source

util.lisp.

Special Variable: end-of-logdet-example
Package

mgl-mat.

Source

mat.lisp.


6.2.2 Macros

Macro: blas-function-name* (name ctype)
Package

mgl-mat.

Source

blas.lisp.

Macro: call-blas-function (name (&rest params))
Package

mgl-mat.

Source

blas.lisp.

Macro: call-cublas-function (name (&rest params) handle)
Package

mgl-mat.

Source

cublas.lisp.

Macro: call-cuda-kernel (name (&rest params) ctypes &key grid-dim block-dim)
Package

mgl-mat.

Source

cuda-kernel.lisp.

Macro: call-lisp-kernel (name (&rest params) ctypes)
Package

mgl-mat.

Source

lisp-kernel.lisp.

Macro: compare-and-swap (place old-value new-value)
Package

mgl-cube.

Source

cube.lisp.

Macro: cublas-function-name* (name ctype)
Package

mgl-mat.

Source

cublas.lisp.

Macro: define-auxiliary-cublas-function ((cname name) &body args)
Package

mgl-mat.

Source

cublas.lisp.

Macro: define-blas-function ((name &key ctypes) (return-type (&rest params)))
Package

mgl-mat.

Source

blas.lisp.

Macro: define-cublas-function ((name &key ctypes) (&rest params))
Package

mgl-mat.

Source

cublas.lisp.

Macro: define-elementwise-cuda-kernel (name (e) &body body)
Package

mgl-mat.

Source

mat.lisp.

Macro: define-elementwise-dispatcher (name cuda-name lisp-name &optional docstring)
Package

mgl-mat.

Source

mat.lisp.

Macro: define-elementwise-lisp-kernel (name (e) &body body)
Package

mgl-mat.

Source

mat.lisp.

Macro: the! (&rest args)
Package

mgl-mat.

Source

util.lisp.

Macro: with-character-stream ((var stream) &body body)
Package

mgl-mat.

Source

mat.lisp.

Macro: with-cube-locked ((cube) &body body)
Package

mgl-cube.

Source

cube.lisp.

Macro: with-cuda-pool ((&key n-bytes) &body body)
Package

mgl-mat.

Source

cuda-early.lisp.

Macro: with-cuda-pool-locked ((pool) &body body)
Package

mgl-mat.

Source

cuda-early.lisp.

Macro: with-cuda-stream ((stream) &body body)
Package

mgl-mat.

Source

cuda-late.lisp.

Macro: with-foreign-array-locked ((foreign-array) &body body)
Package

mgl-mat.

Source

foreign.lisp.

Macro: with-foreign-pool-locked ((pool) &body body)
Package

mgl-mat.

Source

foreign.lisp.

Macro: with-shape-and-displacement-restored ((mat) &body body)
Package

mgl-mat.

Source

mat.lisp.

Macro: with-thread-cached-object ((var key initform &key place) &body body)
Package

mgl-mat.

Source

util.lisp.

Macro: with-zero-on-underflow ((prototype) &body body)
Package

mgl-mat.

Source

util.lisp.

Macro: without-interrupts (&body body)
Package

mgl-cube.

Source

cube.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.3 Ordinary functions

Function: %cublas-destroy (handle)
Package

mgl-mat.

Source

cublas.lisp.

Function: %cublas-get-version (handle version)
Package

mgl-mat.

Source

cublas.lisp.

Function: add-facet (cube name value description direction)
Package

mgl-cube.

Source

cube.lisp.

Function: add-host-array-to-be-unregistered (cuda-pool cuda-host-array callback)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: alloc-cuda-vector (n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: alloc-cuda-vector-with-recovery (pool n-bytes recovery-fns)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: alloc-static-vector (ctype length initial-element)
Package

mgl-mat.

Source

foreign.lisp.

Function: allocate-to-pool (pool n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: append-to-symbol (symbol suffix)
Package

mgl-mat.

Source

util.lisp.

Function: blas-asum (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-axpy (n alpha x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-call-form (blas-name ctype params return-type)
Package

mgl-mat.

Source

blas.lisp.

Function: blas-call-form* (params args fn)
Package

mgl-mat.

Source

blas.lisp.

Function: blas-copy (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dasum (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-daxpy (n alpha x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dcopy (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-ddot (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dgemm (transpose-a transpose-b n m k alpha a lda b ldb beta c ldc)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dnrm2 (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dot (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-dscal (n alpha x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-foreign-function-name (name ctype)
Package

mgl-mat.

Source

blas.lisp.

Function: blas-funcall-form (name ctype params return-type args)
Package

mgl-mat.

Source

blas.lisp.

Function: blas-function-name (name ctype)
Package

mgl-mat.

Source

blas.lisp.

Function: blas-gemm (transpose-a transpose-b n m k alpha a lda b ldb beta c ldc)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-nrm2 (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-sasum (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-saxpy (n alpha x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-scal (n alpha x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-scopy (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-sdot (n x incx y incy)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-sgemm (transpose-a transpose-b n m k alpha a lda b ldb beta c ldc)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-snrm2 (n x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: blas-sscal (n alpha x incx)
Package

mgl-mat.

Source

blas-functions.lisp.

Function: borrow-thread-cached-object (place-key key)
Package

mgl-mat.

Source

util.lisp.

Function: check-cuda-sdk ()
Package

mgl-mat.

Source

cublas.lisp.

Function: check-dimensions (x-dimensions w-dimensions y-dimensions start stride anchor)
Package

mgl-mat.

Source

convolve.lisp.

Function: cleanup-cube (cube ensures destroys)
Package

mgl-cube.

Source

cube.lisp.

Function: cleanup-facets (barrier)
Package

mgl-cube.

Source

cube.lisp.

Function: clip (x &key min max)
Package

mgl-mat.

Source

util.lisp.

Function: common-mat-ctype (&rest mats)
Package

mgl-mat.

Source

mat.lisp.

Function: convert-param-type (object)
Package

mgl-mat.

Source

util.lisp.

Function: convert-param-types (params type)
Package

mgl-mat.

Source

util.lisp.

Function: convert-to-cuda-code (object ctype)
Package

mgl-mat.

Source

cuda-kernel.lisp.

Function: convert-to-lisp-code (object ctype)
Package

mgl-mat.

Source

lisp-kernel.lisp.

Function: copy-facet (instance)
Package

mgl-cube.

Source

cube.lisp.

Function: copy-facet-barrier (instance)
Package

mgl-cube.

Source

cube.lisp.

Function: copy-list-holder (instance)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: copy-references (instance)
Package

mgl-cube.

Source

cube.lisp.

Function: copy-xorwow-states (from n to &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: ctype->cuda (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: ctype->lisp (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: ctype->lla (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: ctype->lla-internal (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: ctype-blas-prefix (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: ctype-size (ctype)
Package

mgl-mat.

Source

util.lisp.

Function: cublas-asum (n x incx &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-axpy (n alpha x incx y incy &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-call-form (cublas-name ctype params)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-call-form* (params args fn)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-copy (n x incx y incy &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dasum (n x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-daxpy (n alpha x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dcopy (n x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-ddot (n x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dgemm (transa transb m n k alpha a lda b ldb beta c ldc &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dnrm2 (n x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dot (n x incx y incy &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-dscal (n alpha x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-foreign-function-name (name ctype)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-funcall-form (name ctype params args)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-function-name (name ctype)
Package

mgl-mat.

Source

cublas.lisp.

Function: cublas-gemm (transa transb m n k alpha a lda b ldb beta c ldc &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-nrm2 (n x incx &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-sasum (n x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-saxpy (n alpha x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-scal (n alpha x incx &key handle stream)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-scopy (n x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-sdot (n x incx y incy &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-sgemm (transa transb m n k alpha a lda b ldb beta c ldc &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-snrm2 (n x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cublas-sscal (n alpha x incx &key handle)
Package

mgl-mat.

Source

cublas-functions.lisp.

Function: cuda-.+! (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.+!-d (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.+!-s (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cos! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cos!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cos!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cosh! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cosh!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.cosh!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.exp! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.exp!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.exp!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.expt! (power x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.expt!-d (power x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.expt!-s (power x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.inv! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.inv!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.inv!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.log! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.log!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.log!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.logistic! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.logistic!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.logistic!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.max! (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.max!-d (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.max!-s (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.min! (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.min!-d (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.min!-s (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sin! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sin!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sin!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sinh! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sinh!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sinh!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sqrt! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sqrt!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.sqrt!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.square! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.square!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.square!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tan! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tan!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tan!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tanh! (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tanh!-d (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-.tanh!-s (x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-add-sign! (alpha x beta y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-add-sign!-d (alpha x beta y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-add-sign!-s (alpha x beta y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-code (form ctype)
Package

mgl-mat.

Source

cuda-kernel.lisp.

Function: cuda-convolve-2d (x x-height x-width w w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-convolve-2d-d (x x-height x-width w w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-convolve-2d-s (x x-height x-width w w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-derive-convolve-2d (x x-height x-width xd w w-height w-width wd yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-derive-convolve-2d-d (x x-height x-width xd w w-height w-width wd yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-derive-convolve-2d-s (x x-height x-width xd w w-height w-width wd yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

convolve.lisp.

Function: cuda-derive-max-pool-2d (x x-height x-width xd w-height w-width y y-height y-width yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-derive-max-pool-2d-d (x x-height x-width xd w-height w-width y y-height y-width yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-derive-max-pool-2d-s (x x-height x-width xd w-height w-width y y-height y-width yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-fill! (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-fill!-2 (ctype alpha cuda-array n)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-fill!-d (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-fill!-s (alpha x n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geem! (alpha a b beta c n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geem!-d (alpha a b beta c n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geem!-s (alpha a b beta c n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geerv! (alpha a x beta b n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geerv!-d (alpha a x beta b n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-geerv!-s (alpha a x beta b n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-kernel-name (name ctype)
Package

mgl-mat.

Source

cuda-kernel.lisp.

Function: cuda-less-than! (x y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-less-than!-d (x y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-less-than!-s (x y n &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-max-pool-2d (x x-height x-width w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-max-pool-2d-d (x x-height x-width w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-max-pool-2d-s (x x-height x-width w-height w-width y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size &key grid-dim block-dim)
Package

mgl-mat.

Source

max-pool.lisp.

Function: cuda-scale-columns! (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-scale-columns!-d (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-scale-columns!-s (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-scale-rows! (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-scale-rows!-d (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-scale-rows!-s (scales x y n-rows n-columns &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-setf-mref (x index value &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-setf-mref-d (x index value &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: cuda-setf-mref-s (x index value &key grid-dim block-dim)
Package

mgl-mat.

Source

mat.lisp.

Function: curand-init-xorwow-simple (seed states n &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-normal-xorwow (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-normal-xorwow-d (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-normal-xorwow-s (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-uniform-xorwow (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-uniform-xorwow-d (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: curand-uniform-xorwow-s (states x n n-states &key grid-dim block-dim)
Package

mgl-mat.

Source

curand.lisp.

Function: deregister-cube-facet (cube facet-name)
Package

mgl-cube.

Source

cube.lisp.

Function: dimensions-total-size (dimensions)
Package

mgl-mat.

Source

mat.lisp.

Function: displacement-bytes (mat)
Package

mgl-mat.

Source

mat.lisp.

Function: ensure-cube-finalized (cube)
Package

mgl-cube.

Source

cube.lisp.

Function: ensure-facet (cube facet-name direction)
Package

mgl-cube.

Source

cube.lisp.

Function: ensure-pointer-param (param)
Package

mgl-mat.

Source

util.lisp.

Function: expand-with-facets (facet-binding-specs body)
Package

mgl-cube.

Source

cube.lisp.

Function: facet-barred-p (barrier cube facet-name)
Package

mgl-cube.

Source

cube.lisp.

Reader: facet-barrier-cube-type (instance)
Writer: (setf facet-barrier-cube-type) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

cube-type.

Reader: facet-barrier-cubes-to-barred-facets (instance)
Writer: (setf facet-barrier-cubes-to-barred-facets) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

cubes-to-barred-facets.

Reader: facet-barrier-destroys (instance)
Writer: (setf facet-barrier-destroys) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

destroys.

Reader: facet-barrier-ensures (instance)
Writer: (setf facet-barrier-ensures) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

ensures.

Function: facet-barrier-p (object)
Package

mgl-cube.

Source

cube.lisp.

Function: facet-p (object)
Package

mgl-cube.

Source

cube.lisp.

Reader: facet-references (instance)
Writer: (setf facet-references) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

references.

Function: facet-vars (mat-params)
Package

mgl-mat.

Source

util.lisp.

Function: fake-writer (facet fake-thread)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: find-up-to-date-facet (cube)
Package

mgl-cube.

Source

cube.lisp.

Function: finish-syncing-cuda-facets (sync-token safep)

Wait until all the copying started by START-SYNCING-CUDA-FACETS is done, then remove the CUDA-ARRAY facets of the CUDA-ARRAY facets from all matrices in KILLS that was passed to START-SYNCING-CUDA-FACETS.

Package

mgl-mat.

Source

cuda-early.lisp.

Function: free-cuda-vector (cuda-vector)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: free-some-reusables (pool n-bytes-to-free)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: free-static-vector (vector)
Package

mgl-mat.

Source

foreign.lisp.

Function: gaussian-random-1 ()

Return a double float of zero mean and unit variance.

Package

mgl-mat.

Source

mat.lisp.

Function: get-permission-to-destroy (references &key being-finalized)
Package

mgl-cube.

Source

cube.lisp.

Function: has-watchers-p (facet)
Package

mgl-cube.

Source

cube.lisp.

Function: has-writers-p (facet)
Package

mgl-cube.

Source

cube.lisp.

Function: incf-references (references delta)
Package

mgl-cube.

Source

cube.lisp.

Function: lisp-.+! (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.+!-d (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.+!-s (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cos! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cos!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cos!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cosh! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cosh!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.cosh!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.exp! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.exp!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.exp!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.expt! (power x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.expt!-d (power x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.expt!-s (power x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.inv! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.inv!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.inv!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.log! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.log!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.log!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.logistic! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.logistic!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.logistic!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.max! (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.max!-d (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.max!-s (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.min! (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.min!-d (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.min!-s (alpha x start-x n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sin! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sin!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sin!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sinh! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sinh!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sinh!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sqrt! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sqrt!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.sqrt!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.square! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.square!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.square!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tan! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tan!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tan!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tanh! (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tanh!-d (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-.tanh!-s (v start end)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp->ctype (lisp-type)
Package

mgl-mat.

Source

util.lisp.

Function: lisp-add-sign! (alpha x start-x beta y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-add-sign!-d (alpha x start-x beta y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-add-sign!-s (alpha x start-x beta y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-code (form ctype)
Package

mgl-mat.

Source

lisp-kernel.lisp.

Function: lisp-convolve-2d (x start-x x-height x-width w start-w w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-convolve-2d-d (x start-x x-height x-width w start-w w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-convolve-2d-s (x start-x x-height x-width w start-w w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-derive-convolve-2d (x start-x x-height x-width xd start-xd w start-w w-height w-width wd start-wd yd start-yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-derive-convolve-2d-d (x start-x x-height x-width xd start-xd w start-w w-height w-width wd start-wd yd start-yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-derive-convolve-2d-s (x start-x x-height x-width xd start-xd w start-w w-height w-width wd start-wd yd start-yd y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

convolve.lisp.

Function: lisp-derive-max-pool-2d (x start-x x-height x-width xd start-xd w-height w-width y start-y y-height y-width yd start-yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-derive-max-pool-2d-d (x start-x x-height x-width xd start-xd w-height w-width y start-y y-height y-width yd start-yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-derive-max-pool-2d-s (x start-x x-height x-width xd start-xd w-height w-width y start-y y-height y-width yd start-yd start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-geem! (alpha a start-a b start-b beta c start-c n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-geem!-d (alpha a start-a b start-b beta c start-c n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-geem!-s (alpha a start-a b start-b beta c start-c n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-geerv! (alpha a start-a x start-x beta b start-b n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-geerv!-d (alpha a start-a x start-x beta b start-b n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-geerv!-s (alpha a start-a x start-x beta b start-b n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-kernel-name (name ctype)
Package

mgl-mat.

Source

lisp-kernel.lisp.

Function: lisp-less-than! (x start-x y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-less-than!-d (x start-x y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-less-than!-s (x start-x y start-y n)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-max-pool-2d (x start-x x-height x-width w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-max-pool-2d-d (x start-x x-height x-width w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-max-pool-2d-s (x start-x x-height x-width w-height w-width y start-y y-height y-width start-0 start-1 stride-0 stride-1 anchor-0 anchor-1 batch-size)
Package

mgl-mat.

Source

max-pool.lisp.

Function: lisp-scale-columns! (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-scale-columns!-d (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-scale-columns!-s (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-scale-rows! (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-scale-rows!-d (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-scale-rows!-s (scales start-scales x start-x y start-y n-rows n-columns)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-uniform-random (v start end limit)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-uniform-random-d (v start end limit)
Package

mgl-mat.

Source

mat.lisp.

Function: lisp-uniform-random-s (v start end limit)
Package

mgl-mat.

Source

mat.lisp.

Reader: list-holder-list (instance)
Writer: (setf list-holder-list) (instance)
Package

mgl-mat.

Source

cuda-early.lisp.

Target Slot

list.

Function: list-holder-p (object)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: make-array-facet (mat vector)
Package

mgl-mat.

Source

mat.lisp.

Function: make-facet (&key name value description up-to-date-p n-watchers watcher-threads direction references)
Package

mgl-cube.

Source

cube.lisp.

Function: make-facet-barrier (&key cube-type ensures destroys cubes-to-barred-facets)
Package

mgl-cube.

Source

cube.lisp.

Function: make-list-holder (&key list)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: make-references (&key n list)
Package

mgl-cube.

Source

cube.lisp.

Function: make-xorwow-state/simple (seed n-states)
Package

mgl-mat.

Source

curand.lisp.

Function: map-tree (fn tree)
Package

mgl-mat.

Source

util.lisp.

Function: mat-facet-to-char (mat facet)
Package

mgl-mat.

Source

mat.lisp.

Function: mat-param-p (param)
Package

mgl-mat.

Source

util.lisp.

Function: maybe-rewire-to (mat vec facet-name vec-facet-name)
Package

mgl-mat.

Source

mat.lisp.

Function: maybe-unregister-pointers (cuda-pool)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: memcpy (dest src n)
Package

mgl-mat.

Source

util.lisp.

Function: non-mat-output-param-p (param)
Package

mgl-mat.

Source

util.lisp.

Function: note-allocation (n)
Package

mgl-mat.

Source

mat.lisp.

Function: param-direction (param)
Package

mgl-mat.

Source

util.lisp.

Function: param-name (param)
Package

mgl-mat.

Source

util.lisp.

Function: param-to-cuda (param)
Package

mgl-mat.

Source

cuda-kernel.lisp.

Function: param-type (param)
Package

mgl-mat.

Source

util.lisp.

Function: params-to-type-declarations (params)
Package

mgl-mat.

Source

lisp-kernel.lisp.

Function: pax-pages ()
Package

mgl-mat.

Source

doc.lisp.

Function: pax-sections ()
Package

mgl-mat.

Source

doc.lisp.

Function: print-mat-dimensions (mat stream)
Package

mgl-mat.

Source

mat.lisp.

Function: print-mat-facets (mat stream)
Package

mgl-mat.

Source

mat.lisp.

Function: print-vec-facets (mat stream)
Package

mgl-mat.

Source

vec.lisp.

Function: process-pool (cuda-pool)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: read-as-bytes (n stream)
Package

mgl-mat.

Source

util.lisp.

Function: read-double-float-vector (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: read-double-float-vector/generic (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: read-mat-header (mat stream)
Package

mgl-mat.

Source

mat.lisp.

Function: read-single-float-vector (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: read-single-float-vector/generic (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: reallocate-from-pool (pool n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Reader: references-list (instance)
Writer: (setf references-list) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

list.

Reader: references-n (instance)
Writer: (setf references-n) (instance)
Package

mgl-cube.

Source

cube.lisp.

Target Slot

n.

Function: references-p (object)
Package

mgl-cube.

Source

cube.lisp.

Function: register-cube-facet (cube facet-name)
Package

mgl-cube.

Source

cube.lisp.

Function: register-cuda-host-array (pointer n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: remove-fake-writer (facet fake-thread)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: replace-vector (vector start dimensions seq-of-seqs ctype)
Package

mgl-mat.

Source

mat.lisp.

Function: return-thread-cached-object (place-key key value)
Package

mgl-mat.

Source

util.lisp.

Function: return-to-pool (pool pointer n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: round-up (number divisor)
Package

mgl-mat.

Source

util.lisp.

Function: sanitize-n-random-states (n-states)
Package

mgl-mat.

Source

curand.lisp.

Function: set-mref (value mat &rest indices)
Package

mgl-mat.

Source

mat.lisp.

Function: set-row-major-mref (mat index value)
Package

mgl-mat.

Source

mat.lisp.

Setf expanders to this function

(setf row-major-mref).

Function: start-syncing-cuda-facets (mats-to-cuda mats-to-cuda-host safep)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: sync->fd (fd-stream)
Package

mgl-mat.

Source

util.lisp.

Function: sync<-fd (fd-stream)
Package

mgl-mat.

Source

util.lisp.

Function: synchronize-cube-p (cube)
Package

mgl-cube.

Source

cube.lisp.

Function: try-to-free-cuda-memory-1 (pool n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: try-to-free-cuda-memory-2 (pool n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: try-to-free-cuda-memory-3 (pool n-bytes)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: unregister-cuda-host-array (cuda-host-array callback)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: unregister-cuda-host-array-now (cuda-host-array callback)
Package

mgl-mat.

Source

cuda-early.lisp.

Function: use-pinning-p ()
Package

mgl-mat.

Source

foreign.lisp.

Function: valid-multi-dimensional-index-p (index-list dimensions)
Package

mgl-mat.

Source

convolve.lisp.

Function: vec-facet (facet)
Package

mgl-mat.

Source

mat.lisp.

Function: vec-facet-name (facet)
Package

mgl-mat.

Source

mat.lisp.

Function: vec-facet-to-char (vec facet)
Package

mgl-mat.

Source

vec.lisp.

Function: will-be-copied-over-p (vec)
Package

mgl-mat.

Source

vec.lisp.

Function: write-as-bytes (integer n stream)
Package

mgl-mat.

Source

util.lisp.

Function: write-double-float-vector (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: write-double-float-vector/generic (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: write-mat-header (mat stream)
Package

mgl-mat.

Source

mat.lisp.

Function: write-single-float-vector (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.

Function: write-single-float-vector/generic (array stream &key start end)
Package

mgl-mat.

Source

util.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Generic functions

Generic Reader: %facets (object)
Package

mgl-cube.

Methods
Reader Method: %facets ((cube cube))

automatically generated reader method

Source

cube.lisp.

Target Slot

facets.

Generic Reader: base-pointer (object)
Package

mgl-mat.

Methods
Reader Method: base-pointer ((offset-pointer offset-pointer))

automatically generated reader method

Source

util.lisp.

Target Slot

base-pointer.

Generic Function: copy-curand-state (state)
Package

mgl-mat.

Source

curand.lisp.

Methods
Method: copy-curand-state ((state curand-xorwow-state))
Generic Reader: cuda-pool (object)
Package

mgl-mat.

Methods
Reader Method: cuda-pool ((cuda-host-array cuda-host-array))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

cuda-pool.

Reader Method: cuda-pool ((cuda-vector cuda-vector))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

cuda-pool.

Reader Method: cuda-pool ((foreign-array foreign-array))

automatically generated reader method

Source

foreign.lisp.

Target Slot

cuda-pool.

Generic Writer: (setf cuda-pool) (object)
Package

mgl-mat.

Methods
Writer Method: (setf cuda-pool) ((cuda-host-array cuda-host-array))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

cuda-pool.

Writer Method: (setf cuda-pool) ((foreign-array foreign-array))

automatically generated writer method

Source

foreign.lisp.

Target Slot

cuda-pool.

Generic Function: curand-normal (state mat)
Package

mgl-mat.

Source

curand.lisp.

Methods
Method: curand-normal ((state curand-xorwow-state) mat)
Generic Function: curand-uniform (state mat)
Package

mgl-mat.

Source

curand.lisp.

Methods
Method: curand-uniform ((state curand-xorwow-state) mat)
Generic Function: destroy-curand-state (state)
Package

mgl-mat.

Source

curand.lisp.

Methods
Method: destroy-curand-state ((state curand-xorwow-state))
Generic Reader: destroys (object)
Package

mgl-mat.

Methods
Reader Method: destroys ((sync-token sync-token))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

destroys.

Generic Reader: ensures (object)
Package

mgl-mat.

Methods
Reader Method: ensures ((sync-token sync-token))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

ensures.

Generic Reader: has-finalizer-p (object)
Package

mgl-cube.

Methods
Reader Method: has-finalizer-p ((cube cube))

automatically generated reader method

Source

cube.lisp.

Target Slot

has-finalizer-p.

Generic Writer: (setf has-finalizer-p) (object)
Package

mgl-cube.

Methods
Writer Method: (setf has-finalizer-p) ((cube cube))

automatically generated writer method

Source

cube.lisp.

Target Slot

has-finalizer-p.

Generic Reader: host-arrays-to-be-unregistered (object)
Package

mgl-mat.

Methods
Reader Method: host-arrays-to-be-unregistered ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

host-arrays-to-be-unregistered.

Generic Writer: (setf host-arrays-to-be-unregistered) (object)
Package

mgl-mat.

Methods
Writer Method: (setf host-arrays-to-be-unregistered) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

host-arrays-to-be-unregistered.

Generic Reader: lock (object)
Package

mgl-cube.

Methods
Reader Method: lock ((cube cube))

automatically generated reader method

Source

cube.lisp.

Target Slot

lock.

Generic Writer: (setf lock) (object)
Package

mgl-cube.

Methods
Writer Method: (setf lock) ((cube cube))

automatically generated writer method

Source

cube.lisp.

Target Slot

lock.

Generic Reader: lock (object)
Package

mgl-mat.

Methods
Reader Method: lock ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

lock.

Reader Method: lock ((foreign-array foreign-array))

automatically generated reader method

Source

foreign.lisp.

Target Slot

lock.

Reader Method: lock ((foreign-pool foreign-pool))

automatically generated reader method

Source

foreign.lisp.

Target Slot

lock.

Generic Writer: (setf lock) (object)
Package

mgl-mat.

Methods
Writer Method: (setf lock) ((foreign-array foreign-array))

automatically generated writer method

Source

foreign.lisp.

Target Slot

lock.

Generic Reader: n-bytes (condition)
Package

mgl-mat.

Methods
Reader Method: n-bytes ((condition cuda-out-of-memory))
Source

cuda-early.lisp.

Target Slot

n-bytes.

Generic Reader: n-bytes-allocated (object)
Package

mgl-mat.

Methods
Reader Method: n-bytes-allocated ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

n-bytes-allocated.

Generic Writer: (setf n-bytes-allocated) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-bytes-allocated) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

n-bytes-allocated.

Generic Reader: n-bytes-free (object)
Package

mgl-mat.

Methods
Reader Method: n-bytes-free ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

n-bytes-free.

Generic Writer: (setf n-bytes-free) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-bytes-free) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

n-bytes-free.

Generic Reader: n-bytes-host-array-registered (object)
Package

mgl-mat.

Methods
Reader Method: n-bytes-host-array-registered ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

n-bytes-host-array-registered.

Generic Writer: (setf n-bytes-host-array-registered) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-bytes-host-array-registered) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

n-bytes-host-array-registered.

Generic Reader: n-bytes-reusable (object)
Package

mgl-mat.

Methods
Reader Method: n-bytes-reusable ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

n-bytes-reusable.

Generic Writer: (setf n-bytes-reusable) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-bytes-reusable) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

n-bytes-reusable.

Generic Reader: n-references (object)
Package

mgl-mat.

Methods
Reader Method: n-references ((foreign-array foreign-array))

automatically generated reader method

Source

foreign.lisp.

Target Slot

n-references.

Generic Writer: (setf n-references) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-references) ((foreign-array foreign-array))

automatically generated writer method

Source

foreign.lisp.

Target Slot

n-references.

Generic Reader: n-static-arrays (object)
Package

mgl-mat.

Methods
Reader Method: n-static-arrays ((foreign-pool foreign-pool))

automatically generated reader method

Source

foreign.lisp.

Target Slot

n-static-arrays.

Generic Writer: (setf n-static-arrays) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-static-arrays) ((foreign-pool foreign-pool))

automatically generated writer method

Source

foreign.lisp.

Target Slot

n-static-arrays.

Generic Reader: n-static-bytes-allocated (object)
Package

mgl-mat.

Methods
Reader Method: n-static-bytes-allocated ((foreign-pool foreign-pool))

automatically generated reader method

Source

foreign.lisp.

Target Slot

n-static-bytes-allocated.

Generic Writer: (setf n-static-bytes-allocated) (object)
Package

mgl-mat.

Methods
Writer Method: (setf n-static-bytes-allocated) ((foreign-pool foreign-pool))

automatically generated writer method

Source

foreign.lisp.

Target Slot

n-static-bytes-allocated.

Generic Reader: offset (object)
Package

mgl-mat.

Methods
Reader Method: offset ((offset-pointer offset-pointer))

automatically generated reader method

Source

util.lisp.

Target Slot

offset.

Generic Function: offset-pointer (offset-pointer)
Package

mgl-mat.

Source

util.lisp.

Methods
Method: offset-pointer ((array offset-pointer))
Generic Reader: pointer-n-bytes (object)
Package

mgl-mat.

Methods
Reader Method: pointer-n-bytes ((offset-pointer offset-pointer))

automatically generated reader method

Source

util.lisp.

Target Slot

n-bytes.

Generic Function: reshape-and-displace-facet* (mat facet-name facet dimensions displacement)
Package

mgl-mat.

Source

mat.lisp.

Methods
Method: reshape-and-displace-facet* ((mat mat) (facet-name (eql mgl-mat:cuda-array)) facet dimensions displacement)
Method: reshape-and-displace-facet* ((mat mat) (facet-name (eql array)) facet dimensions displacement)
Method: reshape-and-displace-facet* ((mat mat) facet-name facet dimensions displacement)
Generic Reader: reusables (object)
Package

mgl-mat.

Methods
Reader Method: reusables ((cuda-pool cuda-pool))

automatically generated reader method

Source

cuda-early.lisp.

Target Slot

reusables.

Generic Writer: (setf reusables) (object)
Package

mgl-mat.

Methods
Writer Method: (setf reusables) ((cuda-pool cuda-pool))

automatically generated writer method

Source

cuda-early.lisp.

Target Slot

reusables.

Generic Reader: vec (object)
Package

mgl-mat.

Methods
Reader Method: vec ((mat mat))

automatically generated reader method

Source

mat.lisp.

Target Slot

vec.

Generic Reader: vec-ctype (object)
Package

mgl-mat.

Methods
Reader Method: vec-ctype ((vec vec))

automatically generated reader method

Source

vec.lisp.

Target Slot

ctype.

Generic Reader: vec-initial-element (object)
Package

mgl-mat.

Methods
Reader Method: vec-initial-element ((vec vec))

automatically generated reader method

Source

vec.lisp.

Target Slot

initial-element.

Generic Reader: vec-n-bytes (object)
Package

mgl-mat.

Methods
Reader Method: vec-n-bytes ((vec vec))

automatically generated reader method

Source

vec.lisp.

Target Slot

n-bytes.

Generic Reader: vec-size (object)
Package

mgl-mat.

Methods
Reader Method: vec-size ((vec vec))

automatically generated reader method

Source

vec.lisp.

Target Slot

size.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.5 Structures

Structure: facet-barrier
Package

mgl-cube.

Source

cube.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: cube-type
Readers

facet-barrier-cube-type.

Writers

(setf facet-barrier-cube-type).

Slot: ensures
Readers

facet-barrier-ensures.

Writers

(setf facet-barrier-ensures).

Slot: destroys
Readers

facet-barrier-destroys.

Writers

(setf facet-barrier-destroys).

Slot: cubes-to-barred-facets
Initform

(trivial-garbage:make-weak-hash-table :weakness :key)

Readers

facet-barrier-cubes-to-barred-facets.

Writers

(setf facet-barrier-cubes-to-barred-facets).

Structure: list-holder
Package

mgl-mat.

Source

cuda-early.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: list
Package

common-lisp.

Readers

list-holder-list.

Writers

(setf list-holder-list).

Structure: references
Package

mgl-cube.

Source

cube.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: n
Initform

0

Readers

references-n.

Writers

(setf references-n).

Slot: list
Package

common-lisp.

Readers

references-list.

Writers

(setf references-list).


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.6 Classes

Class: cuda-pool
Package

mgl-mat.

Source

cuda-early.lisp.

Direct methods
Direct slots
Slot: n-bytes-allocated
Initform

0

Readers

n-bytes-allocated.

Writers

(setf n-bytes-allocated).

Slot: n-bytes-reusable
Initform

0

Readers

n-bytes-reusable.

Writers

(setf n-bytes-reusable).

Slot: n-bytes-free
Initargs

:n-bytes-free

Readers

n-bytes-free.

Writers

(setf n-bytes-free).

Slot: reusables
Initform

(make-hash-table)

Readers

reusables.

Writers

(setf reusables).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

This slot is read-only.

Slot: host-arrays-to-be-unregistered
Initform

(mgl-mat::make-list-holder)

Readers

host-arrays-to-be-unregistered.

Writers

(setf host-arrays-to-be-unregistered).

Slot: n-bytes-host-array-registered
Initform

0

Readers

n-bytes-host-array-registered.

Writers

(setf n-bytes-host-array-registered).

Class: cuda-vector
Package

mgl-mat.

Source

cuda-early.lisp.

Direct superclasses

offset-pointer.

Direct methods

cuda-pool.

Direct slots
Slot: cuda-pool
Initform

mgl-mat::*cuda-pool*

Readers

cuda-pool.

Writers

This slot is read-only.

Class: curand-state
Package

mgl-mat.

Source

curand.lisp.

Direct subclasses

curand-xorwow-state.

Direct methods

copy-random-state.

Class: foreign-pool
Package

mgl-mat.

Source

foreign.lisp.

Direct methods
Direct slots
Slot: n-static-arrays
Initform

0

Readers

n-static-arrays.

Writers

(setf n-static-arrays).

Slot: n-static-bytes-allocated
Initform

0

Readers

n-static-bytes-allocated.

Writers

(setf n-static-bytes-allocated).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

This slot is read-only.

Class: offset-pointer
Package

mgl-mat.

Source

util.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: base-pointer
Initargs

:base-pointer

Readers

base-pointer.

Writers

This slot is read-only.

Slot: offset
Initform

0

Initargs

:offset

Readers

offset.

Writers

This slot is read-only.

Slot: n-bytes
Initargs

:n-bytes

Readers

pointer-n-bytes.

Writers

This slot is read-only.

Class: sync-token
Package

mgl-mat.

Source

cuda-early.lisp.

Direct methods
Direct slots
Slot: ensures
Initargs

:ensures

Readers

ensures.

Writers

This slot is read-only.

Slot: destroys
Initargs

:destroys

Readers

destroys.

Writers

This slot is read-only.

Class: vec
Package

mgl-mat.

Source

vec.lisp.

Direct superclasses

cube.

Direct methods
Direct slots
Slot: ctype
Type

mgl-mat:ctype

Initform

mgl-mat:*default-mat-ctype*

Initargs

:ctype

Readers

vec-ctype.

Writers

This slot is read-only.

Slot: initial-element
Initform

0

Initargs

:initial-element

Readers

vec-initial-element.

Writers

This slot is read-only.

Slot: size
Initargs

:size

Readers

vec-size.

Writers

This slot is read-only.

Slot: n-bytes
Readers

vec-n-bytes.

Writers

This slot is read-only.


Previous: , Up: Internals   [Contents][Index]

6.2.7 Types

Type: double-float-vector ()
Package

mgl-mat.

Source

util.lisp.

Type: index ()
Package

mgl-mat.

Source

util.lisp.

Type: single-float-vector ()
Package

mgl-mat.

Source

util.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (   .  
A   B   C   D   E   F   G   H   I   L   M   N   O   P   R   S   T   U   V   W  
Index Entry  Section

%
%cublas-destroy: Private ordinary functions
%cublas-get-version: Private ordinary functions
%facets: Private generic functions
%facets: Private generic functions

(
(setf cuda-enabled): Public generic functions
(setf cuda-enabled): Public generic functions
(setf cuda-pool): Private generic functions
(setf cuda-pool): Private generic functions
(setf cuda-pool): Private generic functions
(setf facet-barrier-cube-type): Private ordinary functions
(setf facet-barrier-cubes-to-barred-facets): Private ordinary functions
(setf facet-barrier-destroys): Private ordinary functions
(setf facet-barrier-ensures): Private ordinary functions
(setf facet-description): Public ordinary functions
(setf facet-direction): Public ordinary functions
(setf facet-n-watchers): Public ordinary functions
(setf facet-name): Public ordinary functions
(setf facet-references): Private ordinary functions
(setf facet-up-to-date-p): Public ordinary functions
(setf facet-value): Public ordinary functions
(setf facet-watcher-threads): Public ordinary functions
(setf has-finalizer-p): Private generic functions
(setf has-finalizer-p): Private generic functions
(setf host-arrays-to-be-unregistered): Private generic functions
(setf host-arrays-to-be-unregistered): Private generic functions
(setf list-holder-list): Private ordinary functions
(setf lock): Private generic functions
(setf lock): Private generic functions
(setf lock): Private generic functions
(setf lock): Private generic functions
(setf mref): Public setf expanders
(setf n-bytes-allocated): Private generic functions
(setf n-bytes-allocated): Private generic functions
(setf n-bytes-free): Private generic functions
(setf n-bytes-free): Private generic functions
(setf n-bytes-host-array-registered): Private generic functions
(setf n-bytes-host-array-registered): Private generic functions
(setf n-bytes-reusable): Private generic functions
(setf n-bytes-reusable): Private generic functions
(setf n-references): Private generic functions
(setf n-references): Private generic functions
(setf n-static-arrays): Private generic functions
(setf n-static-arrays): Private generic functions
(setf n-static-bytes-allocated): Private generic functions
(setf n-static-bytes-allocated): Private generic functions
(setf references-list): Private ordinary functions
(setf references-n): Private ordinary functions
(setf reusables): Private generic functions
(setf reusables): Private generic functions
(setf row-major-mref): Public setf expanders
(setf synchronization): Public generic functions
(setf synchronization): Public generic functions

.
.*!: Public ordinary functions
.+!: Public ordinary functions
.<!: Public ordinary functions
.cos!: Public ordinary functions
.cosh!: Public ordinary functions
.exp!: Public ordinary functions
.expt!: Public ordinary functions
.inv!: Public ordinary functions
.log!: Public ordinary functions
.logistic!: Public ordinary functions
.max!: Public ordinary functions
.min!: Public ordinary functions
.sin!: Public ordinary functions
.sinh!: Public ordinary functions
.sqrt!: Public ordinary functions
.square!: Public ordinary functions
.tan!: Public ordinary functions
.tanh!: Public ordinary functions

A
add-facet: Private ordinary functions
add-facet-reference-by-name: Public ordinary functions
add-host-array-to-be-unregistered: Private ordinary functions
add-sign!: Public ordinary functions
adjust!: Public ordinary functions
alloc-cuda-vector: Private ordinary functions
alloc-cuda-vector-with-recovery: Private ordinary functions
alloc-static-vector: Private ordinary functions
allocate-to-pool: Private ordinary functions
append-to-symbol: Private ordinary functions
array-to-mat: Public ordinary functions
asum: Public ordinary functions
axpy!: Public ordinary functions

B
base-pointer: Private generic functions
base-pointer: Private generic functions
blas-asum: Private ordinary functions
blas-axpy: Private ordinary functions
blas-call-form: Private ordinary functions
blas-call-form*: Private ordinary functions
blas-copy: Private ordinary functions
blas-dasum: Private ordinary functions
blas-daxpy: Private ordinary functions
blas-dcopy: Private ordinary functions
blas-ddot: Private ordinary functions
blas-dgemm: Private ordinary functions
blas-dnrm2: Private ordinary functions
blas-dot: Private ordinary functions
blas-dscal: Private ordinary functions
blas-foreign-function-name: Private ordinary functions
blas-funcall-form: Private ordinary functions
blas-function-name: Private ordinary functions
blas-function-name*: Private macros
blas-gemm: Private ordinary functions
blas-nrm2: Private ordinary functions
blas-sasum: Private ordinary functions
blas-saxpy: Private ordinary functions
blas-scal: Private ordinary functions
blas-scopy: Private ordinary functions
blas-sdot: Private ordinary functions
blas-sgemm: Private ordinary functions
blas-snrm2: Private ordinary functions
blas-sscal: Private ordinary functions
borrow-thread-cached-object: Private ordinary functions

C
call-blas-function: Private macros
call-cublas-function: Private macros
call-cuda-kernel: Private macros
call-lisp-kernel: Private macros
call-with-cuda: Public ordinary functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
call-with-facet*: Public generic functions
check-cuda-sdk: Private ordinary functions
check-dimensions: Private ordinary functions
check-no-watchers: Public ordinary functions
check-no-writers: Public ordinary functions
choose-1d-block-and-grid: Public ordinary functions
choose-2d-block-and-grid: Public ordinary functions
choose-3d-block-and-grid: Public ordinary functions
cleanup-cube: Private ordinary functions
cleanup-facets: Private ordinary functions
clip: Private ordinary functions
coerce-to-ctype: Public ordinary functions
common-mat-ctype: Private ordinary functions
compare-and-swap: Private macros
convert-param-type: Private ordinary functions
convert-param-types: Private ordinary functions
convert-to-cuda-code: Private ordinary functions
convert-to-lisp-code: Private ordinary functions
convolve!: Public ordinary functions
copy!: Public ordinary functions
copy-column: Public ordinary functions
copy-curand-state: Private generic functions
copy-curand-state: Private generic functions
copy-facet: Private ordinary functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet*: Public generic functions
copy-facet-barrier: Private ordinary functions
copy-list-holder: Private ordinary functions
copy-mat: Public ordinary functions
copy-random-state: Public generic functions
copy-random-state: Public generic functions
copy-random-state: Public generic functions
copy-references: Private ordinary functions
copy-row: Public ordinary functions
copy-xorwow-states: Private ordinary functions
count-barred-facets: Public ordinary functions
ctype->cuda: Private ordinary functions
ctype->lisp: Private ordinary functions
ctype->lla: Private ordinary functions
ctype->lla-internal: Private ordinary functions
ctype-blas-prefix: Private ordinary functions
ctype-size: Private ordinary functions
cublas-asum: Private ordinary functions
cublas-axpy: Private ordinary functions
cublas-call-form: Private ordinary functions
cublas-call-form*: Private ordinary functions
cublas-copy: Private ordinary functions
cublas-create: Public ordinary functions
cublas-dasum: Private ordinary functions
cublas-daxpy: Private ordinary functions
cublas-dcopy: Private ordinary functions
cublas-ddot: Private ordinary functions
cublas-destroy: Public ordinary functions
cublas-dgemm: Private ordinary functions
cublas-dnrm2: Private ordinary functions
cublas-dot: Private ordinary functions
cublas-dscal: Private ordinary functions
cublas-error-function-name: Public generic functions
cublas-error-function-name: Public generic functions
cublas-error-status: Public generic functions
cublas-error-status: Public generic functions
cublas-foreign-function-name: Private ordinary functions
cublas-funcall-form: Private ordinary functions
cublas-function-name: Private ordinary functions
cublas-function-name*: Private macros
cublas-gemm: Private ordinary functions
cublas-get-version: Public ordinary functions
cublas-nrm2: Private ordinary functions
cublas-sasum: Private ordinary functions
cublas-saxpy: Private ordinary functions
cublas-scal: Private ordinary functions
cublas-scopy: Private ordinary functions
cublas-sdot: Private ordinary functions
cublas-sgemm: Private ordinary functions
cublas-snrm2: Private ordinary functions
cublas-sscal: Private ordinary functions
cuda-.+!: Private ordinary functions
cuda-.+!-d: Private ordinary functions
cuda-.+!-s: Private ordinary functions
cuda-.cos!: Private ordinary functions
cuda-.cos!-d: Private ordinary functions
cuda-.cos!-s: Private ordinary functions
cuda-.cosh!: Private ordinary functions
cuda-.cosh!-d: Private ordinary functions
cuda-.cosh!-s: Private ordinary functions
cuda-.exp!: Private ordinary functions
cuda-.exp!-d: Private ordinary functions
cuda-.exp!-s: Private ordinary functions
cuda-.expt!: Private ordinary functions
cuda-.expt!-d: Private ordinary functions
cuda-.expt!-s: Private ordinary functions
cuda-.inv!: Private ordinary functions
cuda-.inv!-d: Private ordinary functions
cuda-.inv!-s: Private ordinary functions
cuda-.log!: Private ordinary functions
cuda-.log!-d: Private ordinary functions
cuda-.log!-s: Private ordinary functions
cuda-.logistic!: Private ordinary functions
cuda-.logistic!-d: Private ordinary functions
cuda-.logistic!-s: Private ordinary functions
cuda-.max!: Private ordinary functions
cuda-.max!-d: Private ordinary functions
cuda-.max!-s: Private ordinary functions
cuda-.min!: Private ordinary functions
cuda-.min!-d: Private ordinary functions
cuda-.min!-s: Private ordinary functions
cuda-.sin!: Private ordinary functions
cuda-.sin!-d: Private ordinary functions
cuda-.sin!-s: Private ordinary functions
cuda-.sinh!: Private ordinary functions
cuda-.sinh!-d: Private ordinary functions
cuda-.sinh!-s: Private ordinary functions
cuda-.sqrt!: Private ordinary functions
cuda-.sqrt!-d: Private ordinary functions
cuda-.sqrt!-s: Private ordinary functions
cuda-.square!: Private ordinary functions
cuda-.square!-d: Private ordinary functions
cuda-.square!-s: Private ordinary functions
cuda-.tan!: Private ordinary functions
cuda-.tan!-d: Private ordinary functions
cuda-.tan!-s: Private ordinary functions
cuda-.tanh!: Private ordinary functions
cuda-.tanh!-d: Private ordinary functions
cuda-.tanh!-s: Private ordinary functions
cuda-add-sign!: Private ordinary functions
cuda-add-sign!-d: Private ordinary functions
cuda-add-sign!-s: Private ordinary functions
cuda-available-p: Public ordinary functions
cuda-code: Private ordinary functions
cuda-convolve-2d: Private ordinary functions
cuda-convolve-2d-d: Private ordinary functions
cuda-convolve-2d-s: Private ordinary functions
cuda-derive-convolve-2d: Private ordinary functions
cuda-derive-convolve-2d-d: Private ordinary functions
cuda-derive-convolve-2d-s: Private ordinary functions
cuda-derive-max-pool-2d: Private ordinary functions
cuda-derive-max-pool-2d-d: Private ordinary functions
cuda-derive-max-pool-2d-s: Private ordinary functions
cuda-enabled: Public generic functions
cuda-enabled: Public generic functions
cuda-fill!: Private ordinary functions
cuda-fill!-2: Private ordinary functions
cuda-fill!-d: Private ordinary functions
cuda-fill!-s: Private ordinary functions
cuda-geem!: Private ordinary functions
cuda-geem!-d: Private ordinary functions
cuda-geem!-s: Private ordinary functions
cuda-geerv!: Private ordinary functions
cuda-geerv!-d: Private ordinary functions
cuda-geerv!-s: Private ordinary functions
cuda-kernel-name: Private ordinary functions
cuda-less-than!: Private ordinary functions
cuda-less-than!-d: Private ordinary functions
cuda-less-than!-s: Private ordinary functions
cuda-max-pool-2d: Private ordinary functions
cuda-max-pool-2d-d: Private ordinary functions
cuda-max-pool-2d-s: Private ordinary functions
cuda-pool: Private generic functions
cuda-pool: Private generic functions
cuda-pool: Private generic functions
cuda-pool: Private generic functions
cuda-room: Public ordinary functions
cuda-scale-columns!: Private ordinary functions
cuda-scale-columns!-d: Private ordinary functions
cuda-scale-columns!-s: Private ordinary functions
cuda-scale-rows!: Private ordinary functions
cuda-scale-rows!-d: Private ordinary functions
cuda-scale-rows!-s: Private ordinary functions
cuda-setf-mref: Private ordinary functions
cuda-setf-mref-d: Private ordinary functions
cuda-setf-mref-s: Private ordinary functions
curand-init-xorwow-simple: Private ordinary functions
curand-normal: Private generic functions
curand-normal: Private generic functions
curand-normal-xorwow: Private ordinary functions
curand-normal-xorwow-d: Private ordinary functions
curand-normal-xorwow-s: Private ordinary functions
curand-uniform: Private generic functions
curand-uniform: Private generic functions
curand-uniform-xorwow: Private ordinary functions
curand-uniform-xorwow-d: Private ordinary functions
curand-uniform-xorwow-s: Private ordinary functions

D
define-auxiliary-cublas-function: Private macros
define-blas-function: Private macros
define-cublas-function: Private macros
define-cuda-kernel: Public macros
define-elementwise-cuda-kernel: Private macros
define-elementwise-dispatcher: Private macros
define-elementwise-lisp-kernel: Private macros
define-facet-name: Public macros
define-lisp-kernel: Public macros
deregister-cube-facet: Private ordinary functions
derive-convolve!: Public ordinary functions
derive-max-pool!: Public ordinary functions
destroy-cube: Public ordinary functions
destroy-curand-state: Private generic functions
destroy-curand-state: Private generic functions
destroy-facet: Public ordinary functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroy-facet*: Public generic functions
destroys: Private generic functions
destroys: Private generic functions
dimensions-total-size: Private ordinary functions
displace: Public ordinary functions
displace!: Public ordinary functions
displacement-bytes: Private ordinary functions

E
ensure-cube-finalized: Private ordinary functions
ensure-facet: Private ordinary functions
ensure-pointer-param: Private ordinary functions
ensures: Private generic functions
ensures: Private generic functions
expand-with-facets: Private ordinary functions

F
facet-barred-p: Private ordinary functions
facet-barrier-cube-type: Private ordinary functions
facet-barrier-cubes-to-barred-facets: Private ordinary functions
facet-barrier-destroys: Private ordinary functions
facet-barrier-ensures: Private ordinary functions
facet-barrier-p: Private ordinary functions
facet-description: Public ordinary functions
facet-direction: Public ordinary functions
facet-n-watchers: Public ordinary functions
facet-name: Public ordinary functions
facet-p: Private ordinary functions
facet-references: Private ordinary functions
facet-up-to-date-p: Public ordinary functions
facet-up-to-date-p*: Public generic functions
facet-up-to-date-p*: Public generic functions
facet-up-to-date-p*: Public generic functions
facet-value: Public ordinary functions
facet-vars: Private ordinary functions
facet-watcher-threads: Public ordinary functions
facets: Public ordinary functions
fake-writer: Private ordinary functions
fill!: Public ordinary functions
find-facet: Public ordinary functions
find-up-to-date-facet: Private ordinary functions
finish-syncing-cuda-facets: Private ordinary functions
foreign-room: Public ordinary functions
free-cuda-vector: Private ordinary functions
free-some-reusables: Private ordinary functions
free-static-vector: Private ordinary functions
Function, %cublas-destroy: Private ordinary functions
Function, %cublas-get-version: Private ordinary functions
Function, (setf facet-barrier-cube-type): Private ordinary functions
Function, (setf facet-barrier-cubes-to-barred-facets): Private ordinary functions
Function, (setf facet-barrier-destroys): Private ordinary functions
Function, (setf facet-barrier-ensures): Private ordinary functions
Function, (setf facet-description): Public ordinary functions
Function, (setf facet-direction): Public ordinary functions
Function, (setf facet-n-watchers): Public ordinary functions
Function, (setf facet-name): Public ordinary functions
Function, (setf facet-references): Private ordinary functions
Function, (setf facet-up-to-date-p): Public ordinary functions
Function, (setf facet-value): Public ordinary functions
Function, (setf facet-watcher-threads): Public ordinary functions
Function, (setf list-holder-list): Private ordinary functions
Function, (setf references-list): Private ordinary functions
Function, (setf references-n): Private ordinary functions
Function, .*!: Public ordinary functions
Function, .+!: Public ordinary functions
Function, .<!: Public ordinary functions
Function, .cos!: Public ordinary functions
Function, .cosh!: Public ordinary functions
Function, .exp!: Public ordinary functions
Function, .expt!: Public ordinary functions
Function, .inv!: Public ordinary functions
Function, .log!: Public ordinary functions
Function, .logistic!: Public ordinary functions
Function, .max!: Public ordinary functions
Function, .min!: Public ordinary functions
Function, .sin!: Public ordinary functions
Function, .sinh!: Public ordinary functions
Function, .sqrt!: Public ordinary functions
Function, .square!: Public ordinary functions
Function, .tan!: Public ordinary functions
Function, .tanh!: Public ordinary functions
Function, add-facet: Private ordinary functions
Function, add-facet-reference-by-name: Public ordinary functions
Function, add-host-array-to-be-unregistered: Private ordinary functions
Function, add-sign!: Public ordinary functions
Function, adjust!: Public ordinary functions
Function, alloc-cuda-vector: Private ordinary functions
Function, alloc-cuda-vector-with-recovery: Private ordinary functions
Function, alloc-static-vector: Private ordinary functions
Function, allocate-to-pool: Private ordinary functions
Function, append-to-symbol: Private ordinary functions
Function, array-to-mat: Public ordinary functions
Function, asum: Public ordinary functions
Function, axpy!: Public ordinary functions
Function, blas-asum: Private ordinary functions
Function, blas-axpy: Private ordinary functions
Function, blas-call-form: Private ordinary functions
Function, blas-call-form*: Private ordinary functions
Function, blas-copy: Private ordinary functions
Function, blas-dasum: Private ordinary functions
Function, blas-daxpy: Private ordinary functions
Function, blas-dcopy: Private ordinary functions
Function, blas-ddot: Private ordinary functions
Function, blas-dgemm: Private ordinary functions
Function, blas-dnrm2: Private ordinary functions
Function, blas-dot: Private ordinary functions
Function, blas-dscal: Private ordinary functions
Function, blas-foreign-function-name: Private ordinary functions
Function, blas-funcall-form: Private ordinary functions
Function, blas-function-name: Private ordinary functions
Function, blas-gemm: Private ordinary functions
Function, blas-nrm2: Private ordinary functions
Function, blas-sasum: Private ordinary functions
Function, blas-saxpy: Private ordinary functions
Function, blas-scal: Private ordinary functions
Function, blas-scopy: Private ordinary functions
Function, blas-sdot: Private ordinary functions
Function, blas-sgemm: Private ordinary functions
Function, blas-snrm2: Private ordinary functions
Function, blas-sscal: Private ordinary functions
Function, borrow-thread-cached-object: Private ordinary functions
Function, call-with-cuda: Public ordinary functions
Function, check-cuda-sdk: Private ordinary functions
Function, check-dimensions: Private ordinary functions
Function, check-no-watchers: Public ordinary functions
Function, check-no-writers: Public ordinary functions
Function, choose-1d-block-and-grid: Public ordinary functions
Function, choose-2d-block-and-grid: Public ordinary functions
Function, choose-3d-block-and-grid: Public ordinary functions
Function, cleanup-cube: Private ordinary functions
Function, cleanup-facets: Private ordinary functions
Function, clip: Private ordinary functions
Function, coerce-to-ctype: Public ordinary functions
Function, common-mat-ctype: Private ordinary functions
Function, convert-param-type: Private ordinary functions
Function, convert-param-types: Private ordinary functions
Function, convert-to-cuda-code: Private ordinary functions
Function, convert-to-lisp-code: Private ordinary functions
Function, convolve!: Public ordinary functions
Function, copy!: Public ordinary functions
Function, copy-column: Public ordinary functions
Function, copy-facet: Private ordinary functions
Function, copy-facet-barrier: Private ordinary functions
Function, copy-list-holder: Private ordinary functions
Function, copy-mat: Public ordinary functions
Function, copy-references: Private ordinary functions
Function, copy-row: Public ordinary functions
Function, copy-xorwow-states: Private ordinary functions
Function, count-barred-facets: Public ordinary functions
Function, ctype->cuda: Private ordinary functions
Function, ctype->lisp: Private ordinary functions
Function, ctype->lla: Private ordinary functions
Function, ctype->lla-internal: Private ordinary functions
Function, ctype-blas-prefix: Private ordinary functions
Function, ctype-size: Private ordinary functions
Function, cublas-asum: Private ordinary functions
Function, cublas-axpy: Private ordinary functions
Function, cublas-call-form: Private ordinary functions
Function, cublas-call-form*: Private ordinary functions
Function, cublas-copy: Private ordinary functions
Function, cublas-create: Public ordinary functions
Function, cublas-dasum: Private ordinary functions
Function, cublas-daxpy: Private ordinary functions
Function, cublas-dcopy: Private ordinary functions
Function, cublas-ddot: Private ordinary functions
Function, cublas-destroy: Public ordinary functions
Function, cublas-dgemm: Private ordinary functions
Function, cublas-dnrm2: Private ordinary functions
Function, cublas-dot: Private ordinary functions
Function, cublas-dscal: Private ordinary functions
Function, cublas-foreign-function-name: Private ordinary functions
Function, cublas-funcall-form: Private ordinary functions
Function, cublas-function-name: Private ordinary functions
Function, cublas-gemm: Private ordinary functions
Function, cublas-get-version: Public ordinary functions
Function, cublas-nrm2: Private ordinary functions
Function, cublas-sasum: Private ordinary functions
Function, cublas-saxpy: Private ordinary functions
Function, cublas-scal: Private ordinary functions
Function, cublas-scopy: Private ordinary functions
Function, cublas-sdot: Private ordinary functions
Function, cublas-sgemm: Private ordinary functions
Function, cublas-snrm2: Private ordinary functions
Function, cublas-sscal: Private ordinary functions
Function, cuda-.+!: Private ordinary functions
Function, cuda-.+!-d: Private ordinary functions
Function, cuda-.+!-s: Private ordinary functions
Function, cuda-.cos!: Private ordinary functions
Function, cuda-.cos!-d: Private ordinary functions
Function, cuda-.cos!-s: Private ordinary functions
Function, cuda-.cosh!: Private ordinary functions
Function, cuda-.cosh!-d: Private ordinary functions
Function, cuda-.cosh!-s: Private ordinary functions
Function, cuda-.exp!: Private ordinary functions
Function, cuda-.exp!-d: Private ordinary functions
Function, cuda-.exp!-s: Private ordinary functions
Function, cuda-.expt!: Private ordinary functions
Function, cuda-.expt!-d: Private ordinary functions
Function, cuda-.expt!-s: Private ordinary functions
Function, cuda-.inv!: Private ordinary functions
Function, cuda-.inv!-d: Private ordinary functions
Function, cuda-.inv!-s: Private ordinary functions
Function, cuda-.log!: Private ordinary functions
Function, cuda-.log!-d: Private ordinary functions
Function, cuda-.log!-s: Private ordinary functions
Function, cuda-.logistic!: Private ordinary functions
Function, cuda-.logistic!-d: Private ordinary functions
Function, cuda-.logistic!-s: Private ordinary functions
Function, cuda-.max!: Private ordinary functions
Function, cuda-.max!-d: Private ordinary functions
Function, cuda-.max!-s: Private ordinary functions
Function, cuda-.min!: Private ordinary functions
Function, cuda-.min!-d: Private ordinary functions
Function, cuda-.min!-s: Private ordinary functions
Function, cuda-.sin!: Private ordinary functions
Function, cuda-.sin!-d: Private ordinary functions
Function, cuda-.sin!-s: Private ordinary functions
Function, cuda-.sinh!: Private ordinary functions
Function, cuda-.sinh!-d: Private ordinary functions
Function, cuda-.sinh!-s: Private ordinary functions
Function, cuda-.sqrt!: Private ordinary functions
Function, cuda-.sqrt!-d: Private ordinary functions
Function, cuda-.sqrt!-s: Private ordinary functions
Function, cuda-.square!: Private ordinary functions
Function, cuda-.square!-d: Private ordinary functions
Function, cuda-.square!-s: Private ordinary functions
Function, cuda-.tan!: Private ordinary functions
Function, cuda-.tan!-d: Private ordinary functions
Function, cuda-.tan!-s: Private ordinary functions
Function, cuda-.tanh!: Private ordinary functions
Function, cuda-.tanh!-d: Private ordinary functions
Function, cuda-.tanh!-s: Private ordinary functions
Function, cuda-add-sign!: Private ordinary functions
Function, cuda-add-sign!-d: Private ordinary functions
Function, cuda-add-sign!-s: Private ordinary functions
Function, cuda-available-p: Public ordinary functions
Function, cuda-code: Private ordinary functions
Function, cuda-convolve-2d: Private ordinary functions
Function, cuda-convolve-2d-d: Private ordinary functions
Function, cuda-convolve-2d-s: Private ordinary functions
Function, cuda-derive-convolve-2d: Private ordinary functions
Function, cuda-derive-convolve-2d-d: Private ordinary functions
Function, cuda-derive-convolve-2d-s: Private ordinary functions
Function, cuda-derive-max-pool-2d: Private ordinary functions
Function, cuda-derive-max-pool-2d-d: Private ordinary functions
Function, cuda-derive-max-pool-2d-s: Private ordinary functions
Function, cuda-fill!: Private ordinary functions
Function, cuda-fill!-2: Private ordinary functions
Function, cuda-fill!-d: Private ordinary functions
Function, cuda-fill!-s: Private ordinary functions
Function, cuda-geem!: Private ordinary functions
Function, cuda-geem!-d: Private ordinary functions
Function, cuda-geem!-s: Private ordinary functions
Function, cuda-geerv!: Private ordinary functions
Function, cuda-geerv!-d: Private ordinary functions
Function, cuda-geerv!-s: Private ordinary functions
Function, cuda-kernel-name: Private ordinary functions
Function, cuda-less-than!: Private ordinary functions
Function, cuda-less-than!-d: Private ordinary functions
Function, cuda-less-than!-s: Private ordinary functions
Function, cuda-max-pool-2d: Private ordinary functions
Function, cuda-max-pool-2d-d: Private ordinary functions
Function, cuda-max-pool-2d-s: Private ordinary functions
Function, cuda-room: Public ordinary functions
Function, cuda-scale-columns!: Private ordinary functions
Function, cuda-scale-columns!-d: Private ordinary functions
Function, cuda-scale-columns!-s: Private ordinary functions
Function, cuda-scale-rows!: Private ordinary functions
Function, cuda-scale-rows!-d: Private ordinary functions
Function, cuda-scale-rows!-s: Private ordinary functions
Function, cuda-setf-mref: Private ordinary functions
Function, cuda-setf-mref-d: Private ordinary functions
Function, cuda-setf-mref-s: Private ordinary functions
Function, curand-init-xorwow-simple: Private ordinary functions
Function, curand-normal-xorwow: Private ordinary functions
Function, curand-normal-xorwow-d: Private ordinary functions
Function, curand-normal-xorwow-s: Private ordinary functions
Function, curand-uniform-xorwow: Private ordinary functions
Function, curand-uniform-xorwow-d: Private ordinary functions
Function, curand-uniform-xorwow-s: Private ordinary functions
Function, deregister-cube-facet: Private ordinary functions
Function, derive-convolve!: Public ordinary functions
Function, derive-max-pool!: Public ordinary functions
Function, destroy-cube: Public ordinary functions
Function, destroy-facet: Public ordinary functions
Function, dimensions-total-size: Private ordinary functions
Function, displace: Public ordinary functions
Function, displace!: Public ordinary functions
Function, displacement-bytes: Private ordinary functions
Function, ensure-cube-finalized: Private ordinary functions
Function, ensure-facet: Private ordinary functions
Function, ensure-pointer-param: Private ordinary functions
Function, expand-with-facets: Private ordinary functions
Function, facet-barred-p: Private ordinary functions
Function, facet-barrier-cube-type: Private ordinary functions
Function, facet-barrier-cubes-to-barred-facets: Private ordinary functions
Function, facet-barrier-destroys: Private ordinary functions
Function, facet-barrier-ensures: Private ordinary functions
Function, facet-barrier-p: Private ordinary functions
Function, facet-description: Public ordinary functions
Function, facet-direction: Public ordinary functions
Function, facet-n-watchers: Public ordinary functions
Function, facet-name: Public ordinary functions
Function, facet-p: Private ordinary functions
Function, facet-references: Private ordinary functions
Function, facet-up-to-date-p: Public ordinary functions
Function, facet-value: Public ordinary functions
Function, facet-vars: Private ordinary functions
Function, facet-watcher-threads: Public ordinary functions
Function, facets: Public ordinary functions
Function, fake-writer: Private ordinary functions
Function, fill!: Public ordinary functions
Function, find-facet: Public ordinary functions
Function, find-up-to-date-facet: Private ordinary functions
Function, finish-syncing-cuda-facets: Private ordinary functions
Function, foreign-room: Public ordinary functions
Function, free-cuda-vector: Private ordinary functions
Function, free-some-reusables: Private ordinary functions
Function, free-static-vector: Private ordinary functions
Function, gaussian-random!: Public ordinary functions
Function, gaussian-random-1: Private ordinary functions
Function, geem!: Public ordinary functions
Function, geerv!: Public ordinary functions
Function, gemm!: Public ordinary functions
Function, get-permission-to-destroy: Private ordinary functions
Function, has-watchers-p: Private ordinary functions
Function, has-writers-p: Private ordinary functions
Function, incf-references: Private ordinary functions
Function, invert: Public ordinary functions
Function, lisp-.+!: Private ordinary functions
Function, lisp-.+!-d: Private ordinary functions
Function, lisp-.+!-s: Private ordinary functions
Function, lisp-.cos!: Private ordinary functions
Function, lisp-.cos!-d: Private ordinary functions
Function, lisp-.cos!-s: Private ordinary functions
Function, lisp-.cosh!: Private ordinary functions
Function, lisp-.cosh!-d: Private ordinary functions
Function, lisp-.cosh!-s: Private ordinary functions
Function, lisp-.exp!: Private ordinary functions
Function, lisp-.exp!-d: Private ordinary functions
Function, lisp-.exp!-s: Private ordinary functions
Function, lisp-.expt!: Private ordinary functions
Function, lisp-.expt!-d: Private ordinary functions
Function, lisp-.expt!-s: Private ordinary functions
Function, lisp-.inv!: Private ordinary functions
Function, lisp-.inv!-d: Private ordinary functions
Function, lisp-.inv!-s: Private ordinary functions
Function, lisp-.log!: Private ordinary functions
Function, lisp-.log!-d: Private ordinary functions
Function, lisp-.log!-s: Private ordinary functions
Function, lisp-.logistic!: Private ordinary functions
Function, lisp-.logistic!-d: Private ordinary functions
Function, lisp-.logistic!-s: Private ordinary functions
Function, lisp-.max!: Private ordinary functions
Function, lisp-.max!-d: Private ordinary functions
Function, lisp-.max!-s: Private ordinary functions
Function, lisp-.min!: Private ordinary functions
Function, lisp-.min!-d: Private ordinary functions
Function, lisp-.min!-s: Private ordinary functions
Function, lisp-.sin!: Private ordinary functions
Function, lisp-.sin!-d: Private ordinary functions
Function, lisp-.sin!-s: Private ordinary functions
Function, lisp-.sinh!: Private ordinary functions
Function, lisp-.sinh!-d: Private ordinary functions
Function, lisp-.sinh!-s: Private ordinary functions
Function, lisp-.sqrt!: Private ordinary functions
Function, lisp-.sqrt!-d: Private ordinary functions
Function, lisp-.sqrt!-s: Private ordinary functions
Function, lisp-.square!: Private ordinary functions
Function, lisp-.square!-d: Private ordinary functions
Function, lisp-.square!-s: Private ordinary functions
Function, lisp-.tan!: Private ordinary functions
Function, lisp-.tan!-d: Private ordinary functions
Function, lisp-.tan!-s: Private ordinary functions
Function, lisp-.tanh!: Private ordinary functions
Function, lisp-.tanh!-d: Private ordinary functions
Function, lisp-.tanh!-s: Private ordinary functions
Function, lisp->ctype: Private ordinary functions
Function, lisp-add-sign!: Private ordinary functions
Function, lisp-add-sign!-d: Private ordinary functions
Function, lisp-add-sign!-s: Private ordinary functions
Function, lisp-code: Private ordinary functions
Function, lisp-convolve-2d: Private ordinary functions
Function, lisp-convolve-2d-d: Private ordinary functions
Function, lisp-convolve-2d-s: Private ordinary functions
Function, lisp-derive-convolve-2d: Private ordinary functions
Function, lisp-derive-convolve-2d-d: Private ordinary functions
Function, lisp-derive-convolve-2d-s: Private ordinary functions
Function, lisp-derive-max-pool-2d: Private ordinary functions
Function, lisp-derive-max-pool-2d-d: Private ordinary functions
Function, lisp-derive-max-pool-2d-s: Private ordinary functions
Function, lisp-geem!: Private ordinary functions
Function, lisp-geem!-d: Private ordinary functions
Function, lisp-geem!-s: Private ordinary functions
Function, lisp-geerv!: Private ordinary functions
Function, lisp-geerv!-d: Private ordinary functions
Function, lisp-geerv!-s: Private ordinary functions
Function, lisp-kernel-name: Private ordinary functions
Function, lisp-less-than!: Private ordinary functions
Function, lisp-less-than!-d: Private ordinary functions
Function, lisp-less-than!-s: Private ordinary functions
Function, lisp-max-pool-2d: Private ordinary functions
Function, lisp-max-pool-2d-d: Private ordinary functions
Function, lisp-max-pool-2d-s: Private ordinary functions
Function, lisp-scale-columns!: Private ordinary functions
Function, lisp-scale-columns!-d: Private ordinary functions
Function, lisp-scale-columns!-s: Private ordinary functions
Function, lisp-scale-rows!: Private ordinary functions
Function, lisp-scale-rows!-d: Private ordinary functions
Function, lisp-scale-rows!-s: Private ordinary functions
Function, lisp-uniform-random: Private ordinary functions
Function, lisp-uniform-random-d: Private ordinary functions
Function, lisp-uniform-random-s: Private ordinary functions
Function, list-holder-list: Private ordinary functions
Function, list-holder-p: Private ordinary functions
Function, logdet: Public ordinary functions
Function, m*: Public ordinary functions
Function, m+: Public ordinary functions
Function, m-: Public ordinary functions
Function, m=: Public ordinary functions
Function, make-array-facet: Private ordinary functions
Function, make-facet: Private ordinary functions
Function, make-facet-barrier: Private ordinary functions
Function, make-list-holder: Private ordinary functions
Function, make-mat: Public ordinary functions
Function, make-references: Private ordinary functions
Function, make-xorwow-state/simple: Private ordinary functions
Function, map-concat: Public ordinary functions
Function, map-displacements: Public ordinary functions
Function, map-mats-into: Public ordinary functions
Function, map-tree: Private ordinary functions
Function, mat-as-scalar: Public ordinary functions
Function, mat-dimension: Public ordinary functions
Function, mat-facet-to-char: Private ordinary functions
Function, mat-param-p: Private ordinary functions
Function, mat-room: Public ordinary functions
Function, mat-row-major-index: Public ordinary functions
Function, mat-to-array: Public ordinary functions
Function, max-pool!: Public ordinary functions
Function, maybe-rewire-to: Private ordinary functions
Function, maybe-unregister-pointers: Private ordinary functions
Function, memcpy: Private ordinary functions
Function, mm*: Public ordinary functions
Function, mref: Public ordinary functions
Function, mv-gaussian-random: Public ordinary functions
Function, non-mat-output-param-p: Private ordinary functions
Function, note-allocation: Private ordinary functions
Function, nrm2: Public ordinary functions
Function, orthogonal-random!: Public ordinary functions
Function, param-direction: Private ordinary functions
Function, param-name: Private ordinary functions
Function, param-to-cuda: Private ordinary functions
Function, param-type: Private ordinary functions
Function, params-to-type-declaration