New externals based vector and matrix libraries #908
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds new external-based libraries for matrices and vectors. It also refactors and extends the external array library.
arr-ext.mc
This library implements (Ocaml native) and (Bigarray) 1D arrays. The Bigarray-based, or
ExtArrarrays as they are called, can hold either double or single precision floats.cblas-ext.mc
This library implements a (incomplete) high-level CBLAS interface based on
ExtArrarrays. It will pick the right implementation based on the kind of theExtArrarray (single or double precision right now).The CBLAS routines are flexible and take many arguments. Therefore I added a record with default arguments for convenience. They are named the same as the function but suffixed with
Arg. For example, you call the CBLAS routinegemmthat performs the computationy := alpha*A*x + beta*yas:where we change the default value of
beta = 0.0to2.0.vec-ext.mc
Implements
ExtArrarrays as vectors. Currently, it only implements the operations necessary to define a vector space (addition and scalar multiplication). The implementation usescblas-ext.mc.mat-ext.mc
Implements matrices based on
ExtArrarrays. It implements operations over matrices using a combination ofcblas-ext.mcand external operations implemented inOwl. All but one operation (matrix exponential) can be used in place or in a referential transparent manner, where the latter performs a copy/data allocation.Updated Microbenchmarks
I updated the Microbenchmarks and added benchmarks for
mat-ext.mc. Some relevant results are as follows on my machine (matrix multiplication with matrices of size 100x100):The benchmark
mulcomparesmatMulfrommat-ext.mcwithOwl.Mat.( *@ )(matrix multiplication). The benchmarkmul_naivecompares naive matrix multiplication in a triple for-loop between matrices frommat-ext.mcandBigarray.Array2arrays.For comparison, these are the times for naive matrix multiplication using Bigarray-based tensors:
and native OCaml arrays