Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
spack-packages
Commits
90d80a0b
Commit
90d80a0b
authored
Feb 10, 2026
by
one
Browse files
Add DTK-compatible nekRS
parent
8f764ef0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
172 additions
and
0 deletions
+172
-0
repos/spack_repo/hygon/tsoc/packages/nekrs/package.py
repos/spack_repo/hygon/tsoc/packages/nekrs/package.py
+172
-0
No files found.
repos/spack_repo/hygon/tsoc/packages/nekrs/package.py
0 → 100644
View file @
90d80a0b
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import
os
from
spack_repo.builtin.build_systems
import
cmake
,
generic
from
spack_repo.builtin.build_systems.cmake
import
CMakePackage
from
spack_repo.builtin.build_systems.cuda
import
CudaPackage
from
spack_repo.builtin.build_systems.generic
import
Package
from
spack_repo.builtin.build_systems.rocm
import
ROCmPackage
from
spack.package
import
*
class
Nekrs
(
Package
,
CMakePackage
,
CudaPackage
,
ROCmPackage
):
"""nekRS is an open-source Navier Stokes solver based on the spectral
element method targeting classical processors and hardware accelerators
like GPUs"""
homepage
=
"https://github.com/Nek5000/nekRS"
git
=
"https://github.com/Nek5000/nekRS.git"
url
=
"https://github.com/Nek5000/nekRS/archive/refs/tags/v23.0.tar.gz"
tags
=
[
"cfd"
,
"flow"
,
"hpc"
,
"solver"
,
"navier-stokes"
,
"spectral-elements"
,
"fluid"
,
"ecp"
,
"ecp-apps"
,
]
maintainers
(
"thilinarmtb"
,
"stgeke"
)
license
(
"BSD-3-Clause"
)
build_system
(
conditional
(
"cmake"
,
when
=
"@23.0:"
),
conditional
(
"generic"
,
when
=
"@=21.0"
),
default
=
"cmake"
)
version
(
"23.0"
,
sha256
=
"2cb4ded69551b9614036e1a9d5ac54c8535826eae8f8b6a00ddb89043b2c392a"
)
version
(
"21.0"
,
tag
=
"v21.0"
,
commit
=
"bcd890bf3f9fb4d91224c83aeda75c33570f1eaa"
)
variant
(
"dpcpp"
,
default
=
False
,
description
=
"Enable OCCA SYCL/DPCPP backend"
)
variant
(
"opencl"
,
default
=
False
,
description
=
"Activates support for OpenCL"
)
variant
(
"gpu_mpi"
,
default
=
True
,
description
=
"Enable GPU-aware MPI support"
)
variant
(
"amgx"
,
default
=
False
,
description
=
"Enable NVIDIA AMGX support (requires CUDA)"
)
variant
(
"cvode"
,
default
=
False
,
description
=
"Enable CVODE support"
)
variant
(
"hypre_gpu"
,
default
=
False
,
description
=
"Enable HYPRE GPU support"
)
conflicts
(
"+amgx~cuda"
,
msg
=
"AMGX support requires CUDA"
)
conflicts
(
"+cvode+opencl"
,
msg
=
"CVODE + OpenCL is not supported by nekRS"
)
conflicts
(
"+cvode+dpcpp"
,
msg
=
"CVODE + DPCPP is not supported by nekRS"
)
conflicts
(
"+cvode+rocm"
,
msg
=
"CVODE + HIP/ROCm is not supported by nekRS"
)
# Conflicts:
# nekrs includes following packages, but in order to build as part of
# CEED we can't leave them in as conflicts. They should be enabled
# sometime in future.
# for pkg in ['occa', 'hyper', 'nek5000', 'blas', 'lapack', 'gslib']:
# conflicts('^' + pkg, msg=(pkg + " is built into nekRS"))
# Dependencies
depends_on
(
"c"
,
type
=
"build"
)
# generated
depends_on
(
"cxx"
,
type
=
"build"
)
# generated
depends_on
(
"fortran"
,
type
=
"build"
)
# generated
depends_on
(
"mpi"
)
depends_on
(
"git"
,
type
=
"build"
)
depends_on
(
"cmake@3.18:"
,
type
=
"build"
)
def
patch
(
self
):
with
working_dir
(
"scripts"
):
# Make sure nekmpi wrapper uses srun when we know OpenMPI
# is not built with mpiexec
if
self
.
spec
.
satisfies
(
"^openmpi~legacylaunchers"
):
filter_file
(
r
"mpirun -np"
,
"srun -n"
,
"nrsmpi"
)
filter_file
(
r
"mpirun -np"
,
"srun -n"
,
"nrspre"
)
filter_file
(
r
"mpirun -np"
,
"srun -n"
,
"nrsbmpi"
)
# nekRS upstream writes nekrs.conf into CMAKE_INSTALL_PREFIX at configure
# time, which is not Spack-friendly. Redirect it into the build tree
# and install it normally.
if
self
.
spec
.
satisfies
(
"@23.0:"
):
filter_file
(
r
"\$\{CMAKE_INSTALL_PREFIX\}/nekrs\.conf"
,
r
"${CMAKE_CURRENT_BINARY_DIR}/nekrs.conf"
,
"CMakeLists.txt"
,
)
filter_file
(
r
"file\(MAKE_DIRECTORY \$\{CMAKE_INSTALL_PREFIX\}/3rd_party\)"
,
"install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nekrs.conf DESTINATION .)
\n
"
"install(CODE
\"
file(MAKE_DIRECTORY
\\\"
${CMAKE_INSTALL_PREFIX}/3rd_party
\\\"
)
\"
)"
,
"CMakeLists.txt"
,
)
def
setup_build_environment
(
self
,
env
:
EnvironmentModifications
)
->
None
:
spec
=
self
.
spec
cxxflags
=
spec
.
compiler_flags
.
get
(
"cxxflags"
,
[])
if
cxxflags
:
# Help OCCA pick up user flags (Spack wrappers still add them too).
env
.
set
(
"CXXFLAGS"
,
" "
.
join
(
cxxflags
))
# Make backend availability explicit for deterministic builds.
env
.
set
(
"OCCA_CUDA_ENABLED"
,
"1"
if
"+cuda"
in
spec
else
"0"
)
env
.
set
(
"OCCA_HIP_ENABLED"
,
"1"
if
"+rocm"
in
spec
else
"0"
)
env
.
set
(
"OCCA_OPENCL_ENABLED"
,
"1"
if
"+opencl"
in
spec
else
"0"
)
env
.
set
(
"OCCA_DPCPP_ENABLED"
,
"1"
if
"+dpcpp"
in
spec
else
"0"
)
def
setup_run_environment
(
self
,
env
:
EnvironmentModifications
)
->
None
:
# The 'env' is included in the Spack generated module files.
spec
=
self
.
spec
env
.
set
(
"NEKRS_HOME"
,
self
.
prefix
)
env
.
prepend_path
(
"PATH"
,
self
.
prefix
.
bin
)
env
.
set
(
"OCCA_CXX"
,
self
.
compiler
.
cxx
)
cxxflags
=
spec
.
compiler_flags
.
get
(
"cxxflags"
,
[])
if
cxxflags
:
# Run-time compiler flags:
env
.
set
(
"OCCA_CXXFLAGS"
,
" "
.
join
(
cxxflags
))
if
"+cuda"
in
spec
:
cuda_dir
=
spec
[
"cuda"
].
prefix
# Run-time CUDA compiler:
env
.
set
(
"OCCA_CUDA_COMPILER"
,
join_path
(
cuda_dir
,
"bin"
,
"nvcc"
))
def
setup_dependent_build_environment
(
self
,
env
:
EnvironmentModifications
,
dependent_spec
:
Spec
)
->
None
:
# Export the same runtime settings for dependents built in Spack.
self
.
setup_run_environment
(
env
)
class
GenericBuilder
(
generic
.
GenericBuilder
):
def
install
(
self
,
pkg
,
spec
,
prefix
):
makenrs
=
Executable
(
os
.
path
.
join
(
os
.
getcwd
(),
"makenrs"
))
makenrs
.
add_default_env
(
"NEKRS_INSTALL_DIR"
,
prefix
)
makenrs
.
add_default_env
(
"NEKRS_CC"
,
spec
[
"mpi"
].
mpicc
)
makenrs
.
add_default_env
(
"NEKRS_CXX"
,
spec
[
"mpi"
].
mpicxx
)
makenrs
.
add_default_env
(
"NEKRS_FC"
,
spec
[
"mpi"
].
mpifc
)
makenrs
.
add_default_env
(
"TRAVIS"
,
"true"
)
makenrs
(
output
=
str
,
error
=
str
,
fail_on_error
=
True
)
class
CMakeBuilder
(
cmake
.
CMakeBuilder
):
def
cmake_args
(
self
):
cxxflags
=
self
.
spec
.
compiler_flags
.
get
(
"cxxflags"
,
[])
cxxflags_str
=
" "
.
join
(
cxxflags
)
if
cxxflags
else
""
args
=
[
# Match upstream recommended usage: MPI wrappers for all languages.
self
.
define
(
"CMAKE_C_COMPILER"
,
self
.
spec
[
"mpi"
].
mpicc
),
self
.
define
(
"CMAKE_CXX_COMPILER"
,
self
.
spec
[
"mpi"
].
mpicxx
),
self
.
define
(
"CMAKE_Fortran_COMPILER"
,
self
.
spec
[
"mpi"
].
mpifc
),
self
.
define
(
"NEKRS_COMPILER_FLAGS"
,
cxxflags_str
),
self
.
define
(
"OCCA_CXXFLAGS"
,
cxxflags_str
),
self
.
define_from_variant
(
"ENABLE_CUDA"
,
"cuda"
),
self
.
define_from_variant
(
"ENABLE_OPENCL"
,
"opencl"
),
self
.
define_from_variant
(
"ENABLE_HIP"
,
"rocm"
),
self
.
define_from_variant
(
"ENABLE_DPCPP"
,
"dpcpp"
),
self
.
define_from_variant
(
"NEKRS_GPU_MPI"
,
"gpu_mpi"
),
self
.
define_from_variant
(
"ENABLE_AMGX"
,
"amgx"
),
self
.
define_from_variant
(
"ENABLE_CVODE"
,
"cvode"
),
self
.
define_from_variant
(
"ENABLE_HYPRE_GPU"
,
"hypre_gpu"
),
]
return
args
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment