Skip to content

GPU Properties POC - #5131

Merged
kjetilly merged 10 commits into
OPM:masterfrom
multitalentloes:full_gpu_sim_v1
Sep 23, 2026
Merged

kjetilly merged 10 commits into
OPM:masterfrom
multitalentloes:full_gpu_sim_v1

Conversation

@multitalentloes

Copy link
Copy Markdown
Member

Contains code changes in OPM-common to support SPE11 types simulations with property and assembly computations on GPU. Main PR: OPM/opm-simulators#7018

kjetilly and others added 2 commits August 6, 2026 09:58
GPU portability: add OPM_HOST_DEVICE/OPM_THROW and refresh BlackOilFluidSystem singleton

- Add OPM_HOST_DEVICE annotations and convert raw `throw` sites to OPM_THROW in
  Evaluation, DynamicEvaluation, BlackOilFluidState, BlackOilFluidSystem and
  the BrineCo2/Co2Gas/NullOil PVT classes.
- Refresh BlackOilFluidSystem_macrotemplate's getNonStaticInstance() so the
  non-static singleton mirrors the current static state after every getInstance()
  call (fixes stale PVT/density tables seen by the GPU intensive-quantities path).
- Add a small `mixingEnergy()` constexpr probe and an
  `inverseFormationVolumeFactorAndViscosity` helper used by GPU code.
- Update bin/genEvalSpecializations.py so generated Evaluation*.hpp pick up
  ErrorMacros.hpp.

CopyablePtr: GPU-friendly storage and host/device decorations

Extends `CopyablePtr` so it can be used both as a plain CPU smart pointer and as a
GPU-side handle (host/device-decorated accessors, allocator-aware construction,
explicit raw-pointer access for kernels). The behaviour on the host is unchanged.

Add missing decorator
Add polymorphism check to enforce commented warning

remove unneeded header

remove diff

improve robustness and formatting

remove checks per cell

add todo

finish rebasing

add more rebasing stuff

GPU assembly support on AMD and CUDA

minor fix

fix rebasing issues

remove duplicate include

remove unneeded templated struct

re-add removed comment

make the gpueclmateriallawmanager store tables per region

avoid simulators includes

remove unneeded gpu decorators
@multitalentloes
multitalentloes marked this pull request as ready for review August 7, 2026 11:14
@kjetilly
kjetilly requested a balanced review from Copilot September 12, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

CPU-only compilation, bounds safety, unsupported curve handling, API compatibility, and avoidable GPU-copy issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds GPU-compatible material and thermal-law infrastructure for SPE11 simulations.

Changes:

  • Adds GPU-owning/view managers for material and thermal properties.
  • Makes SPECROCK, THCONR, and tabulated interpolation GPU-compatible.
  • Exposes CPU manager data and registers new public headers.
File summaries
File Description
CMakeLists_files.cmake Registers GPU manager headers.
BlackOilFluidSystem_macrotemplate.hpp Adjusts storage construction.
GpuEclMaterialLawManager.hpp Adds GPU material-law manager.
PiecewiseLinearTwoPhaseMaterial.hpp Makes errors GPU-compatible.
Tabulated1DFunction.cpp Updates templated instantiations.
Tabulated1DFunction.hpp Adds configurable GPU storage.
EclSpecrockLaw.hpp Enables device-side evaluation.
EclSpecrockLawParams.hpp Adds GPU-backed SPECROCK parameters.
EclThconrLaw.hpp Enables device-side conductivity evaluation.
EclThermalLawManager.hpp Exposes thermal-manager configuration.
GpuEclThermalLawManager.hpp Adds GPU thermal-law manager.
Review details

Suppressed comments (2)

opm/material/thermal/GpuEclThermalLawManager.hpp:386

  • The namespace is opened outside #if HAVE_CUDA, but its closing brace is removed when CUDA is disabled. Including this public header in a CPU-only build therefore leaves Opm::gpuistl unclosed and breaks parsing of the including translation unit.
} // namespace Opm::gpuistl

#endif // HAVE_CUDA

opm/material/fluidmatrixinteractions/GpuEclMaterialLawManager.hpp:531

  • The namespace is opened before the CUDA guard but closed inside it. With HAVE_CUDA == 0, preprocessing removes the closing brace and this public header leaves the including source inside Opm::gpuistl.
} // namespace Opm::gpuistl

#endif // HAVE_CUDA
  • Files reviewed: 11/11 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opm/material/fluidmatrixinteractions/GpuEclMaterialLawManager.hpp
Comment thread opm/material/fluidmatrixinteractions/GpuEclMaterialLawManager.hpp
Comment thread opm/material/thermal/EclThconrLaw.hpp
Comment thread opm/material/thermal/GpuEclThermalLawManager.hpp Outdated
Comment on lines +214 to +216
, referenceDensity_(Storage<std::array<Scalar, 3>>(_referenceDensity_))
, molarMass_(Storage<std::array<Scalar, 3>>(_molarMass_))
, diffusionCoefficients_(Storage<std::array<Scalar, 3 * 3>>(_diffusionCoefficients_))
Comment thread opm/material/thermal/EclSpecrockLawParams.hpp
@kjetilly

Copy link
Copy Markdown
Contributor

jenkins build this opm-simulators=7018 serial rocm hipify please

@multitalentloes

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7018 serial rocm hipify please

@multitalentloes multitalentloes changed the title GPU simulation POC GPU Properties POC Sep 18, 2026
@multitalentloes

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7018 serial rocm hipify please

1 similar comment
@multitalentloes

Copy link
Copy Markdown
Member Author

jenkins build this opm-simulators=7018 serial rocm hipify please

@kjetilly
kjetilly merged commit 930440a into OPM:master Sep 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants