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

Activate foam extend build #93

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
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
7 changes: 0 additions & 7 deletions .github/workflows/build-foam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ jobs:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }}
# ,
# {
# version: "5.0",
# fork: "extend",
# path: "foam-extend-5.0",
# repo: "git://git.code.sf.net/p/foam-extend/foam-extend-5.0"
# }

steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test_matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"path": "OpenFOAM-10",
"repo": "https://github.com/OpenFOAM/OpenFOAM-10.git",
"cyclic_case": "LES/channel395"
}
},
{
"version": "5.0",
"fork": "extend",
"path": "foam-extend-5.0",
"repo": "git://git.code.sf.net/p/foam-extend/foam-extend-5.0",
"cyclic_case": "LES/channel395"
}
]
}
50 changes: 29 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ option(GINKGO_BUILD_HIP "Build Ginkgo with hip backend" FALSE)
option(GINKGO_BUILD_SYCL "Build Ginkgo with sycl backend" FALSE)
option(GINKGO_BUILD_OMP "Build Ginkgo with omp backend" FALSE)
option(GINKGO_BUILD_REFERENCE "Build Ginkgo with reference backend" TRUE)
option(OGL_ALLOW_REFERENCE_ONLY "Enable builds of Ginkgo with reference backend only" FALSE)
option(OGL_ALLOW_REFERENCE_ONLY
"Enable builds of Ginkgo with reference backend only" FALSE)
option(GINKGO_FORCE_GPU_AWARE_MPI "Build Ginkgo using device aware MPI" TRUE)
option(GINKGO_WITH_OGL_EXTENSIONS "Whether ginkgo was build with OGL extension"
FALSE)

if(NOT OGL_ALLOW_REFERENCE_ONLY)
if ((NOT GINKGO_BUILD_CUDA) AND (NOT GINKGO_BUILD_HIP) AND (NOT GINKGO_BUILD_SYCL))
message(FATAL_ERROR "No GPU Backend was selected, set either:\n -DGINKGO_BUILD_CUDA=True\n -DGINKGO_BUILD_HIP=True\n -DGINKGO_BUILD_SYCL=True\n or set:\n -DOGL_ALLOW_REFERENCE_ONLY=True\n to turn off this check")
endif()
if((NOT GINKGO_BUILD_CUDA)
AND (NOT GINKGO_BUILD_HIP)
AND (NOT GINKGO_BUILD_SYCL))
message(
FATAL_ERROR
"No GPU Backend was selected, set either:\n -DGINKGO_BUILD_CUDA=True\n -DGINKGO_BUILD_HIP=True\n -DGINKGO_BUILD_SYCL=True\n or set:\n -DOGL_ALLOW_REFERENCE_ONLY=True\n to turn off this check"
)
endif()
endif()

set(GINKGO_CHECKOUT_VERSION
Expand Down Expand Up @@ -63,7 +69,7 @@ if(NOT ${OGL_USE_EXTERNAL_GINKGO})
${CMAKE_CURRENT_BINARY_DIR}/third_party/ginkgo/build/install/lib/cmake)
endif()

# C++ 14 standard or later is required to interface with ginkgo
# C++ 14 standard or later is required to interface with ginkgo
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand All @@ -89,8 +95,8 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
-Rpass=loop-vectorize \
-ffast-math \
"
#- Rpass-analysis=loop-vectorize -Rpass-missed=loop-vectorize
)
# * Rpass-analysis=loop-vectorize -Rpass-missed=loop-vectorize
)

elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
add_definitions(-DWITH_GNU)
Expand All @@ -100,7 +106,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
--coverage\
-fprofile-arcs \
-ggdb3")
#- fsanitize = address \ - ftest - coverage \
# * fsanitize = address \ - ftest - coverage \

set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} \
Expand All @@ -124,9 +130,9 @@ else()
add_compile_definitions(linux64)
endif()

