Skip to content

Commit

Permalink
Add configuration file for aeos module and update Dockerfiles (#336)
Browse files Browse the repository at this point in the history
* add configuration file to aeo

* update dockerfiles
  • Loading branch information
jzstark authored and ryanrhymes committed Dec 5, 2018
1 parent ed281a5 commit 965294c
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 28 deletions.
16 changes: 10 additions & 6 deletions docker/Dockerfile.alpine
@@ -1,18 +1,19 @@
############################################################
# Dockerfile to build Owl docker image
# Based on ryanrhymes/owl master branch
# Based on owlbarn/owl master branch
# By Liang Wang <liang.wang@cl.cam.ac.uk>
############################################################

FROM ocaml/opam2:alpine-3.6-ocaml-4.06.0
FROM ocaml/opam2:alpine-3.8
USER opam


##################### PREREQUISITES ########################

RUN sudo apk update
RUN sudo apk add m4 wget unzip aspcud openblas-dev
RUN opam install -y oasis dune ocaml-compiler-libs ctypes alcotest utop base stdio configurator
RUN opam update && opam switch create 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes alcotest utop base stdio configurator sexplib


#################### SET UP ENV VARS #######################
Expand All @@ -37,18 +38,21 @@ RUN sed -i -- 's/-Wno-extern-c-compat -Wno-c++11-long-long -Wno-invalid-partial-
&& sed -i -- 's/-flto/ /g' $EIGENPATH/lib/Makefile \
&& sed -i -- 's/-flto/ /g' $EIGENPATH/_oasis

RUN cd $EIGENPATH && sudo make oasis && sudo make && sudo make install && sudo make clean
RUN cd $EIGENPATH && make oasis && make && make install
RUN sudo cp $EIGENPATH/_build/include/libeigen.a /usr/local/lib


#################### INSTALL OWL #######################

ENV OWLPATH /home/opam/owl
RUN cd /home/opam && git clone https://github.com/ryanrhymes/owl.git
RUN cd /home/opam && git clone https://github.com/owlbarn/owl.git

RUN rm -f $OWLPATH/src/owl/misc/owl_plot.* \
&& sed -i '/plplot/d' $OWLPATH/src/owl/jbuild \
&& sed -i '/plplot/d' $OWLPATH/src/owl/dune \
&& sed -i '/module Plot = Owl_plot/d' $OWLPATH/src/owl/owl.ml

RUN sed -i -- 's/\"-llapacke" :://g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking

RUN cd $OWLPATH && make && make install


Expand Down
14 changes: 8 additions & 6 deletions docker/Dockerfile.centos
@@ -1,10 +1,10 @@
############################################################
# Dockerfile to build Owl docker image
# Based on ryanrhymes/owl master branch
# Based on owlbarn/owl master branch
# By Liang Wang <liang.wang@cl.cam.ac.uk>
############################################################

FROM ocaml/opam2:centos-7-ocaml-4.06.0
FROM ocaml/opam2:centos-7
USER opam


Expand All @@ -14,8 +14,8 @@ RUN sudo yum update -y
RUN sudo yum -y install git wget unzip m4 pkg-config gcc-gfortran epel-release
RUN sudo yum -y install openblas-devel

RUN opam update && opam switch 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop eigen base stdio configurator alcotest
RUN opam update && opam switch create 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop eigen base stdio configurator alcotest sexplib


#################### SET UP ENV VARS #######################
Expand All @@ -30,10 +30,12 @@ ENV OWLPATH /home/opam/owl
RUN cd /home/opam && git clone https://github.com/ryanrhymes/owl.git

RUN rm -f $OWLPATH/src/owl/misc/owl_plot.* \
&& sed -i '/plplot/d' $OWLPATH/src/owl/jbuild \
&& sed -i '/plplot/d' $OWLPATH/src/owl/dune \
&& sed -i '/module Plot = Owl_plot/d' $OWLPATH/src/owl/owl.ml

RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking
RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml \
&& sed -i -- 's/\"-llapacke\" :://g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking

RUN make -C $OWLPATH && make -C $OWLPATH install && make -C $OWLPATH clean


Expand Down
30 changes: 23 additions & 7 deletions docker/Dockerfile.fedora
@@ -1,10 +1,10 @@
############################################################
# Dockerfile to build Owl docker image
# Based on ryanrhymes/owl master branch
# Based on owlbarn/owl master branch
# By Liang Wang <liang.wang@cl.cam.ac.uk>
############################################################

FROM ocaml/opam2:fedora-26-ocaml-4.06.0
FROM ocaml/opam2:fedora-29
USER opam


Expand All @@ -14,8 +14,8 @@ RUN sudo yum update -y
RUN sudo yum -y install git wget unzip m4 pkg-config gcc-gfortran
RUN sudo dnf -y install openblas-devel

RUN opam update && opam switch 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop eigen base stdio configurator alcotest
RUN opam update && opam switch create 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop base stdio configurator alcotest sexplib


#################### SET UP ENV VARS #######################
Expand All @@ -24,16 +24,32 @@ ENV PATH /home/opam/.opam/4.06.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/u
ENV CAML_LD_LIBRARY_PATH /home/opam/.opam/4.06.0/lib/stublibs


################# INSTALL EIGEN LIBRARY ####################

ENV EIGENPATH /home/opam/eigen
RUN cd /home/opam/ && git clone https://github.com/owlbarn/eigen.git

RUN sed -i -- 's/-Wno-extern-c-compat -Wno-c++11-long-long -Wno-invalid-partial-specialization/-Wno-ignored-attributes/g' $EIGENPATH/lib/Makefile \
&& sed -i -- 's/-flto/ /g' $EIGENPATH/lib/Makefile \
&& sed -i -- 's/-flto/ /g' $EIGENPATH/_oasis

RUN cd $EIGENPATH \
&& make oasis && make && make install
RUN sudo cp $EIGENPATH/_build/include/libeigen.a /usr/local/lib/


################## INSTALL OWL LIBRARY #####################

ENV OWLPATH /home/opam/owl
RUN cd /home/opam && git clone https://github.com/ryanrhymes/owl.git
RUN cd /home/opam && git clone https://github.com/owlbarn/owl.git

RUN rm -f $OWLPATH/src/owl/misc/owl_plot.* \
&& sed -i '/plplot/d' $OWLPATH/src/owl/jbuild \
&& sed -i '/plplot/d' $OWLPATH/src/owl/dune \
&& sed -i '/module Plot = Owl_plot/d' $OWLPATH/src/owl/owl.ml

RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking
RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml \
&& sed -i -- 's/\"-llapacke\" :://g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking

RUN make -C $OWLPATH && make -C $OWLPATH install && make -C $OWLPATH clean


Expand Down
16 changes: 9 additions & 7 deletions docker/Dockerfile.opensuse
@@ -1,10 +1,10 @@
############################################################
# Dockerfile to build Owl docker image
# Based on ryanrhymes/owl master branch
# Based on owlbarn/owl master branch
# By Liang Wang <liang.wang@cl.cam.ac.uk>
############################################################

FROM ocaml/opam2:opensuse-42.3-ocaml-4.06.0
FROM ocaml/opam2:opensuse-42.3
USER opam


Expand All @@ -14,8 +14,8 @@ RUN sudo zypper -n update
RUN sudo zypper -n in git wget unzip m4 pkg-config gcc-fortran
RUN sudo sudo zypper ref && sudo zypper -n in openblas-devel && sudo update-alternatives --config libblas.so.3

RUN opam update && opam switch 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop eigen base stdio configurator alcotest
RUN opam update && opam switch create 4.06.0 && eval $(opam config env)
RUN opam install -y oasis dune ocaml-compiler-libs ctypes utop eigen base stdio configurator alcotest sexplib


#################### SET UP ENV VARS #######################
Expand All @@ -27,13 +27,15 @@ ENV CAML_LD_LIBRARY_PATH /home/opam/.opam/4.06.0/lib/stublibs
################## INSTALL OWL LIBRARY #####################

ENV OWLPATH /home/opam/owl
RUN cd /home/opam && git clone https://github.com/ryanrhymes/owl.git
RUN cd /home/opam && git clone https://github.com/owlbarn/owl.git

RUN rm -f $OWLPATH/src/owl/misc/owl_plot.* \
&& sed -i '/plplot/d' $OWLPATH/src/owl/jbuild \
&& sed -i '/plplot/d' $OWLPATH/src/owl/dune \
&& sed -i '/module Plot = Owl_plot/d' $OWLPATH/src/owl/owl.ml

RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking
RUN sed -i -- 's:/usr/local/opt/openblas/lib:/usr/lib/x86_64-linux-gnu/:g' $OWLPATH/src/owl/config/configure.ml \
&& sed -i -- 's/\"-llapacke\" :://g' $OWLPATH/src/owl/config/configure.ml # FIXME: hacking

RUN make -C $OWLPATH && make -C $OWLPATH install && make -C $OWLPATH clean


Expand Down
66 changes: 66 additions & 0 deletions src/aeos/config/configure.ml
@@ -0,0 +1,66 @@
(*
* OWL - OCaml Scientific and Engineering Computing
* Copyright (c) 2016-2018 Liang Wang <liang.wang@cl.cam.ac.uk>
*)

module C = Configurator.V1


let write_sexp fn sexp =
Stdio.Out_channel.write_all fn ~data:(Sexplib.Sexp.to_string sexp)


let get_os_type c =
let sys = C.ocaml_config_var c "system" in
match sys with Some s -> s | None -> ""


let get_default_cflags _c = [
"-g"; "-O3"; "-Ofast";
"-march=native"; "-funroll-loops"; "-ffast-math";
"-DSFMT_MEXP=19937"; "-fno-strict-aliasing";
]


let get_openmp_cflags c =
match get_os_type c with
| "linux" -> [ "-fopenmp" ]
| "linux_elf" -> [ "-fopenmp" ]
| "macosx" -> [ "-Xpreprocessor"; "-fopenmp" ]
| "mingw64" -> [ "-fopenmp" ]
| _ -> []


let get_default_libs () = ["-lm";]


let get_openmp_libs c =
match get_os_type c with
| "linux" -> [ "-lgomp" ]
| "linux_elf" -> [ "-lgomp" ]
| "macosx" -> [ "-lomp" ]
| "mingw64" -> [ "-lgomp" ]
| _ -> []


let () =
C.main ~name:"aeos" (fun c ->

(* configure link options *)
let libs = []
@ get_default_libs ()
@ get_openmp_libs c
in

(* configure compile options *)
let cflags = []
@ get_default_cflags c
@ get_openmp_cflags c
in

(* assemble default config *)
let conf : C.Pkg_config.package_conf = { cflags; libs } in

write_sexp "aeos_c_flags.sexp" Sexplib.Std.(sexp_of_list sexp_of_string conf.cflags);
write_sexp "aeos_c_library_flags.sexp" Sexplib.Std.(sexp_of_list sexp_of_string conf.libs);
)
7 changes: 7 additions & 0 deletions src/aeos/config/dune
@@ -0,0 +1,7 @@
(executable
(name configure)
(libraries
dune.configurator
sexplib
stdio
))
12 changes: 10 additions & 2 deletions src/aeos/dune
Expand Up @@ -9,8 +9,16 @@
owl_aeos_tuner_fold_stub
)
(libraries str unix bigarray)
(c_flags (-g -O3 -Ofast -march=native -mfpmath=sse -funroll-loops -ffast-math -DSFMT_MEXP=19937 -msse2 -fno-strict-aliasing -Wno-logical-op-parentheses -Xpreprocessor -fopenmp))
(c_library_flags (-lm -lomp -framework Accelerate))
(c_flags (:include aeos_c_flags.sexp))
(c_library_flags (:include aeos_c_library_flags.sexp))
)

(rule
(targets aeos_c_flags.sexp
aeos_c_library_flags.sexp
)
(deps (:deps config/configure.exe))
(action (run %{deps}))
)

(executable
Expand Down

0 comments on commit 965294c

Please sign in to comment.