diff --git a/.github/workflows/build-foam.yml b/.github/workflows/build-foam.yml index a0284d057..b7ad85d26 100644 --- a/.github/workflows/build-foam.yml +++ b/.github/workflows/build-foam.yml @@ -69,6 +69,12 @@ jobs: key: build_PR_${{ github.event.pull_request.number }}_${{matrix.OF.path}} path: ${{github.workspace}}/build + - name: Cache FOAM_USER_LIBBIN + uses: actions/cache@v4 + with: + key: FOAM_USER_LIBBIN-${{ matrix.OF.path }}-${{ github.sha }} + path: ${{matrix.OF.foam_user_libbin}} + - name: Configure CMake # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system @@ -76,29 +82,19 @@ jobs: run: | source /root/OpenFOAM/${{matrix.OF.path}}/etc/bashrc mkdir -p ${{matrix.OF.foam_user_libbin}} - mkdir -p build - cd build - [ -d "/github/home/$GINKGO_CHECKOUT_VERSION" ] && cp -rp /github/home/$GINKGO_CHECKOUT_VERSION third_party - cmake -GNinja \ - -DOGL_ALLOW_REFERENCE_ONLY=On \ - -DOGL_BUILD_UNITTEST=ON \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DCMAKE_INSTALL_PREFIX=${{matrix.OF.foam_user_libbin}} .. + cmake --preset develop - name: Build OGL - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}} run: | source /root/OpenFOAM/${{matrix.OF.path}}/etc/bashrc - cmake --build . --config $BUILD_TYPE + cmake --build --preset develop - name: Install OGL working-directory: ${{github.workspace}} run: | source /root/OpenFOAM/${{matrix.OF.path}}/etc/bashrc - cmake --install ./build - ls $FOAM_USER_LIBBIN - ls ${{matrix.OF.foam_user_libbin}} - + cmake --build --preset develop --target install - name: Check folders working-directory: ${{github.workspace}} diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 85defba69..01e1a89d5 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -89,7 +89,7 @@ jobs: export LD_LIBRARY_PATH=$FOAM_USER_LIBBIN:$WM_PROJECT_DIR/platforms/linux64GccDPInt32Opt/lib:$WM_PROJECT_DIR/platforms/linux64GccDPInt32Opt/lib/sys-openmpi/:$WM_PROJECT_DIR/platforms/linux64GccDPInt32Opt/lib/openmpi-system:$WM_PROJECT_DIR/platforms/linux64GccDPInt32Opt/lib/dummy/:$LD_LIBRARY_PATH mkdir -p integration && cd integration export CYCLIC_CASE=${{inputs.cyclic_case}} - obr init -gy --config /__w/OGL/OGL/test/integration.yaml + obr init -g --config /__w/OGL/OGL/test/integration.yaml cat workspace/*/case/*log setup_integration_matrix: @@ -128,7 +128,7 @@ jobs: - name: Get Ginkgo checkout version shell: bash run: | - grep -A1 "set(GINKGO_CHECKOUT_VERSION" CMakeLists.txt|tail -n1|grep -o "[0-9a-z\-]*" > GINKGO_CHECKOUT_VERSION + grep -A1 "set(GINKGO_CHECKOUT_VERSION" CMakeLists.txt|tail -n1|grep -o "[0-9a-z\-_.]*" > GINKGO_CHECKOUT_VERSION export GINKGO_CHECKOUT_VERSION=$(cat GINKGO_CHECKOUT_VERSION) echo "GINKGO_CHECKOUT_VERSION=$GINKGO_CHECKOUT_VERSION" >> $GITHUB_ENV echo "Ginkgo_DIR=${{inputs.foam_user_libbin}}/cmake/Ginkgo" >> $GITHUB_ENV diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index df3424044..f5fb4eb28 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -37,10 +37,10 @@ jobs: - name: Create Compilation Database run: | source /root/OpenFOAM/openfoam/etc/bashrc - cmake --preset ninja-cpuonly-release \ + cmake --preset develop \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - cmake --build --preset ninja-cpuonly-release + cmake --build --preset develop - uses: actions/upload-artifact@v4 with: name: build-artifact diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b0faf17b3..6ca823c82 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -33,8 +33,9 @@ jobs: - uses: actions/checkout@v4 - name: Get Ginkgo checkout version + shell: bash run: | - grep -A1 "set(GINKGO_CHECKOUT_VERSION" CMakeLists.txt|tail -n1|grep -o "[0-9a-z\-]*" > GINKGO_CHECKOUT_VERSION + grep -A1 "set(GINKGO_CHECKOUT_VERSION" CMakeLists.txt|tail -n1|grep -o "[0-9a-z\-_.]*" > GINKGO_CHECKOUT_VERSION export GINKGO_CHECKOUT_VERSION=$(cat GINKGO_CHECKOUT_VERSION) echo "GINKGO_CHECKOUT_VERSION=$GINKGO_CHECKOUT_VERSION" >> $GITHUB_ENV @@ -48,13 +49,13 @@ jobs: - name: Cache build folder uses: actions/cache@v4 with: - key: build-${{ inputs.path }}-${{env.GINKGO_CHECKOUT_VERSION}} + # key: build-${{ inputs.path }}-${{env.GINKGO_CHECKOUT_VERSION}} + key: build_PR_${{ github.event.pull_request.number }}_${{inputs.path}} path: | ${{github.workspace}}/build - name: Test OGL - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}} run: | source /root/OpenFOAM/${{inputs.path}}/etc/bashrc - ls $FOAM_USER_LIBBIN - ./unitTests/matrixConversion + ctest --preset develop diff --git a/CMakePresets.json b/CMakePresets.json index 401b50010..2659bf43c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -84,6 +84,18 @@ "configuration": "Develop" } ], + "testPresets": [ + { + "name": "debug", + "configurePreset": "debug", + "configuration": "Release" + }, + { + "name": "develop", + "configurePreset": "develop", + "configuration": "Develop" + } + ], "workflowPresets": [ { "name": "release", diff --git a/include/OGL/CommunicationPattern.H b/include/OGL/CommunicationPattern.H index c3d12ee79..356e0fe18 100644 --- a/include/OGL/CommunicationPattern.H +++ b/include/OGL/CommunicationPattern.H @@ -142,7 +142,7 @@ struct CommunicationPattern { send_idxs(send_idxs_) { // every communication ranks needs a set of send_idxs associated - ASSERT_EQ(ranks.size(), send_idxs_.size()); + OGL_ASSERT_EQ(ranks.size(), send_idxs_.size()); for (auto &rows : send_idxs) { target_sizes.push_back(rows.size()); diff --git a/include/OGL/DevicePersistent/Base.H b/include/OGL/DevicePersistent/Base.H index 4c587a1ea..52e42ca58 100644 --- a/include/OGL/DevicePersistent/Base.H +++ b/include/OGL/DevicePersistent/Base.H @@ -38,7 +38,7 @@ public: /* Base class for storing ginkgo and OGL data structures in the Objectregistry * - * This class creates an unitialised Ginkgo array and copies the + * This class creates an uninitialised Ginkgo array and copies the * shared ptr to the DevicePersistentBase. This will prevent it from * being deleted when leaving the scope. * diff --git a/include/OGL/MatrixWrapper/Distributed.H b/include/OGL/MatrixWrapper/Distributed.H index 89066abe5..78e30a81b 100644 --- a/include/OGL/MatrixWrapper/Distributed.H +++ b/include/OGL/MatrixWrapper/Distributed.H @@ -51,15 +51,14 @@ public: return this->dist_mtx_->get_non_local_matrix(); } - template std::shared_ptr get_local() const { if (repartitioner_->get_fused()) { return dist_mtx_->get_local_matrix(); } else { - return gko::as(gko::as>( - dist_mtx_->get_local_matrix()) - ->get_operators()[0]); + return gko::as>( + dist_mtx_->get_local_matrix()) + ->get_operators()[0]; } } diff --git a/include/OGL/MatrixWrapper/SparsityPattern.H b/include/OGL/MatrixWrapper/SparsityPattern.H index 70db234da..682b252d0 100644 --- a/include/OGL/MatrixWrapper/SparsityPattern.H +++ b/include/OGL/MatrixWrapper/SparsityPattern.H @@ -53,8 +53,8 @@ struct SparsityPattern { dim(dim_), spans(spans_) { - ASSERT_EQ(rows.size(), cols.size()); - ASSERT_EQ(rows.size(), mapping.size()); + OGL_ASSERT_EQ(rows.size(), cols.size()); + OGL_ASSERT_EQ(rows.size(), mapping.size()); } SparsityPattern(std::shared_ptr exec) @@ -85,16 +85,16 @@ struct SparsityPattern { ldu_mapping{exec, static_cast(size)}, dim(dim) { - ASSERT_EQ(static_cast(size), rows.size()); + OGL_ASSERT_EQ(static_cast(size), rows.size()); std::copy(rows.begin(), rows.end(), row_idxs.get_data()); - ASSERT_EQ(static_cast(size), cols.size()); + OGL_ASSERT_EQ(static_cast(size), cols.size()); std::copy(cols.begin(), cols.end(), col_idxs.get_data()); - ASSERT_EQ(static_cast(size), map.size()); + OGL_ASSERT_EQ(static_cast(size), map.size()); std::copy(map.begin(), map.end(), ldu_mapping.get_data()); - ASSERT_EQ(spans_begin.size(), spans_end.size()); + OGL_ASSERT_EQ(spans_begin.size(), spans_end.size()); std::transform(spans_begin.begin(), spans_begin.end(), spans_end.begin(), std::back_inserter(spans), [](const auto begin, const auto end) { diff --git a/include/OGL/Preconditioner.H b/include/OGL/Preconditioner.H index dcdf22f3a..3cd838880 100644 --- a/include/OGL/Preconditioner.H +++ b/include/OGL/Preconditioner.H @@ -51,7 +51,7 @@ public: std::shared_ptr device_exec, std::unique_ptr precond) const { - auto local = get_local(gkomatrix); + auto local = gko::as(gkomatrix)->get_local(); return gko::share( ras::build() .with_generated_local_solver( diff --git a/include/OGL/common.H b/include/OGL/common.H index bb1d26265..3e57e3eab 100644 --- a/include/OGL/common.H +++ b/include/OGL/common.H @@ -90,7 +90,7 @@ namespace Foam { #define UNUSED(x) (void)(x) -#define ASSERT_EQ(_val1, _val2) \ +#define OGL_ASSERT_EQ(_val1, _val2) \ if (_val1 != _val2) { \ FatalErrorInFunction << "Expected equal values: " << _val1 << " and " \ << _val2 << abort(FatalError); \ diff --git a/src/CommunicationPattern.C b/src/CommunicationPattern.C index 63670ad7a..1a4a8a0dc 100644 --- a/src/CommunicationPattern.C +++ b/src/CommunicationPattern.C @@ -70,7 +70,7 @@ AllToAllPattern compute_gather_to_owner_counts( auto exec = exec_handler.get_device_exec(); auto comm = *exec_handler.get_communicator().get(); - ASSERT_EQ(total_size, size + padding_before + padding_after); + OGL_ASSERT_EQ(total_size, size + padding_before + padding_after); label total_ranks{comm.size()}; label rank{comm.rank()}; label owner_rank = compute_owner_rank(rank, ranks_per_owner); @@ -161,26 +161,24 @@ void communicate_values( const AllToAllPattern &comm_pattern, const scalar *send_buffer, scalar *recv_buffer, bool force_host_buffer, label recv_buffer_size) { - if (force_host_buffer && src_exec != target_exec) { - auto tmp = - gko::array(src_exec, recv_buffer_size); + if (force_host_buffer && src_exec != target_exec) { + auto tmp = gko::array(src_exec, recv_buffer_size); - comm->all_to_all_v(src_exec, send_buffer, - comm_pattern.send_counts.data(), - comm_pattern.send_offsets.data(), tmp.get_data(), - comm_pattern.recv_counts.data(), - comm_pattern.recv_offsets.data()); + comm->all_to_all_v( + src_exec, send_buffer, comm_pattern.send_counts.data(), + comm_pattern.send_offsets.data(), tmp.get_data(), + comm_pattern.recv_counts.data(), comm_pattern.recv_offsets.data()); - auto recv_view = gko::array::view( - target_exec, recv_buffer_size, recv_buffer); + auto recv_view = gko::array::view(target_exec, recv_buffer_size, + recv_buffer); - recv_view = tmp; - } else { + recv_view = tmp; + } else { comm->all_to_all_v( target_exec, send_buffer, comm_pattern.send_counts.data(), comm_pattern.send_offsets.data(), recv_buffer, comm_pattern.recv_counts.data(), comm_pattern.recv_offsets.data()); - } + } } std::vector