Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fused repartitioned 2D cases #154

Merged
merged 12 commits into from
Oct 10, 2024
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
24 changes: 10 additions & 14 deletions .github/workflows/build-foam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,32 @@ 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
working-directory: ${{github.workspace}}
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}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
12 changes: 12 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
"configuration": "Develop"
}
],
"testPresets": [
{
"name": "debug",
"configurePreset": "debug",
"configuration": "Release"
},
{
"name": "develop",
"configurePreset": "develop",
"configuration": "Develop"
}
],
"workflowPresets": [
{
"name": "release",
Expand Down
2 changes: 1 addition & 1 deletion include/OGL/CommunicationPattern.H
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion include/OGL/DevicePersistent/Base.H
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 3 additions & 4 deletions include/OGL/MatrixWrapper/Distributed.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ public:
return this->dist_mtx_->get_non_local_matrix();
}

template <typename InnerType>
std::shared_ptr<const gko::LinOp> get_local() const
{
if (repartitioner_->get_fused()) {
return dist_mtx_->get_local_matrix();
} else {
return gko::as<InnerType>(gko::as<CombinationMatrix<InnerType>>(
dist_mtx_->get_local_matrix())
->get_operators()[0]);
return gko::as<CombinationMatrix<gko::LinOp>>(
dist_mtx_->get_local_matrix())
->get_operators()[0];
}
}

Expand Down
12 changes: 6 additions & 6 deletions include/OGL/MatrixWrapper/SparsityPattern.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<const gko::Executor> exec)
Expand Down Expand Up @@ -85,16 +85,16 @@ struct SparsityPattern {
ldu_mapping{exec, static_cast<gko::size_type>(size)},
dim(dim)
{
ASSERT_EQ(static_cast<size_t>(size), rows.size());
OGL_ASSERT_EQ(static_cast<size_t>(size), rows.size());
std::copy(rows.begin(), rows.end(), row_idxs.get_data());

ASSERT_EQ(static_cast<size_t>(size), cols.size());
OGL_ASSERT_EQ(static_cast<size_t>(size), cols.size());
std::copy(cols.begin(), cols.end(), col_idxs.get_data());

ASSERT_EQ(static_cast<size_t>(size), map.size());
OGL_ASSERT_EQ(static_cast<size_t>(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) {
Expand Down
2 changes: 1 addition & 1 deletion include/OGL/Preconditioner.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public:
std::shared_ptr<gko::Executor> device_exec,
std::unique_ptr<PrecondFactory> precond) const
{
auto local = get_local(gkomatrix);
auto local = gko::as<RepartDistMatrix>(gkomatrix)->get_local();
return gko::share(
ras::build()
.with_generated_local_solver(
Expand Down
2 changes: 1 addition & 1 deletion include/OGL/common.H
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
26 changes: 12 additions & 14 deletions src/CommunicationPattern.C
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<scalar>(src_exec, recv_buffer_size);
if (force_host_buffer && src_exec != target_exec) {
auto tmp = gko::array<scalar>(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<scalar>::view(
target_exec, recv_buffer_size, recv_buffer);
auto recv_view = gko::array<scalar>::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<label> gather_labels_to_owner(const ExecutorHandler &exec_handler,
Expand Down
3 changes: 2 additions & 1 deletion src/DevicePersistent/DistributedMatrixAdapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace Foam {

// to store the std::shared_ptr<T> in the IO registry the type needs to be
// declared
defineTemplateTypeNameWithName(DevicePersistentBase<RepartDistMatrix>, "PersistentDistributedMatrix");
defineTemplateTypeNameWithName(DevicePersistentBase<RepartDistMatrix>,
"PersistentDistributedMatrix");
} // namespace Foam
Loading
Loading