Unverified Commit 4c52d420 authored by crlishka's avatar crlishka Committed by GitHub

Support builds of ngraph_dist with both gcc and clang (#306)

* Initial pass as supporting ngraph_dist builds with both gcc and clang.  Includes deprecated targets to support Jenkins CI with old feature and development branches that may not have these changes.

* Added build_all, check_all, and install_all targets

* Broke build and check steps into separate make sections.  Each step already generated its own log.

* Updated README.md

* Fixed a bug in the docker build context, which was overly general and included the build directories.  This caused a loop where the docker images rebuilt into multi-gigabyte images after testing was run (yikes).  New context is the contrib/docker directory, which is tiny.  No more image rebuilds.

* Rename the docker image to be less generic, so that another tool doesn't accidentally use the same name

* Change compatibility target "make check_cpu" to run "make check_all", so that all builds are done.

* Add a conversion step to change the test-suite names for all unit tests, to include an indicator for what compiler was used for the builds (_gcc vs _clang).

* Unfortunately, modifying the test-suite name with compiler suffix did not show in Jenkins test results.  Now modifying classname instead.

* Switch builds to be RelWithDebInfo, which turns on optimization and includes debug symbols.  Remove verbose output when creating tarball, to reduce log fluff.
parent d8433899
This diff is collapsed.
......@@ -19,39 +19,42 @@ In order to use the make targets, you will need to do the following:
* Have docker installed on your computer with the docker daemon running.
* These scripts assume that you are able to run the `docker` command without using `sudo`. You will need to add your account to the `docker` group so this is possible.
* If your computer (running docker) sits behind a firewall, you will need to have the docker daemon properly configured to use proxies to get through the firewall, so that public docker registries and git repositories can be accessed.
* You should _not_ run `make check_cpu` from a directory in an NFS filesystem, if that NFS filesystem uses _root squash_ (see **Notes** section below). Instead, run `make check_cpu` from a cloned repo in a local filesystem.
* You should _not_ run `make check_*` targets from a directory in an NFS filesystem, if that NFS filesystem uses _root squash_ (see **Notes** section below). Instead, run `make check_*` targets from a cloned repo in a local filesystem.
## Make Targets
The _make targets_ are designed to provide easy commands to run actions using the docker image. All _make targets_ should be issued on the host OS, and _not_ in a docker image.
* In general, you simply need to run the command **`make check_cpu`**. This first makes the `build_ngraph_cpp_cpu` target as a dependency. Then it makes the `check_cpu` target, which will build NGraph-Cpp using _cmake_ and _make_ and then run unit testing. Please keep in mind that `make check_cpu` does not work when your working directory is in an NFS filesystem that uses _root squash_ (see **Notes** section below).
Most make targets are structured in the form `<action>_<compiler>`. The `<action>` indicates what you want to do (e.g. build, check, install), while the `<compiler>` indicates what you want to build with (i.e. gcc or clang).
* You can also run the command **`make shell`** to start an interactive bash shell inside the docker image. While this is not required for normal builds and unit testing, it allows you to run interactively within the docker image with the cloned repo mounted. Again, `build_ngraph_cpp_cpu` is made first as a dependency. Please keep in mind that `make shell` does not work when your working directory is in an NFS filesystem that uses _root squash_ (see **Notes** section below).
* In general, you simply need to run the command **`make check_all`**. This first makes the `build_docker_ngraph_cpp` target as a dependency. Then it makes the `build_*` and `check_*` targets, which will build NGraph-Cpp using _cmake_ and _make_ and then run unit testing. Please keep in mind that `make check_*` targets do not work when your working directory is in an NFS filesystem that uses _root squash_ (see **Notes** section below).
* Running the command **`make build_ngraph_cpp_cpu`** is also available, if you simply want to build the docker image. This target does work properly when your working directory is in an NFS filesystem.
* Two builds are supported: building with `gcc` and `clang`. Targets are named `*_gcc` and `*_clang` when they refer to building with a specific compiler, and the `*_all` targets are available to build with both compilers. Output directories are BUILD-GCC and BUILD-CLANG, at the top level.
Note that all operations performed inside the the docker image are run as **root**. This has unfortunate side effects if you run a make target that does operations inside the docker image, while your working directory is in an NFS filesystem that uses _root squash_ (see **Notes** below).
* You can also run the command **`make shell`** to start an interactive bash shell inside the docker image. While this is not required for normal builds and unit testing, it allows you to run interactively within the docker image with the cloned repo mounted. Again, `build_docker_ngraph_cpp` is made first as a dependency. Please keep in mind that `make shell` does not work when your working directory is in an NFS filesystem that uses _root squash_ (see **Notes** section below).
## Helper Scripts
* Running the command **`make build_docker_ngraph_cpp`** is also available, if you simply want to build the docker image. This target does work properly when your working directory is in an NFS filesystem.
These helper scripts are included for use in the `Makefile` and automated (Jenkins) jobs. **These scripts should _not_ be called directly unless you understand what they do.**
* Finally, **`make clean`** is available to clean up the BUILD-* and docker build directories.
#### `chown_files.sh`
Note that all operations performed inside the the docker image are run as a regular user, using the `run-as-user.sh` script. This is done to avoid writing root-owned files in mounted filesystems.
## Helper Scripts
Used in the `Makefile` to change the ownership of files while running _inside the docker image_. This is used to fix a problem with docker where files written in a mounted filesystem, from within the docker image, will end up being owned by root in the host OS. This leads to problems with Jenkins not being able to clean up its own job directories if docker images are used.
These helper scripts are included for use in the `Makefile` and automated (Jenkins) jobs. **These scripts should _not_ be called directly unless you understand what they do.**
#### `docker_cleanup.sh`
A helper script for Jenkins jobs to clean up old exited docker containers and `ngraph_*` docker images.
#### `run_as_user.sh`
A helper script to run as a normal user within the docker container. This is done to avoid writing root-owned files in mounted filesystems.
## Notes
* The top-level `Makefile` in this cloned repo can be used to build and unit-test NGraph-Cpp _outside_ of docker. This directory is only for building and running unit tests for NGraph-Cpp in the _reference-OS_ docker image.
* The `_cpu` suffix in the targets refers to the docker image being built such that testing is in a _cpu-only_ environment. At a later date, _gpu_ and other environments may be added. This convention was chosen to stay consistent with the _NervanaSystems ngraph_ project on Github.
* Due to limitations in how docker mounts work, `make check_cpu` and `make shell` will fail
if you try to run them while in a working directory that is in an NFS-mount that has _root squash_ enabled. The cause results from the process in the docker container running as root. When a file or directory is created by root in the mounted directory tree, from within the docker image, the NFS-mount (in the host OS) does not allow a root-created file, leading to a permissions error. This is dependent on whether the host OS performs "root squash" when mounting NFS filesystems. The fix to this is easy: run `make check_cpu` and `make shell` from a local filesystem.
* Due to limitations in how docker mounts work, `make check_cpu` and `make shell` will fail if you try to run them while in a working directory that is in an NFS-mount that has _root squash_ enabled. The cause results from the process in the docker container running as root. When a file or directory is created by root in the mounted directory tree, from within the docker image, the NFS-mount (in the host OS) does not allow a root-created file, leading to a permissions error. This is dependent on whether the host OS performs "root squash" when mounting NFS filesystems. The fix to this is easy: run `make check_cpu` and `make shell` from a local filesystem.
* These make targets have been tested on Ubuntu 14.04 and Ubuntu 16.04 with docker installed and the docker daemon properly configured. Some adjustments may be needed to run these on other OSes.
* These make targets have been tested on Ubuntu 16.04 with docker installed and the docker daemon properly configured. Some adjustments may be needed to run these on other OSes.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment