Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ name: CI
on:
# Triggers the workflow on pull request events only for the "develop" branch
pull_request:
branches: [ "develop" ]
branches: ["develop"]
workflow_dispatch:


jobs:
build-run-tests:
# The type of runner that the job will run on
Expand All @@ -16,11 +15,13 @@ jobs:
strategy:
matrix:
with_caliper: [ON, OFF]
with_mpi : [ON, OFF]
with_mpi: [ON, OFF]

steps:
- uses: actions/checkout@v3
- name: Build WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Build WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
shell: bash -l {0}
run: |
module load gcc/11.2.1
Expand Down Expand Up @@ -48,14 +49,14 @@ jobs:
-DWITH_WORKFLOW=Off \
$GITHUB_WORKSPACE
make -j$(nproc)
- name: Run Tests WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
- name: Run Tests WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
run: |
cd build
source /spack/share/spack/setup-env.sh
spack env activate -p /ams-spack-env
env CTEST_OUTPUT_ON_FAILURE=1 make test

- name: Install AMS WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
- name: Install AMS WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
run: |
cd build
source /spack/share/spack/setup-env.sh
Expand All @@ -68,12 +69,14 @@ jobs:
container: ghcr.io/llnl/ams-ci-cuda11.6.1:latest

strategy:
matrix:
with_caliper: [ON, OFF]
with_mpi : [ON, OFF]
matrix:
with_caliper: [ON, OFF]
with_mpi: [ON, OFF]
steps:
- uses: actions/checkout@v3
- name: Build WITH_CUDA=On WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Build WITH_CUDA=On WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
shell: bash -l {0}
run: |
module load gcc/11.2.1
Expand Down Expand Up @@ -101,24 +104,25 @@ jobs:
-DWITH_WORKFLOW=Off \
$GITHUB_WORKSPACE
make -j$(nproc)
- name: Install AMS WITH_CUDA=On WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
- name: Install AMS WITH_CUDA=On WITH_CALIPER=${{ matrix.with_caliper }} WITH_MPI=${{ matrix.with_mpi }}
run: |
cd build
source /spack/share/spack/setup-env.sh
spack env activate -p /ams-spack-env
make -j$(nproc) install


install-link-cpu-tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: ghcr.io/llnl/ams-ci-almalinux8:latest

strategy:
matrix:
with_shared: [ON, OFF]
matrix:
with_shared: [ON, OFF]
steps:
- uses: actions/checkout@v3
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Build SharedLibray=${{ matrix.with_shared }}
shell: bash -l {0}
run: |
Expand Down Expand Up @@ -166,7 +170,7 @@ jobs:
cd build_idealgas/
export AMS_MFEM_PATH=$(spack location -i mfem)
echo "AMS_INSTALL_PATH=${AMS_INSTALL_PATH}"
cmake -DWITH_CUDA=Off -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS -DMFEM_DIR=${AMS_MFEM_PATH} $GITHUB_WORKSPACE/examples/ideal_gas/
cmake -DWITH_CUDA=Off -DCMAKE_PREFIX_PATH=${AMS_INSTALL_PATH}/ -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS -DMFEM_DIR=${AMS_MFEM_PATH} $GITHUB_WORKSPACE/examples/ideal_gas/
make -j$(nproc) VERBOSE=1

install-link-cuda-tests:
Expand All @@ -175,10 +179,12 @@ jobs:
container: ghcr.io/llnl/ams-ci-cuda11.6.1:latest

strategy:
matrix:
with_shared: [ON, OFF]
matrix:
with_shared: [ON, OFF]
steps:
- uses: actions/checkout@v3
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Build SharedLibray=${{ matrix.with_shared }}
shell: bash -l {0}
run: |
Expand Down Expand Up @@ -223,7 +229,7 @@ jobs:
mkdir build_idealgas/
cd build_idealgas/
export AMS_MFEM_PATH=$(spack location -i mfem)
cmake -DCMAKE_CUDA_ARCHITECTURES=70 -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS -DMFEM_DIR=${AMS_MFEM_PATH} $GITHUB_WORKSPACE/examples/ideal_gas/
cmake -DCMAKE_CUDA_ARCHITECTURES=70 -DCMAKE_PREFIX_PATH=${AMS_INSTALL_PATH}/ -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS -DMFEM_DIR=${AMS_MFEM_PATH} $GITHUB_WORKSPACE/examples/ideal_gas/
make -j$(nproc) VERBOSE=1
- name: Install BOptions SharedLibray=${{ matrix.with_shared }}
shell: bash -l {0}
Expand All @@ -233,7 +239,7 @@ jobs:
spack env activate -p /ams-spack-env
mkdir build_bnm_opt/
cd build_bnm_opt/
cmake -DCMAKE_CUDA_ARCHITECTURES=70 -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS $GITHUB_WORKSPACE/examples/bnm_opt/
cmake -DCMAKE_CUDA_ARCHITECTURES=70 -DCMAKE_PREFIX_PATH=${AMS_INSTALL_PATH}/ -DAMS_DIR=${AMS_INSTALL_PATH}/lib64/cmake/AMS $GITHUB_WORKSPACE/examples/bnm_opt/
make -j$(nproc) VERBOSE=1

build-rmq-tests:
Expand All @@ -257,6 +263,8 @@ jobs:
RABBITMQ_PORT: 5672
steps:
- uses: actions/checkout@v4
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Build Torch=On FAISS=On RMQ=On AMS
shell: bash -l {0}
run: |
Expand Down Expand Up @@ -322,7 +330,8 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Install AMS package (editable)
shell: bash -l {0}
run: |
Expand All @@ -340,7 +349,8 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Start MariaDB
shell: bash -l {0}
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- name: Ensure git safe directory
run: git config --global --add safe.directory '*'
- name: Install deps (APT)
run: |
sudo apt-get update
Expand Down
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.18)
project(AMS VERSION 0.1.1 LANGUAGES CXX C)


if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

cmake_policy(SET CMP0074 NEW)

project(AMS VERSION 0.1.1 LANGUAGES CXX C)


# NOTE: This may break some of our integrations with the applications. But flux requires > C++20, RMQ requires C++17 and although AMS does not have
# any restrictions on the CXX standard the application may impose those. The solution would be to compile RMQ with an older GCC version (8) and
# have flux to be an external of the system environment
Expand Down Expand Up @@ -52,6 +59,17 @@ list(APPEND AMS_APP_LIBRARIES nlohmann_json::nlohmann_json)
find_package(Threads REQUIRED)
# ------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
include(cmake/FetchAndAddFmt.cmake)
FetchAndAddFmt("On")
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
include(cmake/FetchAndAddTlExpected.cmake)
FetchAndAddTlExpected("On")
#-------------------------------------------------------------------------------


set(MPI_DIRECTORIES "")
if (WITH_MPI)
find_package(MPI REQUIRED)
Expand Down Expand Up @@ -87,6 +105,7 @@ endif()

if (WITH_AMS_DEBUG)
list(APPEND AMS_APP_DEFINES "LIBAMS_VERBOSE")
list(APPEND AMS_APP_DEFINES "__AMS_DEBUG__")
endif()

if (AMS_HDF5_DIR)
Expand Down
6 changes: 4 additions & 2 deletions cmake/AMSConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/AMSTargets.cmake")

# Expose configuration options with AMS_ prefix
set(AMS_WITH_MPI @WITH_MPI@)
set(AMS_WITH_CUDA @WITH_CUDA@)
Expand All @@ -10,6 +8,9 @@ set(AMS_WITH_HDF5 @WITH_HDF5@)
set(AMS_WITH_RMQ @WITH_RMQ@)
include(CMakeFindDependencyMacro)

find_dependency(fmt)
find_dependency(tl-expected)

if (NOT TARGET Torch)
set(AMS_TORCH_DIR @Torch_DIR@)
if (NOT Torch_DIR)
Expand Down Expand Up @@ -73,4 +74,5 @@ if (AMS_WITH_RMQ)
endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/AMSTargets.cmake")
check_required_components("@PROJECT_NAME@")
41 changes: 41 additions & 0 deletions cmake/FetchAndAddFmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include(FetchContent)
function(FetchAndAddFmt USE_FETCH)
# Normalize input to uppercase (ON/OFF)
string(TOUPPER "${USE_FETCH}" USE_FETCH_UC)

if(USE_FETCH_UC STREQUAL "ON")
message(STATUS "[AMS] Fetching vendored fmt…")
set(FMT_INSTALL ON CACHE BOOL "" FORCE)
set(FMT_DOC OFF CACHE BOOL "" FORCE)
set(FMT_TEST OFF CACHE BOOL "" FORCE)
include(FetchContent)

FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 12.1.0
)

# Actually download + add the subproject
FetchContent_MakeAvailable(fmt)

# fmt creates a target called fmt::fmt
# We export that as-is
message(STATUS "[AMS] Using vendored fmt::fmt")

else()
message(STATUS "[AMS] Looking for system fmt…")

find_package(fmt QUIET)

if(NOT fmt_FOUND)
message(FATAL_ERROR
"[AMS] fmt was not found in the system! "
"Pass ON to FetchAndAddFmt to fetch it automatically."
)
endif()

message(STATUS "[AMS] Using system fmt::fmt")
endif()

endfunction()
22 changes: 22 additions & 0 deletions cmake/FetchAndAddTlExpected.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include(FetchContent)

function(FetchAndAddTlExpected FETCH_TL_EXPECTED)
string(TOUPPER "${FETCH_TL_EXPECTED}" FETCH_TL_EXPECTED_UC)

if(FETCH_TL_EXPECTED_UC STREQUAL "ON")
message(STATUS "AMS: Fetching tl-expected via FetchContent")
# --- IMPORTANT: disable tl-expected's own tests & packaging ---
set(EXPECTED_BUILD_TESTS OFF CACHE BOOL "Disable TlExpected tests" FORCE)
set(EXPECTED_BUILD_PACKAGE OFF CACHE BOOL "Disable TlExpected package" FORCE)
FetchContent_Declare(
tl-expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG v1.3.1
)

FetchContent_MakeAvailable(tl-expected)
else()
message(STATUS "AMS: Using system-provided tl-expected")
find_package(tl-expected REQUIRED)
endif()
endfunction()
3 changes: 2 additions & 1 deletion src/AMSlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# ------------------------------------------------------------------------------
# handle sources and headers
set(AMS_LIB_SRC wf/debug.cpp wf/logger.cpp wf/utils.cpp wf/SmallVector.cpp ml/surrogate.cpp wf/basedb.cpp AMSTensor.cpp wf/interface.cpp wf/resource_manager.cpp AMS.cpp)
set(AMS_LIB_SRC wf/debug.cpp wf/logger.cpp wf/utils.cpp wf/SmallVector.cpp ml/surrogate.cpp wf/basedb.cpp AMSTensor.cpp wf/interface.cpp wf/resource_manager.cpp ml/Model.cpp ml/AbstractModel.cpp AMS.cpp)

list(APPEND AMS_LIB_SRC wf/hdf5db.cpp)

Expand All @@ -28,6 +28,7 @@ target_include_directories(AMS PUBLIC
$<INSTALL_INTERFACE:include>
)

target_link_libraries(AMS PUBLIC fmt::fmt tl::expected)

if (WITH_CUDA)
target_link_libraries(AMS PRIVATE CUDA::cudart)
Expand Down
Loading