Graph Framework
Loading...
Searching...
No Matches
Build System

Overview of the Cmake based build system for the graph_framework.

Introduction

This page details the cmake based build system.


User Guide

The following section is for users of the framework.

Dependencies

The graph_framwork requires three external dependencies and one optional dependency. LLVM is another dependency that is used for generating CPU code. However this is automatically obtained via the build system. The graph_frame is written using the C++20 standard. The C interface uses C17 and the fortran interface uses Fortran 2008.

Required

Optional

  • Doxygen for generating this documentation.

Obtaining the code

The framework code itself can be obtained from the graph_framework Github repository.

git clone https://github.com/ORNL-Fusion/graph_framework.git

Source will be downloaded into a graph_framework directory unless a different directory is explicitly used.

Generating the build system

After the repository is cloned, create a build directory in the top level source directory and change into that directory.

mkdir build
cd build

There are two ways to run cmake. From the command line the build system can generated by using the cmake command with options set using the the -D option. As an exampole.

cmake -DOPTION_NAME=OPTION_VALUE ../

Where ../ points to the source directory containing the top level CMakeLists.txt file.

The recommended method is to use the interactive ccmake command instead.

ccmake ../

Note options can still be set from the command line using the -D option.

Build system Options

Initially, there will be no options. Along the botton, there are several commands. Use the 'c' command to start the configuation process. Once configured several options will apear. During this process cmake is cloning the LLVM repository. So this step may take some time initally. Most of the are various options for configuing LLVM and can be ignored. The important options are listed below.

Build options for users.
Option Discrption
CMAKE_BUILD_TYPE Switch between
  • Release
  • Debug
  • MinSizeRel
  • RelWithDebInfo
USE_VERBOSE Show verbose information about compute kernels.
BUILD_C_BINDING Generate the C langauge interface.
BUILD_Fortran_BINDINGGenerate the Fortran language interface.
USE_METAL Enable the Metal backend (macOS only).
USE_CUDA Enable the Cuda backend (Linux only).
USE_HIP Enable the Hip backend (Linux only, Hip branch).
USE_SSH Use ssh for git instead of html.
Note
macOS users will need to change the default option for CMAKE_CXX_COMPILER to clang++. This is due to the way the build systems determines default include directories for system libraries. This can be accomplished using the advacned options accessed from the t command or setting this via the command line.
cmake -DCMAKE_CXX_COMPILER=clang++ ../

Any time an option is changed, or a new option becomes is available, you need to use the configure c command for changes to take affect. Once all options are set, a generate g options will appear. Using this option will generate the Makefile.

Trouble Shooting.

Some times, cmake will fail to locate the NetCDF library if it is not installed in a standard path. In these cases you can use the CMAKE_PREFIX_PATH to define the install location of the NetCDF library. For instance if the netcdf library is installed in /foo/bar/lib the prefix path should be set to /foo/bar.

Building the code.

Once the build system is successfully generated a Makefile will appear. The code can be build using the

make

command. Note that the build system first starts by pulling the latest revision of LLVM. The build system then has to build LLVM first which can take a while. It is recommended to use a limited parallel build.

make -j10

The -jnum_processes option determines number of parallel instances to run. The build products will be found in assocated directories in the build directory.

A list of individual components which can be built can be identified using

make help

Running unit tests

Units tests can be run using the command.

make test ARGS=-j10

Like the parallel build the -jnum_processes option determines the number of parallel instances to run.


Developer Guide

This section covers information for developers of the framework itself.

Macro Definitions

The build system defines some macros for defining targets, configuring debug options, and configuing external dependences.

Tool targets


add_tool_target(target lang)

Define a tool target.

Parameters
[in] target The name of the target.
[in] lang File extention for the target (c, cpp, f90).

Target assumes there is a source file defined as target.lang. For instance a C++ source file named foo.cpp is configured as

add_tool_target(foo cpp)

This will generate a build target called xfoo.


add_test_target(target lang)

Define a test target.

Parameters
[in] target The name of the target.
[in] lang File extention for the target (c, cpp, f90).

The aguments are the same as add_tool_target. This also adds the target as a unit test.


Sanatizer flags


register_sanitizer_option(name)

Register a sanitizer option.

Parameters
[in] name The name of the sanitizer flags.

This adds a new cmake option SANITIZE_NAME to add -fsanitize=name to the command line arguments.


Register an external project


register_project(reg_name dir url default_tag sub_dir)

Register an external project.

Parameters
[in] reg_name Name for the registered project.
[in] dir Name directory to clone the project to.
[in] url URL for the repository.
[in] default_tag Default tag for to pull from.
[in] sub_dir Subdirectory to locate the project source code.

This function clones a external project into the directory defined by dir. This also adds a new build option for BUILD_TAG_DIR. The URL must have the format of

${URL_PROTO}domain.com${URL_SEP}remining/url

Debugging

In addition to the standard build options there are several debugging options that can be enabled.

Build System Options

Build options for developers.
Option Discription
USE_PCH Use precompiled headers during computation. Most users should keep this on.
SAVE_KERNEL_SOURCE Option to dump the generated compute kernel source code to disk.
USE_INPUT_CACHE Option to cache registers for the kernel arguments.
USE_CONSTANT_CACHE Option to use registers to cache constant values otherwise constants are inlined.
SHOW_USE_COUNT Generates information on the number of times a register is used.
USE_INDEX_CACHE Option to use registers to cache array indicies.
Sanitizer Flags
SANITIZE_ADDRESS Use address sanitizer debugging option.
SANITIZE_LEAK Use leak sanitizer debugging option.
SANITIZE_MEMORY Use memory sanitizer debugging option.
SANITIZE_THREAD Use thread sanitizer debugging option.
SANITIZE_UNDEFINED Use undefined sanitizer debugging option.
SANITIZE_FLOAT-DIVIDE-BY-ZEROUse float-divide-by-zero sanitizer debugging option.