# Development and testing

{% hint style="info" %}
**Good to know:** *Universal* uses [CMake ](https://cmake.org)to manage its builds, and [gitflow ](https://guides.github.com/introduction/flow/)to manage code contributions.
{% endhint %}

### Forking and cloning the *Universal* github repo

If you are interested in contributing to *Universal* development, then you want to set up a development system that follows the [gitflow](https://guides.github.com/introduction/flow/) workflow.

In quick summary:

1. fork github.com/stillwater-sc/universal to your own workspace
2. git clone <https://github.com/\\><your-github-id>/universal
3. cd universal
4. git remote add upstream <https://github.com/stillwater-sc/universal>

### Build configuration and compilation

Universal uses [CMake ](https://cmake.org/)to manage its build. On Windows there is a nice GUI tool, and if you are using Visual Studio, CMake is directly integrated into the IDE. For command line Linux and Mac environments, the process will look as follows:

```
$ cd build
$ cmake ..

 _____  _____  ____  _____  _____  ____   ____  ________  _______     ______        _       _____
|_   _||_   _||_   \|_   _||_   _||_  _| |_  _||_   __  ||_   __ \  .' ____ \      / \     |_   _|
  | |    | |    |   \ | |    | |    \ \   / /    | |_ \_|  | |__) | | (___ \_|    / _ \      | |
  | '    ' |    | |\ \| |    | |     \ \ / /     |  _| _   |  __ /   _.____`.    / ___ \     | |   _
   \ \__/ /    _| |_\   |_  _| |_     \ ' /     _| |__/ | _| |  \ \_| \____) | _/ /   \ \_  _| |__/ |
    `.__.'    |_____|\____||_____|     \_/     |________||____| |___|\______.'|____| |____||________|

-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No default build type specified: setting CMAKE_BUILD_TYPE=Release
-- C++20 has been enabled by default: but bit_cast<> requires gcc 11
-- Performing Test COMPILER_HAS_SSE3_FLAG
-- Performing Test COMPILER_HAS_SSE3_FLAG - Success
-- Performing Test COMPILER_HAS_AVX_FLAG
-- Performing Test COMPILER_HAS_AVX_FLAG - Success
-- Performing Test COMPILER_HAS_AVX2_FLAG
-- Performing Test COMPILER_HAS_AVX2_FLAG - Success
--
-- PROJECT_NAME                = universal
-- PROJECT_NAME_NOSPACES       = universal
-- PROJECT_SOURCE_DIR          = /home/stillwater/dev/clones/universal
-- PROJECT_VERSION             = 3.44.1.008a07a1
-- CMAKE_CURRENT_SOURCE_DIR    = /home/stillwater/dev/clones/universal
-- CMAKE_CURRENT_BINARY_DIR    = /home/stillwater/dev/clones/universal/build
-- GIT_COMMIT_HASH             = 008a07a1
-- GIT_BRANCH                  = cfloat_v5
-- include_install_dir         = include
-- include_install_dir_full    = include/universal
-- config_install_dir          = share/universal
-- include_install_dir_postfix = universal
--
-- ******************* Universal Arithmetic Library Configuration Summary *******************
-- General:
--   Version                          :   3.44.1.008a07a1
--   System                           :   Linux
--   C++ Language Requirement         :   C++20
--   C compiler                       :   /usr/bin/cc
--   Release C flags                  :   -O3 -DNDEBUG -Wall -Wpedantic -Wno-narrowing -Wno-deprecated
--   Debug C flags                    :   -g -Wall -Wpedantic -Wno-narrowing -Wno-deprecated
--   C++ compiler                     :   /usr/bin/c++
--   Release CXX flags                :   -O3 -DNDEBUG   -Wall -Wpedantic -Wno-narrowing -Wno-deprecated -Wall -Wpedantic -Wno-narrowing -Wno-deprecated
--   Debug CXX flags                  :   -g   -Wall -Wpedantic -Wno-narrowing -Wno-deprecated -Wall -Wpedantic -Wno-narrowing -Wno-deprecated
--   Build type                       :   Release
--
--   BUILD_ALL                        :   OFF
--   BUILD_DEMONSTRATION              :   ON
--   BUILD_NUMERICS                   :   OFF
--   BUILD_BENCHMARKS                 :   OFF
--   BUILD_NUMBER_SYSTEMS             :   OFF
--   BUILD_MIXEDPRECISION_SDK         :   OFF
--
--   BUILD_NUMBER_ARITHMETIC_CLASSES  :   OFF
--   BUILD_NUMBER_NATIVE_TYPES        :   OFF
--   BUILD_NUMBER_INTEGERS            :   OFF
--   BUILD_NUMBER_DECIMALS            :   OFF
--   BUILD_NUMBER_FIXPNTS             :   OFF
--   BUILD_NUMBER_CFLOATS             :   OFF
--   BUILD_NUMBER_AREALS              :   OFF
--   BUILD_NUMBER_UNUM_TYPE_1         :   OFF
--   BUILD_NUMBER_UNUM_TYPE_2         :   OFF
--   BUILD_NUMBER_POSITS              :   OFF
--   BUILD_NUMBER_VALIDS              :   OFF
--   BUILD_NUMBER_LNS                 :   OFF
--   BUILD_NUMBER_REALS               :   OFF
--   BUILD_NUMBER_CONVERSIONS         :   OFF
--
--   BUILD_CMD_LINE_TOOLS             :   ON
--   BUILD_EDUCATION                  :   ON
--   BUILD_APPLICATIONS               :   ON
--   BUILD_PLAYGROUND                 :   ON
--
--   BUILD_NUMERIC_CHALLENGES         :   OFF
--   BUILD_NUMERIC_UTILS              :   OFF
--   BUILD_NUMERIC_FPBENCH            :   OFF
--   BUILD_NUMERIC_FUNCTIONS          :   OFF
--   BUILD_NUMERIC_IEEE_QUIRES        :   OFF
--
--   BUILD_BENCHMARK_PERFORMANCE      :   OFF
--   BUILD_BENCHMARK_ACCURACY         :   OFF
--   BUILD_BENCHMARK_ENERGY           :   OFF
--
--   BUILD_MIXEDPRECISION_ROOTS       :   OFF
--   BUILD_MIXEDPRECISION_APPROXIMATE :   OFF
--   BUILD_MIXEDPRECISION_INTEGRATE   :   OFF
--   BUILD_MIXEDPRECISION_INTERPOLATE :   OFF
--   BUILD_MIXEDPRECISION_OPTIMIZE    :   OFF
--   BUILD_MIXEDPRECISION_CONJUGATE   :   OFF
--
--   BUILD_LINEAR_ALGEBRA_BLAS        :   OFF
--   BUILD_LINEAR_ALGEBRA_VMATH       :   OFF
--
--
--   BUILD_C_API_PURE_LIB             :   OFF
--   BUILD_C_API_SHIM_LIB             :   OFF
--   BUILD_C_API_LIB_PIC              :   OFF
--   BUILD_DOCS                       :   OFF
--
-- Regression Testing Level:
--   BUILD_REGRESSION_SANITY          :   ON
--
-- Dependencies:
--   SSE3                             :   NO
--   AVX                              :   NO
--   AVX2                             :   NO
--   Pthread                          :   NO
--   TBB                              :   NO
--   OMP                              :   NO
--
-- Utilities:
--   Serializer                       :   NO
--
-- Install:
--   Install path                     :   /usr/local
--

 _____  _____  ____  _____  _____  ____   ____  ________  _______     ______        _       _____
|_   _||_   _||_   \|_   _||_   _||_  _| |_  _||_   __  ||_   __ \  .' ____ \      / \     |_   _|
  | |    | |    |   \ | |    | |    \ \   / /    | |_ \_|  | |__) | | (___ \_|    / _ \      | |
  | '    ' |    | |\ \| |    | |     \ \ / /     |  _| _   |  __ /   _.____`.    / ___ \     | |   _
   \ \__/ /    _| |_\   |_  _| |_     \ ' /     _| |__/ | _| |  \ \_| \____) | _/ /   \ \_  _| |__/ |
    `.__.'    |_____|\____||_____|     \_/     |________||____| |___|\______.'|____| |____||________|

-- Configuring done
-- Generating done
-- Build files have been written to: /home/stillwater/dev/clones/universal/build

```

By default, the CMake process will configure the demonstration programs. A simple make will then build the programs.

![Building a Universal build configuration](https://3604518306-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9D1HtTe6H4Gh87SJ4ydi%2Fuploads%2F37UP9cUm7Nls8fFN9iRZ%2Funiversal-build.png?alt=media\&token=1c86ea6a-d14e-47db-abe9-a365a57337a3)

&#x20;

All the variables in the above log that start with **BUILD\_** are **build configuration** switches, turning on or off different components of the library.&#x20;

For example, if you want to build just the posit number system test suites, you would issue:

```
cmake -DBUILD_NUMBER_POSITS=ON ..

// or if we do NOT want to bother with the demonstration programs
cmake -DBUILD_DEMONSTRATION=OFF -DBUILD_NUMBER_POSITS=ON ..
```

The following BUILD variables are grouping collections of components:

* **BUILD\_ALL**  will build all the components of the library
* **BUILD\_DEMONSTRATION** will build command line, playground, applications, and educational components
* **BUILD\_NUMERICS** will build the numerical checks, utilities, and FPBench components
* **BUILD\_BENCHMARKS** will build the performance, accuracy and energy benchmarks
* **BUILD\_NUMBER\_SYSTEMS** will build all number systems and their regression suites
* **BUILD\_MIXEDPRECISION\_SDK** will build the SDK for mixed-precision algorithm optimization

### Testing

The CMake build configuration will automatically register the tests with ctest, and thus a quick invocation of ctest will execute the regression suites. ctest without arguments will execute all tests. ctest with a regex will test just those tests that match the regular expression:

![cfloat number system testing with ctest](https://3604518306-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9D1HtTe6H4Gh87SJ4ydi%2Fuploads%2FAnDe1gAriOguXBsAflJK%2Funiversal-test.png?alt=media\&token=0aa592b6-4c25-4cb0-848e-aaddc4be8368)

The full regression suite, when run sequentially, takes approximately 10 minutes. On modern hardware with a dozen of cores that test time goes down to 10 seconds. Even so, judicious build configuration that includes just the tests that your development impacts, will make your edit/compile/test cycle more productive, so familiarize yourself with all the available build targets to make your development enjoyable.
