(all-distributions)
(all-rngs)
(axpy mult lhs rhs)
Perform a*x+y where a is a constant and x and y native buffers matching in datatype
and length. At this time only :float32
and :float64
datatypes are supported.
Meant to be used within a stack resource context. See docs for sub
.
Perform a*x+y where a is a constant and x and y native buffers matching in datatype and length. At this time only `:float32` and `:float64` datatypes are supported. Meant to be used within a stack resource context. See docs for [[sub]].
(axpy! mult lhs rhs)
Mutable axpy
placing results in rhs.
Mutable [[axpy]] placing results in rhs.
(correlate1d data kernel)
(correlate1d data kernel options)
Drop in replacement for dtype-next's convolve/correlate1d pathway that is significantly faster for large input data and kernel values.
Drop in replacement for dtype-next's convolve/correlate1d pathway that is significantly faster for large input data and kernel values.
(correlation1d-fn dtype
nsignal
nwin
&
{:keys [mode algorithm] :or {mode :full algorithm :auto}})
Create a correlation function that returns data the same length as the input. This function is not reentrant, do not call simultaneously from multiple threads.
dtype
- One of :float32
:float64
.nsignal
- Length of input signal.Options:
:mode
- One of :full
:same
:algorithm
- One of :fft
:naive
:auto
.Create a correlation function that returns data the same length as the input. This function is *not* reentrant, do not call simultaneously from multiple threads. * `dtype` - One of `:float32` `:float64`. * `nsignal` - Length of input signal. * `nwin - Number of elements in the kernel. Options: - `:mode` - One of `:full` `:same` - `:algorithm` - One of `:fft` `:naive` `:auto`.
(fft-forward data)
(fft-forward data options)
Compute the forward fft. Returns a dtype-next array buffer. For options see fft-forward-fn
.
It is a bit faster to use fft-forward-fn and then use the returned function as this initializes
an fft context only once and reuses it.
Compute the forward fft. Returns a dtype-next array buffer. For options see [[fft-forward-fn]]. It is a bit faster to use fft-forward-fn and then use the returned function as this initializes an fft context only once and reuses it.
(fft-forward-fn dtype domain len)
Create a function to process forward fft. Returned function takes one arg, input and returns a pre-allocated output after each invocation. Input length must match len. If domain is complex, input length must be double len.
Complex data is stored packed as if in a struct - r1,i1,r2,i2
dtype
- either :float32
or :float64
.domain
- either :real
or :complex
.Example:
user> (require '[cnuernber.mkl :as mkl])
Execution error (FileNotFoundException) at user/eval5625 (REPL:43).
Could not locate cnuernber/mkl__init.class, cnuernber/mkl.clj or cnuernber/mkl.cljc on classpath.
user> (require '[mkl.api :as mkl])
nil
user> (mkl/initialize!)
#object[com.sun.proxy.$Proxy3 0x56dd4be7 "Proxy interface to Native Library <libmkl_rt.so@139886755541424>"]
user> (def data (take 100 (cycle [1 2 3 4 5])))
#'user/data
user> (def fft-fn (mkl/fft-forward-fn :float32 :real 100))
#'user/fft-fnJul 21, 2023 3:27:56 PM clojure.tools.logging$eval5978$fn__5981 invoke
INFO: Reference thread starting
user> (def res (fft-fn data))
#'user/res
user> res
#native-buffer@0x00007F39ED2F22D0<float32>[200]
[300.0, 0.000, 0.000, 0.000, 3.104E-07, -3.306E-07, 0.000, 0.000, 1.885E-07, 3.595E-08, 0.000, 0.000, 1.808E-07, -9.941E-08, 0.000, 0.000, -1.462E-07, 1.847E-08, 0.000, 0.000...]
Create a function to process forward fft. Returned function takes one arg, input and returns a pre-allocated output after each invocation. Input length must match len. If domain is complex, input length must be double len. Complex data is stored packed as if in a struct - r1,i1,r2,i2 * `dtype` - either `:float32` or `:float64`. * `domain` - either `:real` or `:complex`. Example: ```clojure user> (require '[cnuernber.mkl :as mkl]) Execution error (FileNotFoundException) at user/eval5625 (REPL:43). Could not locate cnuernber/mkl__init.class, cnuernber/mkl.clj or cnuernber/mkl.cljc on classpath. user> (require '[mkl.api :as mkl]) nil user> (mkl/initialize!) #object[com.sun.proxy.$Proxy3 0x56dd4be7 "Proxy interface to Native Library <libmkl_rt.so@139886755541424>"] user> (def data (take 100 (cycle [1 2 3 4 5]))) #'user/data user> (def fft-fn (mkl/fft-forward-fn :float32 :real 100)) #'user/fft-fnJul 21, 2023 3:27:56 PM clojure.tools.logging$eval5978$fn__5981 invoke INFO: Reference thread starting user> (def res (fft-fn data)) #'user/res user> res #native-buffer@0x00007F39ED2F22D0<float32>[200] [300.0, 0.000, 0.000, 0.000, 3.104E-07, -3.306E-07, 0.000, 0.000, 1.885E-07, 3.595E-08, 0.000, 0.000, 1.808E-07, -9.941E-08, 0.000, 0.000, -1.462E-07, 1.847E-08, 0.000, 0.000...] ```
(initialize!)
(initialize! options)
Initialize - find the mkl_rt
shared library and load it. Uses normal OS pathways to
find the library in addition to the java_library_path
system variable.
Initialize - find the `mkl_rt` shared library and load it. Uses normal OS pathways to find the library in addition to the `java_library_path` system variable.
(real->complex real)
Convert a real buffer to an interleaved real-complex buffer - not an efficient operation.
Convert a real buffer to an interleaved real-complex buffer - not an efficient operation.
(rng-stream n
{:keys [seed rng dist datatype]
:or {rng :sfmt19937 dist :uniform datatype :float64}
:as options})
Return a function that when called returns a new batch of random numbers. Returns the same native buffer on every call. The values of (all-distributions) state the name of the optional arguments and their order.
Options:
Note that the distribution arguments must be provided in the optional arguments map. See the documentation for various mkl distribution functions for their definitions.
:datatype
- defaults to :float64.:seed
- unsigned integer - defaults to unchecked integer cast of system/nanoTime if not provided.:rng
- one of (all-rngs) - defaults to :sfmt19937:dist
- one of the keys of (all-distributions). Defaults to :uniform.Return a function that when called returns a new batch of random numbers. Returns the same native buffer on every call. The values of (all-distributions) state the name of the optional arguments and their order. Options: Note that the distribution arguments *must* be provided in the optional arguments map. See the documentation for various [mkl distribution functions](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-0/distribution-generators.html) for their definitions. * `:datatype` - defaults to :float64. * `:seed` - unsigned integer - defaults to unchecked integer cast of system/nanoTime if not provided. * `:rng` - one of (all-rngs) - defaults to :sfmt19937 * `:dist` - one of the keys of (all-distributions). Defaults to :uniform.
(sub a b)
Subtract two native buffers. No care has been taken to ensure buffers are native or to convert them.
Meant to be used within a stack resource context.
mkl.api> (def fdata (dt/make-container :native-heap :float32 (hamf/range 100000)))
#'mkl.api/fdata
mkl.api> (crit/quick-bench (resource/stack-resource-context
(sub (hamf/subvec fdata 0 (dec (dt/ecount fdata)))
(hamf/subvec fdata 1))))
Evaluation count : 27468 in 6 samples of 4578 calls.
Execution time mean : 21.781143 µs
Execution time std-deviation : 82.384894 ns
Execution time lower quantile : 21.689956 µs ( 2.5%)
Execution time upper quantile : 21.872100 µs (97.5%)
Overhead used : 1.998471 ns
Subtract two native buffers. No care has been taken to ensure buffers are native or to convert them. Meant to be used within a stack resource context. ```clojure mkl.api> (def fdata (dt/make-container :native-heap :float32 (hamf/range 100000))) #'mkl.api/fdata mkl.api> (crit/quick-bench (resource/stack-resource-context (sub (hamf/subvec fdata 0 (dec (dt/ecount fdata))) (hamf/subvec fdata 1)))) Evaluation count : 27468 in 6 samples of 4578 calls. Execution time mean : 21.781143 µs Execution time std-deviation : 82.384894 ns Execution time lower quantile : 21.689956 µs ( 2.5%) Execution time upper quantile : 21.872100 µs (97.5%) Overhead used : 1.998471 ns ```
(sub! a b ret)
Subtract two native buffers placing result into ret
. See docs for sub
.
Subtract two native buffers placing result into `ret`. See docs for [[sub]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close