Skip to content

Commit

Permalink
prefixing all options with micm_ (#413)
Browse files Browse the repository at this point in the history
* prefixing all options with micm_

* correcting target compile options

* namespacing compile option

* prefixing gpu arch with micm
  • Loading branch information
K20shores authored Mar 4, 2024
1 parent 55de514 commit 0c23465
Show file tree
Hide file tree
Showing 36 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
],
"settings": {
},
"postCreateCommand": "cd /workspaces/micm && mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=release -D ENABLE_CLANG_TIDY:BOOL=FALSE -D ENABLE_LLVM:BOOL=TRUE -D ENABLE_MEMCHECK:BOOL=TRUE .. && make install -j 2"
"postCreateCommand": "cd /workspaces/micm && mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=release -D MICM_ENABLE_LLVM:BOOL=TRUE -D MICM_ENABLE_MEMCHECK:BOOL=TRUE .. && make install -j 2"
}
46 changes: 22 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,29 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
# Set up include and lib directories
set(MICM_LIB_DIR "${PROJECT_BINARY_DIR}/lib")

option(ENABLE_CLANG_TIDY "Enable clang-tiday to format source code" OFF)
option(ENABLE_MPI "Enable MPI parallel support" OFF)
option(ENABLE_OPENMP "Enable OpenMP support" OFF)
option(ENABLE_COVERAGE "Enable code coverage output" OFF)
option(ENABLE_MEMCHECK "Enable memory checking in tests" OFF)
option(ENABLE_JSON "Enable json configureation file reading" ON)
option(BUILD_DOCS "Build the documentation" OFF)
option(ENABLE_CUDA "Build with Cuda support" OFF)
option(ENABLE_OPENACC "Build with OpenACC Support" OFF)
option(ENABLE_LLVM "Build with LLVM support for JIT-compiling" OFF)
option(ENABLE_TESTS "Build the tests" ON)
option(ENABLE_EXAMPLES "Build the examples" ON)
set(DEFAULT_VECTOR_MATRIX_SIZE "4" CACHE STRING "Default size for vectorizable matrix types")
option(MICM_ENABLE_CLANG_TIDY "Enable clang-tiday to format source code" OFF)
option(MICM_ENABLE_MPI "Enable MPI parallel support" OFF)
option(MICM_ENABLE_OPENMP "Enable OpenMP support" OFF)
option(MICM_ENABLE_COVERAGE "Enable code coverage output" OFF)
option(MICM_ENABLE_MEMCHECK "Enable memory checking in tests" OFF)
option(MICM_ENABLE_JSON "Enable json configureation file reading" ON)
option(MICM_BUILD_DOCS "Build the documentation" OFF)
option(MICM_ENABLE_CUDA "Build with Cuda support" OFF)
option(MICM_ENABLE_OPENACC "Build with OpenACC Support" OFF)
option(MICM_ENABLE_LLVM "Build with LLVM support for JIT-compiling" OFF)
option(MICM_ENABLE_TESTS "Build the tests" ON)
option(MICM_ENABLE_EXAMPLES "Build the examples" ON)
set(MICM_DEFAULT_VECTOR_MATRIX_SIZE "4" CACHE STRING "Default size for vectorizable matrix types")

include(CMakeDependentOption)
# Option to collect custom OpenACC flags
cmake_dependent_option(ENABLE_GPU_TYPE "Enable custom CUDA flags" OFF
"ENABLE_OPENACC OR ENABLE_CUDA" ON)
cmake_dependent_option(MICM_ENABLE_GPU_TYPE "Enable custom CUDA flags" OFF
"MICM_ENABLE_OPENACC OR MICM_ENABLE_CUDA" ON)

if(ENABLE_GPU_TYPE)
set(GPU_TYPE "" CACHE STRING "The GPU type being targeted")
if(MICM_ENABLE_GPU_TYPE)
set(MICM_GPU_TYPE "" CACHE STRING "The GPU type being targeted")
endif()

add_compile_definitions(DEFAULT_VECTOR_SIZE=${DEFAULT_VECTOR_MATRIX_SIZE})

# on ubuntu with clang, an incorrect version of the c++ standard library was being linked
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# If the compiler is Clang, use libc++
Expand All @@ -68,16 +66,16 @@ include(cmake/dependencies.cmake)

add_subdirectory(src)

if(BUILD_DOCS)
if(MICM_BUILD_DOCS)
add_subdirectory(docs)
endif()

################################################################################
# Tests

