diff --git a/CMakeLists.txt b/CMakeLists.txt index 976f72086d3..3eb30947ca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,8 +365,10 @@ macro(opm-simulators_sources_hook) # cuda warns when constxpr functions are used in kernels. # since the entire stl is constexpr ..., we enable relaxed flag set_source_files_properties( + opm/simulators/linalg/gpuistl/GpuBlackoilIntensiveQuantitiesDispatcher.cu tests/gpuistl/test_blackoilfluidstategpu.cu tests/gpuistl/test_gpu_ad.cu + tests/gpuistl/test_gpu_ecl_thermal_law_manager.cu tests/gpuistl/test_gpu_linear_two_phase_material.cu tests/gpuistl/test_gpuPvt.cu tests/gpuistl/test_gpuBlackOilFluidSystem.cu @@ -735,6 +737,7 @@ macro(opm-simulators_targets_hook) SOURCES flow/flow_${OBJ}.cpp ) + simulators_add_target_options(TARGET flow_lib${OBJ}) list(APPEND FLOW_TGTS $) list(APPEND FLOWMODELS_PREFIXED flow_${OBJ}) @@ -775,6 +778,58 @@ macro(opm-simulators_targets_hook) opmsimulators ) + # Flow GPU executables handled separately to avoid making flow dependent on CUDA/HIP + set(FLOW_GPU_MODELS + gpu_gaswater_thermal + ) + + if(CONVERT_CUDA_TO_HIP OR CUDA_FOUND) + + if(CONVERT_CUDA_TO_HIP) + set(EXTENSION "hip") + else() + set(EXTENSION "cu") + endif() + + foreach(OBJ ${FLOW_GPU_MODELS}) + + opm_add_library( + TARGET + flow_lib${OBJ} + TYPE + OBJECT + SOURCES + flow/flow_${OBJ}.${EXTENSION} + ) + + simulators_add_target_options(TARGET flow_lib${OBJ}) + list(APPEND FLOW_GPU_TGTS $) + list(APPEND FLOWMODELS_PREFIXED flow_${OBJ}) + + opm_add_executable( + TARGET + flow_${OBJ} + SOURCES + flow/flow_${OBJ}_main.cpp + $ + $ + LIBRARIES + opmsimulators + ) + endforeach() + + opm_add_executable( + TARGET + flow_gpu + SOURCES + flow/flow_gpu_main.cpp + ${FLOW_GPU_TGTS} + $ + LIBRARIES + opmsimulators + ) + endif() + if(OPM_ENABLE_PYTHON) set_target_properties( flow_libblackoil diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index cc4b74daa90..1588e6233c7 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -338,9 +338,12 @@ if(CUDA_FOUND OR hip_FOUND) ADD_CUDA_OR_HIP_FILE(MAIN_SOURCE_FILES opm/simulators/linalg detail/FlexibleSolverWrapper.cpp) ADD_CUDA_OR_HIP_FILE(MAIN_SOURCE_FILES opm/simulators/linalg FlexibleSolver_gpu_instantiate.cpp) ADD_CUDA_OR_HIP_FILE(MAIN_SOURCE_FILES opm/simulators/linalg PreconditionerFactory_gpu_instantiate.cpp) + ADD_CUDA_OR_HIP_FILE(MAIN_SOURCE_FILES opm/simulators/linalg GpuBlackoilIntensiveQuantitiesDispatcher.cu) # HEADERS + ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg GpuBlackoilIntensiveQuantitiesDispatcher.hpp) + ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg GpuFlowGasWaterEnergyTypeTags.hpp) ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg detail/autotuner.hpp) ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg detail/coloringAndReorderingUtils.hpp) ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg detail/gpu_safe_call.hpp) @@ -567,6 +570,7 @@ if(CUDA_FOUND OR hip_FOUND) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_safe_conversion.cpp) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_solver_adapter.cpp) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_gpu_ad.cu) + ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_gpu_ecl_thermal_law_manager.cu) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_gpu_linear_two_phase_material.cu) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_gpuPvt.cu) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_gpu_smart_pointers.cu) @@ -584,6 +588,7 @@ if(CUDA_FOUND OR hip_FOUND) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_primary_variables_gpu.cu) endif() ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_MiniMatrix.cu) + ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_blackoilintensivequantities_gpu.cu) # Boost < 1.75 + nvcc = trouble in this test if(Boost_VERSION VERSION_GREATER 1.74) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_MiniVector.cu) @@ -592,6 +597,42 @@ if(CUDA_FOUND OR hip_FOUND) if(MPI_FOUND) ADD_CUDA_OR_HIP_FILE(TEST_SOURCE_FILES tests test_GpuOwnerOverlapCopy.cpp) endif() + + # for loop providing the flag --expt-relaxed-constexpr to fix some cuda issues with constexpr + if(NOT CONVERT_CUDA_TO_HIP) + set(CU_FILES_NEEDING_RELAXED_CONSTEXPR + tests/gpuistl/test_gpu_ad.cu + tests/gpuistl/test_gpu_linear_two_phase_material.cu + tests/gpuistl/test_gpuPvt.cu + tests/gpuistl/test_gpuBlackOilFluidSystem.cu + tests/gpuistl/test_GpuSparseMatrix.cu + tests/gpuistl/test_GpuSparseTable.cu + tests/gpuistl/test_blackoilfluidstategpu.cu + flow/flow_gpu_gaswater_thermal.cu + ) + + foreach(file ${CU_FILES_NEEDING_RELAXED_CONSTEXPR}) + set_source_files_properties(${file} + PROPERTIES + COMPILE_FLAGS + "--expt-relaxed-constexpr" + ) + endforeach() + + set(CU_FILES_NEEDING_FPERMISSIVE + tests/gpuistl/test_primary_variables_gpu.cu + ) + + foreach(file ${CU_FILES_NEEDING_FPERMISSIVE}) + # Certain structures in OPM requires the -fpermissive flag to compile with nvcc, + # this enables this for the specific files + set_source_files_properties(${file} + PROPERTIES + COMPILE_FLAGS + "-fpermissive --expt-relaxed-constexpr -Xcompiler=-fpermissive" + ) + endforeach() + endif() endif() if(USE_GPU_BRIDGE) @@ -788,6 +829,9 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/discretization/common/linearizationtype.hh opm/models/discretization/common/restrictprolong.hh opm/models/discretization/common/tpfalinearizer.hh + opm/models/discretization/common/tpfalinearizergpukernels.hh + opm/models/discretization/common/tpfalinearizergpuparams.hh + opm/models/discretization/common/tpfalinearizerstructs.hh opm/models/discretization/common/tpsalinearizer.hpp opm/models/discretization/ecfv/ecfvbaseoutputmodule.hh opm/models/discretization/ecfv/ecfvdiscretization.hh @@ -963,6 +1007,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/FacePropertiesTPSA_impl.hpp opm/simulators/flow/FemCpGridCompat.hpp opm/simulators/flow/FIBlackoilModel.hpp + opm/simulators/flow/SimpleFIBlackOilModel.hpp opm/simulators/flow/FIPContainer.hpp opm/simulators/flow/FlowBaseProblemProperties.hpp opm/simulators/flow/FlowBaseVanguard.hpp @@ -1019,6 +1064,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/SimulatorSerializer.hpp opm/simulators/flow/SolutionContainers.hpp opm/simulators/flow/SubDomain.hpp + opm/simulators/flow/ThermalGasWaterFlowProblem.hpp opm/simulators/flow/TTagFlowProblemTPFA.hpp opm/simulators/flow/TTagFlowProblemTPSA.hpp opm/simulators/flow/TTagFlowProblemGasWater.hpp diff --git a/flow/flow_gpu.hpp b/flow/flow_gpu.hpp new file mode 100644 index 00000000000..89f6b7442d1 --- /dev/null +++ b/flow/flow_gpu.hpp @@ -0,0 +1,79 @@ +/* + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ +#ifndef FLOW_GPU_HPP +#define FLOW_GPU_HPP + +#include +#include +/* + This file extracts typetag declarations that must be present in both the .CU and .HIP + executables for Flow to avoid double maintenance. +*/ + +namespace Opm +{ + +namespace Properties +{ + namespace TTag + { + // FlowGasWaterEnergyProblemGPU is declared in FlowGasWaterEnergyTypeTag.hpp + // (InheritsFrom = FlowGasWaterEnergyProblem). The template below maps it + // to FlowGasWaterEnergyProblemGPUTrue for GPU-storage variants. + + template