tlestang / heatcompact3d

3D heat equation with 6th order compact schemes
https://tlestang.github.io/heatcompact3d/
GNU General Public License v3.0
0 stars 1 forks source link

Add cuda based implementation and build for field rhs computation #9

Closed tlestang closed 1 year ago

tlestang commented 1 year ago

This add a new field_gpu type field implementation for which the rhs hand side method is implemented using CUDA fortran.

Class field_type is made and abstract class with deferred type boudn method rhs. Previous (cpu based) field_type becomes field_cpu_type that inherits form the abstract class. Same goes for new GPU based field type.

Because statements like

rhs = temp_field%rhs()

lead to a runtime error when compiled with nvfortran, rhs method is changed to return a real array instead of a class(field_type. This means the time integration must be slightly changed to use (field + real) additions (field_add_real added to + operator for type field_type.

Build is configured via CMake. Which includes CUDA source files whether or not compiler is nvfortran.

FFLAGS=-cuda FC=nvfortran cmake -S . -B build_cuda

Currently specifying FFLAGS at the command line is still required for unknown reasons. Setting target_compile_options in the CMake configuration doesn't seem to do the trick.