Update in simulator#7016
Draft
kjetilly wants to merge 5 commits into
Draft
Conversation
There was a problem hiding this comment.
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.
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.
c963be8 to
71e732c
Compare
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.
71e732c to
d17e801
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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".