#Add a custom command that produces version.cpp, plus a dummy output that's not
# actually produced, in order to always force re-run version.cmake before
#the build
# Add a custom command that produces version.cpp, plus a dummy output that's not
# actually produced, in order to always force re-run version.cmake before the
# build
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.C
${CMAKE_CURRENT_BINARY_DIR}/_version.C
Expand All @@ -153,9 +159,9 @@ target_sources(
HostMatrix/HostMatrix.C
Solver/CG/GKOCG.C
Solver/BiCGStab/GKOBiCGStab.C
#Solver / IR / GKOIR.C Solver / Multigrid / GKOMultigrid.C
# Solver / IR / GKOIR.C Solver / Multigrid / GKOMultigrid.C
Solver/GMRES/GKOGMRES.C
#LduMatrix / GKOACG / GKOACG.C
# LduMatrix / GKOACG / GKOACG.C
PUBLIC common/common.H
StoppingCriterion/StoppingCriterion.H
lduLduBase/lduLduBase.H
Expand All @@ -173,20 +179,17 @@ target_sources(
BaseWrapper/CoupledLduBase/GKOCoupledLduBase.H
Solver/CG/GKOCG.H
Solver/IR/GKOIR.H
#Solver / Multigrid / GKOMultigrid.H
# Solver / Multigrid / GKOMultigrid.H
Solver/BiCGStab/GKOBiCGStab.H
Solver/GMRES/GKOGMRES.H
#LduMatrix / GKOACG / GKOACG.H
)
# LduMatrix / GKOACG / GKOACG.H
)

target_include_directories(
OGL SYSTEM
PRIVATE $ENV{FOAM_SRC}/finiteVolume/lnInclude
$ENV{FOAM_SRC}/meshTools/lnInclude
$ENV{FOAM_SRC}/OpenFOAM/lnInclude
$ENV{FOAM_SRC}/OSspecific/POSIX/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
)
$ENV{FOAM_SRC}/meshTools/lnInclude $ENV{FOAM_SRC}/OpenFOAM/lnInclude
$ENV{FOAM_SRC}/OSspecific/POSIX/lnInclude ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(OGL PUBLIC Ginkgo::ginkgo)

Expand All @@ -206,4 +209,9 @@ if(EXISTS $ENV{WM_PROJECT_DIR}/CONTRIBUTORS.md)
target_compile_definitions(OGL PRIVATE WITH_ESI_VERSION=1)
endif()

if(EXISTS $ENV{WM_PROJECT_DIR}/src/foam)
target_compile_definitions(OGL PRIVATE WITH_EXTEND_VERSION=1)
target_include_directories(OGL SYSTEM PRIVATE $ENV{FOAM_SRC}/foam/lnInclude)
endif()

install(TARGETS OGL DESTINATION $ENV{FOAM_USER_LIBBIN})
13 changes: 13 additions & 0 deletions DevicePersistent/Base/Base.H
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public:
word msg = "reading " + name_ + " from registry";
MLOG_1(verbose_, msg)

