Skip to content

Update in simulator#7016

Draft
kjetilly wants to merge 5 commits into
OPM:masterfrom
kjetilly:update_in_simulator
Draft

Update in simulator#7016
kjetilly wants to merge 5 commits into
OPM:masterfrom
kjetilly:update_in_simulator

Conversation

@kjetilly
Copy link
Copy Markdown
Contributor

Draft since some tunups need to be done.

This adds properties on the GPU. It adds GPU specific classes of ElementContext, MaterialLawManager and Problem. However, these are thin classes only meant as "views".

@multitalentloes multitalentloes added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Apr 30, 2026
@kjetilly kjetilly requested a review from Copilot April 30, 2026 19:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an experimental GPU execution path for computing per-cell BlackOil intensive quantities (targeting the CO2STORE gas+water+energy configuration) by adding GPU-friendly “view”/storage classes for the problem, material-law manager, and thermal-law manager, plus a dispatcher that uploads PVs, runs a GPU kernel, and overlays results back onto CPU IQ objects.

Changes:

  • Add GPU dispatcher (GpuBlackoilIntensiveQuantitiesDispatcher) and GPU TypeTags for FlowGasWaterEnergyProblem to run the intensive-quantities update on device.
  • Add GPU-portable “view/buffer” implementations for FlowProblem, ECL material-law manager, and ECL thermal-law manager to support the kernel update path.
  • Expand/adjust GPU utilities and tests (GPU smart pointers, thermal-law manager test, and a large GPU-vs-CPU IQ validation/performance test).

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/very_simple_deck.DATA Adds a small test deck fixture for simulator/GPU-related tests.
tests/gpuistl/test_gpu_smart_pointers.cu Adds tests for new GPU unique_ptr array and managed unique_ptr helpers.
tests/gpuistl/test_gpu_linear_two_phase_material.cu Switches raw cudaMalloc/cudaFree to GPU smart pointers in a test.
tests/gpuistl/test_gpu_ecl_thermal_law_manager.cu New GPU test validating thermal-law manager evaluation matches CPU.
tests/gpuistl/test_blackoilintensivequantities_gpu.cu New end-to-end GPU vs CPU intensive-quantities correctness/perf tests.
opm/simulators/linalg/gpuistl/gpu_smart_pointer.hpp Adds GPU array + managed-memory unique_ptr helpers; adjusts ValueAsPointer constructors.
opm/simulators/linalg/gpuistl/MiniVector.hpp Guards the Dune::FieldVector conversion ctor behind HAVE_DUNE_COMMON.
opm/simulators/linalg/gpuistl/GpuFlowGasWaterEnergyTypeTags.hpp Introduces shared GPU TypeTag overrides for the CO2STORE FlowGasWaterEnergy setup.
opm/simulators/linalg/gpuistl/GpuBlackoilIntensiveQuantitiesDispatcher.hpp Declares the experimental dispatcher API and compile-time support predicate.
opm/simulators/linalg/gpuistl/GpuBlackoilIntensiveQuantitiesDispatcher.cu Implements the dispatcher: convert PVs, upload, run kernel, read back, overlay.
opm/simulators/flow/TemperatureModel.hpp Marks several temperature/energy IQ methods as OPM_HOST_DEVICE for GPU compilation.
opm/simulators/flow/NewTranFluxModule.hpp Replaces host throws with OPM_THROW for GPU-safe compilation.
opm/simulators/flow/GpuFlowProblem.hpp Adds a minimal GPU-compatible “FlowProblem view” holding only IQ-needed data.
opm/simulators/flow/GpuEclThermalLawManager.hpp Adds GPU-portable thermal-law manager builder + copy_to_gpu/make_view.
opm/simulators/flow/GpuEclMaterialLawManager.hpp Adds GPU-portable material-law manager builder + copy_to_gpu/make_view.
opm/simulators/flow/FlowProblemParameters.hpp Adds experimental parameter for enabling GPU property computation.
opm/simulators/flow/FlowProblemParameters.cpp Registers the experimental GPU parameter with CUDA/non-CUDA messaging.
opm/simulators/flow/FlowGasWaterEnergyTypeTag.hpp Extracts the FlowGasWaterEnergyProblem TypeTag into a reusable header.
opm/simulators/flow/FIBlackoilModel.hpp Integrates dispatcher into CPU IQ update flow and adds GPU-only/overlay paths.
opm/models/discretization/common/tpfalinearizer.hh Makes GPU helper functions inline to avoid ODR/link issues.
opm/models/discretization/common/fvbaseelementcontextgpu.hh Adds a GPU-stub ElementContext to satisfy device compilation requirements.
opm/models/common/directionalmobility.hh Marks accessors OPM_HOST_DEVICE and switches to OPM_THROW on invalid index.
opm/models/blackoil/blackoilprimaryvariables.hh Marks setScaledPressure_ OPM_HOST_DEVICE and fixes indentation of a helper.
opm/models/blackoil/blackoilintensivequantities.hh Adds overlay helper and expands GPU TypeTag conversion ctors; adjusts GPU-safe control flow.
opm/models/blackoil/blackoilfoammodules.hh Replaces host throws with OPM_THROW for GPU-safe compilation.
opm/models/blackoil/blackoilenergymodules.hh Broad OPM_HOST_DEVICE annotation and OPM_THROW conversions for GPU compilation paths.
opm/models/blackoil/blackoilbrinemodules.hh Adds OPM_HOST_DEVICE to several methods and converts throws to OPM_THROW.
flowexperimental/BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp Adds OPM_HOST_DEVICE annotations and converts throws to OPM_THROW.
CMakeLists_files.cmake Adds new GPU dispatcher + new headers/tests to build, gated on HIP or CUDA>=13.1.
CMakeLists.txt Defines OPM_HAVE_GPU_BLACKOIL_INTENSIVE_QUANTITIES_DISPATCHER macro and adds new GPU tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread opm/models/common/directionalmobility.hh
Comment thread opm/models/blackoil/blackoilintensivequantities.hh
Comment thread opm/simulators/flow/FIBlackoilModel.hpp
Comment thread opm/simulators/flow/FlowProblemParameters.cpp Outdated
Comment thread opm/simulators/linalg/gpuistl/GpuBlackoilIntensiveQuantitiesDispatcher.hpp Outdated
Comment thread opm/simulators/linalg/gpuistl/GpuFlowGasWaterEnergyTypeTags.hpp Outdated
Comment thread opm/simulators/flow/GpuEclThermalLawManager.hpp Outdated
Comment thread opm/simulators/flow/FIBlackoilModel.hpp Outdated
Comment thread tests/gpuistl/test_blackoilintensivequantities_gpu.cu
Comment thread tests/gpuistl/test_gpu_ecl_thermal_law_manager.cu Outdated
Adds host-side allocator helpers, host/device-decorated raw-pointer
accessors and small additions to MiniVector that the rest of the GPU
intensive-quantities work depends on.  Updates test_gpu_smart_pointers.cu
to cover the new behaviour.
…) use