if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
if(PROJECT_IS_TOP_LEVEL AND MICM_ENABLE_TESTS)
# Test code coverage
if(ENABLE_COVERAGE)
if(MICM_ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
Expand Down Expand Up @@ -111,14 +109,14 @@ endif()
################################################################################
# Command-line driver examples

if(PROJECT_IS_TOP_LEVEL AND ENABLE_EXAMPLES AND ENABLE_JSON)
if(PROJECT_IS_TOP_LEVEL AND MICM_ENABLE_EXAMPLES AND MICM_ENABLE_JSON)
add_subdirectory(examples)
endif()

################################################################################
# Copy configuration data

if(PROJECT_IS_TOP_LEVEL AND (ENABLE_TESTS OR ENABLE_EXAMPLES))
if(PROJECT_IS_TOP_LEVEL AND (MICM_ENABLE_TESTS OR MICM_ENABLE_EXAMPLES))
add_custom_target(copy_example_configs ALL ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/examples/configs ${CMAKE_BINARY_DIR}/examples/configs)
endif()
2 changes: 1 addition & 1 deletion cmake/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# modified from https://github.com/filipdutescu/modern-cpp-template/blob/master/cmake/StaticAnalyzers.cmake

if(ENABLE_CLANG_TIDY)
if(MICM_ENABLE_CLANG_TIDY)
find_program(CLANGTIDY clang-tidy)
if(CLANGTIDY)
set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-Wno-unknown-warning-option)
Expand Down
16 changes: 8 additions & 8 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
################################################################################
# Memory check