#ifdef WITH_EXTEND_VERSION
if (update) {
persistent_object_ =
db_.lookupObject<DevicePersistentBase<T>>(name_).get_ptr();

TIME_WITH_FIELDNAME(verbose_, call_update, name_,
f.update(persistent_object_);)
} else {
persistent_object_ =
db_.lookupObject<DevicePersistentBase<T>>(name_).get_ptr();
}
#else
if (update) {
persistent_object_ =
db_.lookupObjectRef<DevicePersistentBase<T>>(name_)
Expand All @@ -117,6 +129,7 @@ public:
db_.lookupObjectRef<DevicePersistentBase<T>>(name_)
.get_ptr();
}
#endif

} else {
word msg = "initialising " + name_;
Expand Down
16 changes: 16 additions & 0 deletions HostMatrix/HostMatrix.H
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,19 @@ public:
permutation_matrix_name_{"PermutationMatrix"},
permutation_stored_{
db.template foundObject<regIOobject>(permutation_matrix_name_)},
#ifdef WITH_EXTEND_VERSION
P_{(permutation_stored_)
? db.template lookupObject<DevicePersistentBase<gko::LinOp>>(
permutation_matrix_name_)
.get_ptr()
: nullptr}
#else
P_{(permutation_stored_) ? db.template lookupObjectRef<
DevicePersistentBase<gko::LinOp>>(
permutation_matrix_name_)
.get_ptr()
: nullptr}
#endif
{
if (!local_sparsity_.col_idxs_.get_stored() ||
local_sparsity_.col_idxs_.get_update()) {
Expand Down Expand Up @@ -286,11 +294,19 @@ public:
permutation_matrix_name_{"PermutationMatrix"},
permutation_stored_{
db.template foundObject<regIOobject>(permutation_matrix_name_)},
#ifdef WITH_EXTEND_VERSION
P_{(permutation_stored_)
? db.template lookupObject<DevicePersistentBase<gko::LinOp>>(
permutation_matrix_name_)
.get_ptr()
: nullptr}
#else
P_{(permutation_stored_) ? db.template lookupObjectRef<
DevicePersistentBase<gko::LinOp>>(
permutation_matrix_name_)
.get_ptr()
: nullptr}
#endif
{
// TODO reimplement this
}
Expand Down
13 changes: 13 additions & 0 deletions Preconditioner/Preconditioner.H
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,26 @@ public:
cache = cache - 1;

set_next_caching(sys_matrix_name_, db_, cache--);
#ifdef WITH_EXTEND_VERSION
return db_
.template lookupObject<DevicePersistentBase<gko::LinOp>>(
precond_store_name)
.get_ptr();
#else
return db_
.template lookupObjectRef<DevicePersistentBase<gko::LinOp>>(
precond_store_name)
.get_ptr();
#endif
} else {
#ifdef WITH_EXTEND_VERSION
auto prev_precond =
db_.template lookupObject<DevicePersistentBase<gko::LinOp>>(
precond_store_name);
#else
auto prev_precond = db_.template lookupObjectRef<
DevicePersistentBase<gko::LinOp>>(precond_store_name);
#endif
const label caching_period =
controls.lookupOrDefault<label>("caching", 0);
set_next_caching(sys_matrix_name_, db_, caching_period);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OGL has the following requirements
See also [ginkgo's](https://github.com/ginkgo-project/ginkgo) documentation for additional requirements.

![build](https://github.com/hpsim/OGL/actions/workflows/build-foam.yml/badge.svg)
![OF versions](https://img.shields.io/badge/OF--versions-v2212%2C10-green)
![OF versions](https://img.shields.io/badge/OF--versions-v2212%2C10%2C5.0-green)
![Documentation](https://codedocs.xyz/hpsim/OGL/)

## Compilation
Expand Down
7 changes: 7 additions & 0 deletions common/common.C
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ void set_gko_solver_property(word sys_matrix_name, const objectRegistry &db,
{
const word solvPropsDict = sys_matrix_name + "_gkoSolverProperties";
if (db.foundObject<regIOobject>(solvPropsDict)) {
#ifdef WITH_EXTEND_VERSION
const IOdictionary &dict =
const_cast<objectRegistry &>(db).lookupObject<IOdictionary>(
solvPropsDict);
const_cast<IOdictionary &>(dict).set<label>(key, value);
#else
const_cast<objectRegistry &>(db)
.lookupObjectRef<IOdictionary>(solvPropsDict)
.set<label>(key, value);
#endif
} else {
auto gkoSolverProperties =
new IOdictionary(IOobject(solvPropsDict, fileName("None"), db,
Expand Down
2 changes: 1 addition & 1 deletion lduLduBase/lduLduBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public:
}

return solverPerf;
};
}
};
} // namespace Foam

Expand Down
Loading