Decorates inline helpers in blackoil*modules.hh, blackoilprimaryvariables.hh,
directionalmobility.hh, tpfalinearizer.hh, NewTranFluxModule.hpp,
TemperatureModel.hpp and BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp
with OPM_HOST_DEVICE, replaces a few raw `throw`s with OPM_THROW, and
switches static `FluidSystem::` accesses to instance-based
`fluidState.fluidSystem()` / `getFluidSystem()` so the same code works
when the fluid system lives on the device.  Test
test_gpu_linear_two_phase_material.cu picks up the matching template
adjustments.
@kjetilly kjetilly force-pushed the update_in_simulator branch from c963be8 to 71e732c Compare April 30, 2026 21:17
Adds the GPU intensive-quantities dispatcher
(GpuBlackoilIntensiveQuantitiesDispatcher.{hpp,cu}) and the supporting
GpuFlowGasWaterEnergyTypeTags.hpp.  FIBlackoilModel is updated in this
branch (rather than earlier) to consume the dispatcher as the entry
point used to push BlackOilIntensiveQuantities updates to the device.

The .cu translation unit and the OPM_HAVE_GPU_BLACKOIL_INTENSIVE_QUANTITIES_DISPATCHER
macro are gated on HIP or CUDA >= 13.1.
Adds the GPU-side problem and material/thermal law manager headers
(GpuFlowProblem, GpuEclMaterialLawManager, GpuEclThermalLawManager) plus
the matching GPU element-context header (fvbaseelementcontextgpu.hh) and
the FlowGasWaterEnergyTypeTag.hpp typetag.  Wires them through
FlowProblemParameters and adds a Boost test
(test_gpu_ecl_thermal_law_manager.cu) backed by tests/very_simple_deck.DATA.

The new test is gated on HIP or CUDA >= 13.1 in CMakeLists_files.cmake.
Reworks BlackOilIntensiveQuantities so its update path is fully usable
from device code (relaxed-constexpr-friendly storage, host/device-decorated
helpers, moved init helpers).  Adds tests/gpuistl/test_blackoilintensivequantities_gpu.cu
which exercises the GPU update path end-to-end and matches it against the
CPU reference, including derivatives.  The test is gated on HIP or
CUDA >= 13.1.
@kjetilly kjetilly force-pushed the update_in_simulator branch from 71e732c to d17e801 Compare May 3, 2026 19:44
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