Git Product home page Git Product logo

lacaml's People

Contributors

chris00 avatar cshardin avatar florenthoareau avatar kit-ty-kate avatar kkirstein avatar mmottl avatar mseri avatar rgrinberg avatar rleonid avatar scemama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lacaml's Issues

Get rid of num_type?

When using Merlin, types such as Lacaml_float64.num_type pop up instead of float which make signatures harder to read. Since we already perform substitutions, how about to remove it (the type num_type would remain)? This would be done in the "public" .mli files only.

build script does not use pkg-config to locate libraries

Under NixOS, it would be possible to install lacaml using opam using:

nix run nixpkgs.blas nixpkgs.liblapack
% opam install lacaml

which is a way to install opam packages with c stubs that works most often than not.
This rely on the package to use pkg-config to locate its dependencies though.
lacaml does not, instead using a specific program to locate dependencies that rely on some environment variables.
As a result, the user experience is harder than required. For the record, this is how I eventually managed to install lacaml on NixOs:

/usr/bin/env LACAML_LIBS=-L(nix eval --raw nixpkgs.liblapack)"/lib -L"(nix eval --raw nixpkgs.blas)/lib" -lblas -llapack" opam install lacaml

(notice that's fish shell not bash)

Could lacaml consider using pkg-config instead, which might help with other cases beside NixOs?

OPAM with MKL

Hi,
I have succeeded to use lacaml with the Intel MKL library on my desktop PC by doing :

export  LACAML_LIBS="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_rt -lpthread -lm -ldl"
opam install lacaml

but when I tried on a HPC server, it did not work because on that particular machine there is no libblas.so and liblapack.so. Only the MKL is available. So the installation of conf-blas and conf-lapack fails.

I am not familiar with opam configuration files, so I can't fix the conf-* files myself and submit a pull request, but I could force the installation by doing the following symbolic links in a directory which is in my LIBRARY_PATH:

ln -s $MKLROOT/lib/intel64/libmkl_rt.so libblas.so
ln -s $MKLROOT/lib/intel64/libmkl_rt.so liblapack.so

cheers,

Anthony

operations on Mat.empty

as a corner case, i happened on gemm Mat.empty Mat.empty which i expected to yield Mat.empty. however, instead this resulted in an exception from blas. just wanted to point this out in case it is not intentional. one could of course test explicitly for empty matrices. i guess it's a tradeoff between convenience and potentially some overhead if Mat.empty were handled by all functions where it makes sense.

exception from fortran can only be caught at top level

i'm seeing strange behavior like below. i hope the structure is clear even though i have a ton of undefined symbols here.

let find_min x =
  let minim = nm_min teste ~x ~step_size:stepinit in
  try
    let success_steps = ref 0 in
    for i = 1 to maxit do
      Min.iterate minim;
      if Min.test_size minim 0.01
      then incr success_steps
      else success_steps := 0;
      if !success_steps >= succ_steps then raise @@ Converged i;
    done;
    minim
  with
  | Converged i ->
    (Format.printf "tolerance reached in step %d\n@." i;
    minim)
  | _ -> minim

in this function i try to catch all exceptions and always give back the current mutable minimizer object minim. sometimes the function to be minimized teste raises Failure("Lacaml.D.potrf: leading minor of order 66 is not positive definite") - and the catch-all case does not catch it!?

only when wrapping find_min on the top level i can catch it with try find_min x with _ -> default_minim

is it possible that lacaml can somehow smuggle this exception through? or am i doing something weird?

documentation: functions which modify their input

working with lapack is an exercise in general distrust. i just got bit again by gesv a b modifying a. for a seasoned fortran programmer this may be obvious, but it's in stark contrast to the ocaml paradigm of mostly immutable data. so from this point of view it's really more difficult to program in lacaml than in straight fortran: one is not generally in the mindset of pervasive mutability.

anyway, the question is, what can lacaml do to help? for functions with a unit return value i am primed to expect that they modify something. for functions which give back a matrix, such as gesv i was not expecting it e.g. gemm leaves its input intact afaik.

would it be sensible to state in the documentation, at least for functions with a nontrivial return value, what they may modify, if anything?

GGLSE?

Hi Markus,

Do you have any plans for adding GGLSE? I see there is a mention in impl_SDCZ_c.c

PS. Thanks for Lacaml, it's really great. I've been using it extensively.

gemv with empty vector

this is similar to the last issue but i think it may be an actual bug so opened a new issue:

let a = Mat.create 2 0
let v = Vec.create 0
let w = gemv a v
let d = Vec.dim w

here, i get 2, and w is a vector with uninitialized entries. this seems wrong?

i would argue that actually a vector 0. 0. would be the mathematically correct result. each entry of the result vector w is the scalar product of the corresponding row vector of the input matrix aand the input vector v. since these have length 0, the scalar product is an empty sum and should be 0.

alternatively one may argue that empty inputs are pathological. then it would make sense to raise an exception, similar to what gemv already does.

right now, it's not ideal that a nonsensical result is actually returned, in my opinion. if this is what lapack does, maybe one should protect the user from lapack here?

(edit: nonsense removal)

Install fails on FreeBSD 11.3

Hello,

I tried via opam using the public repositories. It can't find gcc & lapack:

opam install lacaml
The following actions will be performed:

  • install conf-lapack 1 [required by lacaml]
  • install lacaml 11.0.6
    ===== 2 to install =====
    Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[lacaml.11.0.6] downloaded from cache at https://opam.ocaml.org/cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of conf-lapack failed at "/bin/sh -exc ${CC:-gcc} $CFLAGS test.c ${LACAML_LIBS:--llapack} $LDFLAGS".

#=== ERROR while compiling conf-lapack.1 ======================================#

context 2.0.6 | freebsd/x86_64 | ocaml-base-compiler.4.10.0 | https://opam.ocaml.org#1d8fdb21

path /usr/home/rmason/.opam/4.10.0/.opam-switch/build/conf-lapack.1

command /bin/sh -exc ${CC:-gcc} $CFLAGS test.c ${LACAML_LIBS:--llapack} $LDFLAGS

exit-code 1

env-file /usr/home/rmason/.opam/log/conf-lapack-70142-d0f245.env

output-file /usr/home/rmason/.opam/log/conf-lapack-70142-d0f245.out

output

[...]

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `chbmv_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `dsyr2_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `zcopy_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `dspr_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `icamax_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `dsymv_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `zhemv_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `ssyrk_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `srotm_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `drot_'

/usr/local/bin/ld: /usr/local/lib/liblapack.so: undefined reference to `ztbmv_'

collect2: error: ld returned 1 exit status

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build conf-lapack 1
+-

  • No changes have been performed

The packages you requested declare the following system dependencies. Please make sure they are installed before retrying:
gcc lapack

I built the git version in the lacaml directory but utop can't find it.
I tried 'opam install .' (https://opam.ocaml.org/doc/Packaging.html) but
it can't find gcc & lapack. Dunno why it needs to given that the package is
already built.

I'm an OCaml novice, so there may be something I'm missing. Meanwhile, back to some other language for LA.

cannot build docs?

trying to upgrade lacaml to 8.0.4 with opam on os x el capitan, ocaml 4.02.3, i get

[ERROR] The compilation of lacaml failed at "ocaml setup.ml -doc".
Processing  1/1: [lacaml: ocamlfind remove]
#=== ERROR while installing lacaml.8.0.4 ======================================#
# opam-version 1.2.2
# os           darwin
# command      ocaml setup.ml -doc
# path         /Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4
# compiler     4.02.3
# exit-code    1
# env-file     /Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/lacaml-95122-6d07ae.env
# stdout-file  /Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/lacaml-95122-6d07ae.out
# stderr-file  /Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/lacaml-95122-6d07ae.err
### stdout ###
# [...]
# an is not a valid exception constructor in "@raise an invalid argument if
#     any arguments are invalid."
# File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 330:
# an is not a valid exception constructor in "@raise an invalid argument if
#     any arguments are invalid."
# File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 335:
# an is not a valid exception constructor in "@raise an invalid argument if
#     any arguments are invalid."
#32 error(s) encountered
# Command exited with code 1.
### stderr ###
# E: Failure("Command ''/Users/nbecker/.opam/4.02.3/bin/ocamlbuild' API.docdir/index.html -tag debug' terminated with error code 10")

the full output file is

/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml.odoc -package bigarray -package bytes -I lib lib/lacaml.mli
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml.odoc -package bigarray -package bytes -I lib lib/lacaml.mli
Warning: Module or module type Lacaml_utils not found
Warning: Module or module type Lacaml_C not found
Warning: Module or module type Lacaml_Z not found
Warning: Module or module type Lacaml_S not found
Warning: Module or module type Lacaml_D not found
Warning: Module or module type Lacaml_common not found
Warning: Module or module type Lacaml_io not found
Warning: Module or module type Lacaml_utils not found
Warning: Module or module type Lacaml_C not found
Warning: Module or module type Lacaml_Z not found
Warning: Module or module type Lacaml_S not found
Warning: Module or module type Lacaml_D not found
Warning: Module or module type Lacaml_common not found
Warning: Module or module type Lacaml_io not found
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_common.odoc -package bigarray -package bytes -I lib lib/lacaml_common.mli
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_io.odoc -package bigarray -package bytes -I lib lib/lacaml_io.mli
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_S.odoc -package bigarray -package bytes -I lib lib/lacaml_S.mli
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_S.odoc -package bigarray -package bytes -I lib lib/lacaml_S.mli
Warning: Element S not found
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_D.odoc -package bigarray -package bytes -I lib lib/lacaml_D.mli
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_D.odoc -package bigarray -package bytes -I lib lib/lacaml_D.mli
Warning: Element D not found
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_C.odoc -package bigarray -package bytes -I lib lib/lacaml_C.mli
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_C.odoc -package bigarray -package bytes -I lib lib/lacaml_C.mli
Warning: Element C not found
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_Z.odoc -package bigarray -package bytes -I lib lib/lacaml_Z.mli
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_Z.odoc -package bigarray -package bytes -I lib lib/lacaml_Z.mli
Warning: Element Z not found
/Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_utils.odoc -package bigarray -package bytes -I lib lib/lacaml_utils.ml
+ /Users/nbecker/.opam/4.02.3/bin/ocamlfind ocamldoc -dump lib/lacaml_utils.odoc -package bigarray -package bytes -I lib lib/lacaml_utils.ml
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 128:
an is not a valid exception constructor in "@raise an invalid argument that integer
    variable [var] with name [name] at location [loc] is lower than [0]."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 132:
an is not a valid exception constructor in "@raise an invalid
    argument in that case."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 146:
an is not a valid exception constructor in "@raise an invalid
    argument that dimension [dim] of a vector with name [vec_name] exceeds
    the minimum [min_dim] at location [loc]."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 150:
an is not a valid exception constructor in "@raise an invalid argument otherwise."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 154:
an is not a valid exception constructor in "@raise an invalid
    argument that an offset [ofs] named [ofs_name] for a value having [name]
    is invalid (i.e. is outside of [1..max_ofs])."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 157:
an is not a valid exception constructor in "@raise an invalid argument
    that vector offset [ofs] is invalid (i.e. is outside of [1..max_ofs])."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 161:
an is not a valid exception constructor in "@raise an invalid argument in that case."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 165:
an is not a valid exception constructor in "@raise an invalid
    argument in that case."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 184:
an is not a valid exception constructor in "@raise an invalid argument
    that the maximum operation size (e.g. [m] or [n] for vectors and matrices)
    has been exceeded."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 190:
an is not a valid exception constructor in "@raise an invalid argument if any
    arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 196:
an is not a valid exception constructor in "@raise an invalid
    argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 201:
an is not a valid exception constructor in "@raise an invalid
    argument if any of the parameters are illegal."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 212:
an is not a valid exception constructor in "@raise an invalid argument
    that matrix row offset [r] is invalid (i.e. is outside of [1..max_r])."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 215:
an is not a valid exception constructor in "@raise an invalid argument
    that matrix column offset [c] is invalid (i.e. is outside of [1..max_c])."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 219:
an is not a valid exception constructor in "@raise an invalid argument in that case."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 223:
an is not a valid exception constructor in "@raise an invalid argument in that case."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 254:
an is not a valid exception constructor in "@raise an invalid argument if any arguments are
    invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 259:
an is not a valid exception constructor in "@raise an invalid
    argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 265:
an is not a valid exception constructor in "@raise an invalid argument if any
    arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 270:
an is not a valid exception constructor in "@raise an invalid argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 276:
an is not a valid exception constructor in "@raise an invalid argument if any arguments
    are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 282:
an is not a valid exception constructor in "@raise an
    invalid argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 288:
an is not a valid exception constructor in "@raise an invalid argument if any
    arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 293:
an is not a valid exception constructor in "@raise an invalid argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 299:
an is not a valid exception constructor in "@raise an
    invalid argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 305:
an is not a valid exception constructor in "@raise an invalid argument
    if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 310:
an is not a valid exception constructor in "@raise an invalid argument if any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 315:
an is not a valid exception constructor in "@raise an invalid argument if any arguments
    are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 320:
an is not a valid exception constructor in "@raise an invalid argument if any
    arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 325:
an is not a valid exception constructor in "@raise an invalid argument if
    any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 330:
an is not a valid exception constructor in "@raise an invalid argument if
    any arguments are invalid."
File "/Users/nbecker/.opam/4.02.3/build/lacaml.8.0.4/_build/lib/lacaml_utils.ml", line 335:
an is not a valid exception constructor in "@raise an invalid argument if
    any arguments are invalid."
32 error(s) encountered
Command exited with code 1.

toplevel-specific segfault with syevr

Hi Markus,

I noticed the following problem using ocaml 4.13.1 and lacaml 11.0.8:

# #require "lacaml";;
/home/pveber/.opam/4.13.1/lib/ocaml/bigarray.cma: loaded
/home/pveber/.opam/4.13.1/lib/lacaml: added to search path
/home/pveber/.opam/4.13.1/lib/lacaml/lacaml.cma: loaded
# Lacaml.D.syevr @@ Lacaml.D.Mat.of_array [| [| 1. ; 0. |] ; [| 0. ; 1. |] |];;
Erreur de segmentation (core dumped)

The problem shows more generally under bytecode compilation. The function works fine in native mode though. I'm sorry I don't have more to investigate right now, but maybe the issue will be obvious for you ;).

lacaml on Windows

Hi,

has anybody successfully installed lacaml on Windows7 (64bit)?
I'm trying to do so with opam install lacaml and end with missing symbols from the fortran runtime, e.g. _gfortran_concat_string. libgfortran-3.dll is on my path. I have a cygwin environment with a x86_64-w64-mingw32 toolchain (gcc & gfortran). Maybe I have to add some linking options to setup.conf?
The toolchain and opam seem to be setup correctly, as I can successfully install packages like lablgtk.

Thanks in advance for any hints,
Kay-Uwe

P.S: I'm a newbie at ocaml & opam, so please bare with me, if I missed something obvious...

lacaml.7.2.6_build_output.zip

Vec.multiply_const ?

i could not find something like this. would this be a worthwhile addition (analogous to add_const)?

Mat.mul documentation

please consider writing the word 'element-wise' into the documentation. i just lost some time thinking 'product' refers to the matrix produc (which is in fact gemm as i then learned). disclaimer: lapack newbie.

Build fails on ppc64le because -march=native is not understood

I can easily work around this by setting LACAML_CFLAGS before compiling, but it would be nice if it worked out of the box on Power:

+ LACAML_LIBS=-lflexiblas
+ dune build -j8
         gcc src/config/zdot_is_function_stubs.o (exit 1)
(cd _build/default/src/config && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -pthread -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -pthread -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Wall -pedantic -Wextra -Wunused -DEXTERNAL_EXP10 -std=c99 -O3 -march=native -ffast-math -fPIC -DPIC -g -I /usr/lib64/ocaml -o zdot_is_function_stubs.o -c zdot_is_function_stubs.c)
cc1: error: unrecognized command-line option '-march=native'
         gcc src/config/zdot_is_procedure_stubs.o (exit 1)
(cd _build/default/src/config && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -pthread -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -pthread -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Wall -pedantic -Wextra -Wunused -DEXTERNAL_EXP10 -std=c99 -O3 -march=native -ffast-math -fPIC -DPIC -g -I /usr/lib64/ocaml -o zdot_is_procedure_stubs.o -c zdot_is_procedure_stubs.c)
cc1: error: unrecognized command-line option '-march=native'

Creating sub modules for organizing

I sometimes find it a bit overwhelming navigating all of the functions in Lacaml, and wish for a little bit more organization. I'd like to propose a couple of suggestions, they're entirely optional, just to get a discussion started and give some possibilities.

  1. Group the functions in Lacaml_S (and Lacaml_D, Lacaml_C ...) into submodules Blas1, Blas2, Blas3 and Lapack_ar, Lapack_ls, Lapack_svd (... etc, I don't really like the 'simple' and 'expert' driver breakdowns but I'm not certain this would be much better).
  2. In Vec group the Lacaml_float64.vec -> Lacaml_float64.vec functions (exp, exp1m, sin, sqrt ) into a sub module such as Op (for operations) ?
  3. The special matrix functions (hilbert, hankel ...) into a sub module Special .

I understand that to support backward compatibility maybe we'd have to setup some other module not to break existing code.

building with alternative blas

hi, i am troubleshooting on os x and have reason to believe that the Accelerate framework may be part of the problem. i therefore like to build lacaml with openblas instead. i installed openblas with homebrew and get this information:

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openblas/lib
    CPPFLAGS: -I/usr/local/opt/openblas/include

i assume i can change something in the _oasis file around line 86 to use that instead of the Accelerate framework. what exactly would i need to replace?

thanks for any help!

installation with homebrew, openblas, macos 12.6

on a current installation of macos, i was unable to opam install lacaml with the environment i used successfully previously. i suspect the way gfortran is linked on homebrew has changed. the installation fails becaus libquadmath cannot be found by the linker

printing in ocamldebug

is there a way of installing lacaml's vector and matrix printers under ocamldebug?

i looked for .cma or .cmo files in the distribution and found only lacaml.cma and lacaml_top.cma. the Lacaml_io module in particular does not have a bytecode object. i was unable to load lacaml{,_top}.cma in the debugger due to missing function definitions. am i doing it wrong? printing in the toploop works just fine.

corner case: gemm with a 0 dimension

i just came across this corner case in code.

open Lacaml.D
let a = Mat.create 2 2
let b = lacpy ~ac:3 a

this gives a b with shape 2, 0 which seems reasonable. (however ~ac > 3 raises)

let c = gemm a b

in the context it was used it would have been meaningful to get a matrix with shape 2,0 out. instead an exception was raised: second dimension 0. is this something within blas or does lacaml do that? in the latter case, would it make sense to allow multiplications which contain empty dimensions but are consistent dimensionally?

Install of 10.0 on os x without Accelerate

hi, i tried to upgrade to v10 on os x without using accelerate framework, instead using the homebrew-installed openblas. i tried with these environment variables:

LACAML_CFLAGS=-I/usr/local/opt/openblas/include
LACAML_LIBS=-L/usr/local/opt/openblas/lib -lopenblas -llapack

installing lacaml via opam succeeds (on 4.04.2+flambda).
but then

otool -L ~/.opam/4.04.2+flambda/lib/lacaml/lacaml.cmxs

gives

/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/usr/local/opt/openblas/lib/libopenblasp-r0.2.20.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)

and in the jbuilder build log i find invocations like this:

(cd _build/default && /Users/nbecker/.opam/4.04.2+flambda/bin/ocamlmklib.opt -g -o src/lacaml_stubs src/impl_c.o src/utils_c.o src/vec2_S_c.o src/vec2_D_c.o src/vec2_C_c.o src/vec2_Z_c.o src/vec4_S_c.o src/vec4_D_c.o src/vec4_C_c.o src/vec4_Z_c.o src/mat2_S_c.o src/mat2_D_c.o src/mat2_C_c.o src/mat2_Z_c.o src/mat4_S_c.o src/mat4_D_c.o src/mat4_C_c.o src/mat4_Z_c.o src/impl2_S_c.o src/impl2_D_c.o src/impl2_C_c.o src/impl2_Z_c.o src/impl4_S_c.o src/impl4_D_c.o src/impl4_C_c.o src/impl4_Z_c.o -framework Accelerate -L/usr/local/opt/openblas/lib -lopenblas -llapack)

which include the accelerate framework. am i doing something wrong?

gen_blas_kind.exe sigsevs

Installing lacaml on a new computer with a new debian sid install fails. The problem seems to be the helper program gen_blas_kind.exe which fails with a SIGSEV error.

teg@zbox:~$ opam install lacaml
The following actions will be performed:
  â install lacaml 11.0.4

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><>    <><><><><><><>
[lacaml.11.0.4] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><>    <><><><><><>
[ERROR] The compilation of lacaml failed at "/home/teg/.opam/opam-init/hooks/sandbox.sh     build dune build -p lacaml -j 3".

#=== ERROR while compiling lacaml.11.0.4     ======================================#
# context     2.0.3 | linux/x86_32 | ocaml-variants.4.08.0+flambda |     https://opam.ocaml.org#1f561ea0
# path        ~/.opam/4.08.0+flambda/.opam-switch/build/lacaml.11.0.4
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p lacaml -j 3
# exit-code   1
# env-file    ~/.opam/log/lacaml-14543-d8a4ae.env
# output-file ~/.opam/log/lacaml-14543-d8a4ae.out
### output ###
# gen_blas_kind src/config/blas_kind_flags.sexp (got signal SEGV)
# (cd _build/default/src/config && ./gen_blas_kind.exe)



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><>    <><><><><><><>
ââ The following actions failed
â λ build lacaml 11.0.4
ââ
â¶â No changes have been performed


A bt from gdb:
Starting program: /home/teg/.opam/4.08.0+flambda/.opam-  switch/build/lacaml.11.0.4/_build/default/src/config/gen_blas_kind.exe

Program received signal SIGSEGV, Segmentation fault.
0x00000001 in ?? ()
(gdb) bt
#0  0x00000001 in ?? ()
#1  0x0064e9e8 in camlStdlib__map__set_of_closures_1738 ()
#2  0xb725470c in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Trying with the sandbox.sh removed does not make any difference.
Compiler error, stdlib error, something else? What more should be tried?

/Jörgen

testing for Mat.empty

what's the best way to test if a matrix is the empty matrix? is a == Mat.empty safe? should one test for the dimensions being 0?

Vec.ssqr returns incorrect results in 10.0.1 and 11.0.0

Hi,

After upgrading from 7.2.1 to 11.0.0 (and adjusting the axpy labeled argument issues) I ran into a nasty bug: Vec.ssqr returns incorrect results. This is with OCaml 4.05.0 as well as 4.05.0+trunk+flambda.

I thought this could be a boxing/unboxing issue, but the @unboxed annotation seems to be there for the return value in the generated .ml's.

In the meantime we'll be using 9.3.2 which doesn't have this problem.

test_lapack.zip

open Lacaml.D

let test_ssqr () =
  for k = 1 to 1000 do
    let n = 1 + Random.int 100 in
    let v = Vec.create n in
    for j = 1 to n do
      v.{j} <- Random.float 1.0 -. 0.5
    done;
    let ss = ref 0.0 in
    for j = 1 to n do
      ss := !ss +. v.{j} *. v.{j}
    done;
    let ss' = Vec.ssqr v in
    let err = abs_float (!ss -. ss') in
    let tol = float n *. epsilon_float in
    if err > tol then failwith (Printf.sprintf "test_ssqr: err=%g > tol=%g" err tol)
  done

let _ = test_ssqr ()

Release compatible with OCaml 5?

The current master works fine with ocaml 5. Would it be possible to have a new release? Even better if it could include #53

I would be happy to deal with the releasing burden if you don't have time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.