if(ENABLE_MEMCHECK)
if(MICM_ENABLE_MEMCHECK)
find_file(MEMCHECK_SUPPRESS_FILE
DOC "Suppression file for memory checking"
NAMES openmpi-valgrind.supp
Expand All @@ -22,7 +22,7 @@ endif()
################################################################################
# OpenMP

if(ENABLE_OPENMP)
if(MICM_ENABLE_OPENMP)
if(APPLE)
# Apple clang by default doesn't include support for openmp
# but if omp was installed with `brew install libomp`, support can be configured
Expand Down Expand Up @@ -65,7 +65,7 @@ endif()
################################################################################
# MPI

if(ENABLE_MPI)
if(MICM_ENABLE_MPI)
find_package(MPI REQUIRED)
message(STATUS "Compiling with MPI support")
endif()
Expand Down Expand Up @@ -94,7 +94,7 @@ endif()
################################################################################
# nlohmann::json

if(ENABLE_JSON)
if(MICM_ENABLE_JSON)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
Expand All @@ -105,20 +105,20 @@ endif()
################################################################################
# Docs

if(BUILD_DOCS)
if(MICM_BUILD_DOCS)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
endif()

################################################################################
# GPU Support

if(ENABLE_CUDA)
if(MICM_ENABLE_CUDA)
find_package(CUDA REQUIRED)
enable_language(CUDA)
endif()

if(ENABLE_OPENACC)
if(MICM_ENABLE_OPENACC)
find_package(OpenACC REQUIRED)
endif()

Expand All @@ -127,7 +127,7 @@ endif()
#
# TODO: Try to use fetch content for LLVM libraries

if(ENABLE_LLVM)
if(MICM_ENABLE_LLVM)
find_package(LLVM REQUIRED CONFIG)
if(LLVM_FOUND)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
Expand Down
8 changes: 4 additions & 4 deletions cmake/test_util.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################################################################
# Utility functions for creating tests

if(ENABLE_MEMCHECK)
if(MICM_ENABLE_MEMCHECK)
find_program(MEMORYCHECK_COMMAND "valgrind")
endif()

Expand Down Expand Up @@ -37,7 +37,7 @@ endfunction(create_standard_test)
# Add a test

function(add_micm_test test_name test_binary test_args working_dir test_skip_memcheck)
if(ENABLE_MPI)
if(MICM_ENABLE_MPI)
add_test(NAME ${test_name}
COMMAND mpirun -v -np 2 ${CMAKE_BINARY_DIR}/${test_binary} ${test_args}
WORKING_DIRECTORY ${working_dir})
Expand All @@ -49,11 +49,11 @@ function(add_micm_test test_name test_binary test_args working_dir test_skip_mem
set(MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1 --trace-children=yes --leak-check=full --gen-suppressions=all ${MEMCHECK_SUPPRESS}")
set(memcheck "${MEMORYCHECK_COMMAND} ${MEMORYCHECK_COMMAND_OPTIONS}")
separate_arguments(memcheck)
if(ENABLE_MPI AND MEMORYCHECK_COMMAND AND ENABLE_MEMCHECK AND NOT test_skip_memcheck)
if(MICM_ENABLE_MPI AND MEMORYCHECK_COMMAND AND MICM_ENABLE_MEMCHECK AND NOT test_skip_memcheck)
add_test(NAME memcheck_${test_name}
COMMAND mpirun -v -np 2 ${memcheck} ${CMAKE_BINARY_DIR}/${test_binary} ${test_args}
WORKING_DIRECTORY ${working_dir})
elseif(MEMORYCHECK_COMMAND AND ENABLE_MEMCHECK AND NOT test_skip_memcheck)
elseif(MEMORYCHECK_COMMAND AND MICM_ENABLE_MEMCHECK AND NOT test_skip_memcheck)
add_test(NAME memcheck_${test_name}
COMMAND ${memcheck} ${CMAKE_BINARY_DIR}/${test_binary} ${test_args}
WORKING_DIRECTORY ${working_dir})
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN mkdir /build \
&& cd /build \
&& cmake \
-D CMAKE_BUILD_TYPE=release \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
../micm \
&& make install -j 8

Expand Down
10 changes: 5 additions & 5 deletions docker/Dockerfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ RUN mkdir /build \
&& cd /build \
&& cmake \
-D CMAKE_BUILD_TYPE=debug \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D ENABLE_COVERAGE:BOOL=TRUE \
-D ENABLE_LLVM:BOOL=TRUE \
# -D ENABLE_MPI:BOOL=TRUE \
# -D ENABLE_OPENMP:BOOL=TRUE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_COVERAGE:BOOL=TRUE \
-D MICM_ENABLE_LLVM:BOOL=TRUE \
# -D MICM_ENABLE_MPI:BOOL=TRUE \
# -D MICM_ENABLE_OPENMP:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.docs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN echo "The suffix is '$SWITCHER_SUFFIX'"

RUN mkdir /build \
&& cd /build \
&& cmake -D BUILD_DOCS=ON \
&& cmake -D MICM_BUILD_DOCS=ON \
/micm \
&& make docs

Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.llvm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ RUN mkdir /build \
&& cd /build \
&& cmake \
-D CMAKE_BUILD_TYPE=release \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D ENABLE_LLVM:BOOL=TRUE \
-D ENABLE_MEMCHECK:BOOL=TRUE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_LLVM:BOOL=TRUE \
-D MICM_ENABLE_MEMCHECK:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.memcheck
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ RUN mkdir /build \
&& cd /build \
&& cmake \
-D CMAKE_BUILD_TYPE=release \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D ENABLE_MEMCHECK:BOOL=TRUE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_MEMCHECK:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.mpi
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
RUN mkdir /build \
&& cd /build \
&& cmake \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D ENABLE_MPI:BOOL=TRUE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_MPI:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.nvhpc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ RUN mkdir /cuda_build \
&& cd /cuda_build \
&& cmake \
-D CMAKE_BUILD_TYPE=debug \
-D ENABLE_CUDA=ON \
-D GPU_TYPE="a100" \
-D MICM_ENABLE_CUDA=ON \
-D MICM_GPU_TYPE="a100" \
../micm \
&& make -j 8 install

Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.openmp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ COPY . /micm/
RUN mkdir /build \
&& cd /build \
&& cmake \
-D ENABLE_CLANG_TIDY:BOOL=FALSE \
-D ENABLE_OPENMP:BOOL=TRUE \
-D ENABLE_JSON:BOOL=TRUE \
-D MICM_ENABLE_CLANG_TIDY:BOOL=FALSE \
-D MICM_ENABLE_OPENMP:BOOL=TRUE \
-D MICM_ENABLE_JSON:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.publish
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ RUN mkdir /build \
&& cd /build \
&& cmake \
-D CMAKE_BUILD_TYPE=release \
-D ENABLE_LLVM:BOOL=TRUE \
-D ENABLE_JSON:BOOL=TRUE \
-D MICM_ENABLE_LLVM:BOOL=TRUE \
-D MICM_ENABLE_JSON:BOOL=TRUE \
../micm \
&& make install -j 8

Expand Down
6 changes: 3 additions & 3 deletions docs/source/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ From the root directory of micm:
cd docs
pip install -r requirements.txt
cd .. && mkdir build && cd build
cmake -DBUILD_DOCS=ON ..
cmake -DMICM_BUILD_DOCS=ON ..
make docs
open docs/sphinx/index.html
Expand All @@ -77,7 +77,7 @@ Venv
cd docs
pip install -r requirements.txt
cd .. && mkdir build && cd build
cmake -DBUILD_DOCS=ON ..
cmake -DMICM_BUILD_DOCS=ON ..
make docs
open docs/sphinx/index.html
Expand All @@ -91,6 +91,6 @@ Conda
cd docs
pip install -r requirements.txt
cd .. && mkdir build && cd build
cmake -DBUILD_DOCS=ON ..
cmake -DMICM_BUILD_DOCS=ON ..
make docs
open docs/sphinx/index.html
6 changes: 3 additions & 3 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ step will simply copy the header files into the normal location required by your
$ make test
CMake will allow for setting options such as the installation directory
with CMAKE_INSTALL_PREFIX, or various build flags such as BUILD_DOCS, ENABLE_CUDA, etc.
with CMAKE_INSTALL_PREFIX, or various build flags such as MICM_BUILD_DOCS, MICM_ENABLE_CUDA, etc.

Options
-------
Expand All @@ -43,13 +43,13 @@ Some of these libraries can be included automatically with cmake build options,
others require that you have libraries installed on your system.

- JSON configuration support
- When building micm, you need to enable the JSON option. This will download and configure the `nlohmann/jsoncpp library <https://github.com/nlohmann/json>`_ for you. For example: ``cmake -DENABLE_JSON=ON ..``
- When building micm, you need to enable the JSON option. This will download and configure the `nlohmann/jsoncpp library <https://github.com/nlohmann/json>`_ for you. For example: ``cmake -DMICM_ENABLE_JSON=ON ..``
- JIT-compiled chemistry functions
- This requires `LLVM <https://llvm.org/docs/index.html>`_ to be installed with on your system. Once it is, you can include the jit options with ``cmake -DENBABLE_LLVM=ON ..``
- GPU support
- Coming soon
- OpenMP
- On macOS, you either need to configure cmake to use gcc which ships with OpenMP (either ``CXX=g++ cmake -DENABLE_OPENMP=ON ..`` or ``cmake -DCMAKE_CXX_COMPILER=g++ -DENABLE_OPENMP=ON ..``)
- On macOS, you either need to configure cmake to use gcc which ships with OpenMP (either ``CXX=g++ cmake -DMICM_ENABLE_OPENMP=ON ..`` or ``cmake -DCMAKE_CXX_COMPILER=g++ -DMICM_ENABLE_OPENMP=ON ..``)

For more ways to build and install micm, see :ref:`Installation and usage`. If you would like instructions for building
the docs, see :ref:`Contributing`.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you would like to include the json examples, you must configure micm to build

.. code-block:: console
$ cmake -DENABLE_JSON=ON ..
$ cmake -DMICM_ENABLE_JSON=ON ..
$ make
$ ./test_rate_constants_no_user_defined_example_with_config
$ ./test_rate_constants_user_defined_example_with_config
Expand Down
2 changes: 1 addition & 1 deletion include/micm/process/jit_process_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace micm

/// @brief JIT-compiled solver function calculators for a collection of processes
/// The template parameter is the number of grid cells to solve simultaneously
template<std::size_t L = DEFAULT_VECTOR_SIZE>
template<std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class JitProcessSet : public ProcessSet
{
std::shared_ptr<JitCompiler> compiler_;
Expand Down
2 changes: 1 addition & 1 deletion include/micm/solver/jit_lu_decomposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace micm
///
/// See LuDecomposition class description for algorithm details
/// The template parameter is the number of blocks (i.e. grid cells) in the block-diagonal matrix
template<std::size_t L = DEFAULT_VECTOR_SIZE>
template<std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class JitLuDecomposition : public LuDecomposition
{
std::shared_ptr<JitCompiler> compiler_;
Expand Down
4 changes: 2 additions & 2 deletions include/micm/solver/jit_rosenbrock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace micm
template<
template<class> class MatrixPolicy = VectorMatrix,
template<class> class SparseMatrixPolicy = VectorSparseMatrix,
class LinearSolverPolicy = JitLinearSolver<DEFAULT_VECTOR_SIZE, SparseMatrixPolicy>,
class ProcessSetPolicy = JitProcessSet<DEFAULT_VECTOR_SIZE>>
class LinearSolverPolicy = JitLinearSolver<MICM_DEFAULT_VECTOR_SIZE, SparseMatrixPolicy>,
class ProcessSetPolicy = JitProcessSet<MICM_DEFAULT_VECTOR_SIZE>>
class JitRosenbrockSolver : public RosenbrockSolver<MatrixPolicy, SparseMatrixPolicy, LinearSolverPolicy, ProcessSetPolicy>
{
std::shared_ptr<JitCompiler> compiler_;
Expand Down
Loading

0 comments on commit 0c23465

Please sign in to comment.