CrossClj

0.9.22 docs

SourceDocs



RECENT
    VARS
    *current-compute-device*
    ->DeviceResources
    allocate-device-buffer
    allocate-host-buffer
    allocate-rand-buffer
    create-stream
    current-device
    default-device
    device-buffer->host-array
    dtype-cast
    host-array->device-buffer
    indexed-copy
    map->DeviceResources
    memory-info
    PBuffer
    PDevice
    PDeviceProvider
    PDriver
    PDriverProvider
    PEvent
    PStream
    PStreamProvider
    sub-buffer
    sync-stream
    sync-streams
    unsafe-with-compute-device
    with-compute-device

    « Index of all namespaces of this project

    Base set of protocols required to move information from the host to the device as well as
    enable some form of computation on a given device.  There is a cpu implementation provided for
    reference.
    
    Three basic datatypes are defined:
     * Driver: Enables enumeration of devices and creation of host buffers.
     * Device: Creates streams and device buffers.
     * Stream: Stream of execution occuring on the device.
     * Event: A synchronization primitive emitted in a stream to notify other
              streams that might be blocking.
    (->DeviceResources device res-ctx)
    Positional factory function for class cortex.compute.driver.DeviceResources.
    
    (allocate-device-buffer elem-count elem-type & {:keys [device]})
    Allocate a device buffer.  This is the generic unit of data storage used for computation.
    
    (allocate-host-buffer driver elem-count elem-type & {:keys [usage-type], :or {usage-type :one-time}})
    (allocate-rand-buffer elem-count & {:keys [device]})
    Allocate a buffer used for rands.  Random number generation in general needs a
    divisible-by-2 element count and a floating point buffer (cuda cuRand limitation)
    (create-stream & {:keys [device]})
    Create a stream of execution.  Streams are indepenent threads of execution.  They can be
    synchronized with each other and the main thread using events.
    (default-device driver)
    (device-buffer->host-array stream device-buffer)
    Synchronously transfer a device buffer to a host array
    
    (host-array->device-buffer stream upload-ary & {:keys [datatype], :or {datatype (dtype/get-datatype upload-ary)}})
    Synchronously make a device buffer with these elements in it.
    
    (indexed-copy stream src src-indexes dest dest-indexes n-elems-per-idx & {:keys [src-stride dest-stride], :or {src-stride n-elems-per-idx, dest-stride n-elems-per-idx}})
    (map->DeviceResources m__7585__auto__)
    Factory function for class cortex.compute.driver.DeviceResources, taking a map of keywords to field values.
    
    (memory-info & {:keys [device]})
    Get a map of {:free <long> :total <long>} describing the free and total memory in bytes.
    
    protocol
    Interface to create sub-buffers out of larger contiguous buffers.
    
    (alias? lhs-dev-buffer rhs-dev-buffer)
    Do these two buffers alias each other?  Meaning do they start at the same address
    and overlap completely?
    (partially-alias? lhs-dev-buffer rhs-dev-buffer)
    Do these two buffers partially alias each other?  Does some sub-range of their
    data overlap?
    (sub-buffer-impl buffer offset length)
    Create a sub buffer that shares the backing store with the main buffer.
    
    protocol
    (allocate-device-buffer-impl device elem-count elem-type)
    Allocate a device buffer.  This is the generic unit of data storage used for computation.
    
    (allocate-rand-buffer-impl device elem-count)
    Allocate a buffer used for rands.  Random number generation in general needs a divisible-by-2 element count
    and a floating point buffer (cuda cuRand limitation)
    (create-stream-impl device)
    Create a stream of execution.  Streams are indepenent threads of execution.  They can be synchronized
    with each other and the main thread using events.
    (memory-info-impl device)
    Get a map of {:free <long> :total <long>} describing the free and total memory in bytes.
    
    protocol
    Get a device from an object.
    
    (get-device impl)
    protocol
    A driver is a generic compute abstraction.  Could be a group of threads, could be a machine
    on a network or it could be a CUDA or OpenCL driver.  A stream is a stream of execution
    (analogous to a thread) where subsequent calls are serialized.  All buffers implement a few of
    the datatype interfaces, at least get-datatype and ecount.  Host buffers are expected to
    implement enough of the datatype interfaces to allow a copy operation from generic datatypes
    into them.  This means at least PAccess.
    (allocate-host-buffer-impl driver elem-count elem-type options)
    Allocate a host buffer.  Transfer from host to device requires data first copied into a
    host buffer and then uploaded to a device buffer.
    options:
    {:usage-type #{:one-time :reusable}
    usage-type: Hint to allow implementations to allocate different types of host buffers each
    optimized for the desired use case.  Default is one-time.
    (get-devices driver)
    Get a list of devices accessible to the system.
    
    protocol
    Get a driver from an object
    
    (get-driver impl)
    protocol
    (wait-for-event event)
    Wait on the host until an event is triggered.
    
    protocol
    Basic functionality expected of streams.  Streams are an abstraction of a stream of execution
    and can be synchonized with the host or with each other using events.
    (copy-device->device stream dev-a dev-a-off dev-b dev-b-off elem-count)
    (copy-device->host stream device-buffer device-offset host-buffer host-offset elem-count)
    (copy-host->device stream host-buffer host-offset device-buffer device-offset elem-count)
    (create-event stream)
    Create an event for synchronization.  The event is triggered when the stream
    executes to the event.
    (indexed-copy-impl stream dev-src dev-src-indexes src-stride dev-dst dev-dst-indexes dst-stride n-elems-per-idx)
    Perform an indexed copy operation where dev-a, dev-b are of same datatype (double,float)
    while dev-a-indexes, dev-b-indexes are integer buffers.  n-elems-per-idx allows you to copy
    vectors of data.
    (memset stream device-buffer device-offset elem-val elem-count)
    (sync-event stream event)
    Have this stream pause until a given event is triggered.
    
    protocol
    Get a stream from an object
    
    (get-stream impl)
    (sub-buffer device-buffer offset length)
    Create a view of a buffer which shares the backing store
    with the original.  Offset must be >= 0.
    (sync-stream stream)
    (sync-streams event-stream wait-stream)
    Force wait-stream to wait for event-stream
    
    macro
    (unsafe-with-compute-device device & body)
    Unsafe because resources allocated within this block will not necessarily get released on the
    same device.  Building block for building safe device abstractions.
    macro
    (with-compute-device device & body)
    Returns a tuple of retval and tracked device resource buffer