Closed kit-ty-kate closed 1 month ago
In addition to the missing Float16 pattern matches the C code has warnings from the K&R C style function declarations and incompatible pointer types.
https://github.com/tmcgilchrist/owl/tree/ocaml_5_2 has basic fix for pattern matches in ef69ebe19f7e3b5ff1e51453999171e2d4b32ced and silenced K&R C warnings in c3a3582e1c728b225950c253816ec7c8bfee0fcf
Haven't looked into the last warnings about incompatible pointer types.
opam exec -- dune build @all
In file included from src/owl/core/owl_ndarray_contract_stub.c:17:
src/owl/core/owl_ndarray_contract_impl.h:88:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat[]' (aka 'long[]') [-Wincompatible-pointer-types]
cp->n = X->dim;
^ ~~~~~~
In file included from src/owl/core/owl_ndarray_contract_stub.c:26:
src/owl/core/owl_ndarray_contract_impl.h:88:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat[]' (aka 'long[]') [-Wincompatible-pointer-types]
cp->n = X->dim;
^ ~~~~~~
In file included from src/owl/core/owl_ndarray_contract_stub.c:35:
src/owl/core/owl_ndarray_contract_impl.h:88:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat[]' (aka 'long[]') [-Wincompatible-pointer-types]
cp->n = X->dim;
^ ~~~~~~
In file included from src/owl/core/owl_ndarray_contract_stub.c:44:
src/owl/core/owl_ndarray_contract_impl.h:88:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat[]' (aka 'long[]') [-Wincompatible-pointer-types]
cp->n = X->dim;
^ ~~~~~~
4 warnings generated.
I expect that proper Float16 support will need more work.
Most scientific computing libraries support higher precision floating point operations (floats and doubles), to support float16 or bfloat16 or more exotic float8 the common BLAS functions has to be implemented with reduced precision. To support float16 now in Owl, the linear algebra operation can be done in higher precision (float32) by converting float16 array buffer to float32 array buffer and then stored back again in float16 array buffer.
Raising precision would cause some overhead but not that much, also accumulation in higher precision (float32) is also more stable. This is what ml_types library does for accumulation.
@mtk2xfugaku thank you for the details, that makes sense. I'm unlikely to have time to do that work, my main goal was to get it compiling for Sandmark GC regression tests.
@tmcgilchrist I cloned your branch and ran the tests and everything passes. Based on your experience, what else do you feel needs to be done before this can be merged?
I expect that proper Float16 support will need more work.
In your opinion could this be left to a future project, or is this a necessary prerequisite before users of OCaml 5.2 can reliably use Owl?
This compilation issue is fixed in the current Owl.
OCaml 5.2 added support for float16 bigarrays and owl-base fails with: