Skip to content

Porting assembly to the GPU #696

Description

@Tongdongq

We might start trying to accelerate (parts of) the assembly with a GPU at some point.

My initial plan was to:

1. Analyze the callgraph.
2. Create big structure 'DataStorage' and pass it down the assembly.
3. Make sure only data from 'DataStorage' is read/written. This means only the struct needs to be copied to the GPU. A big part of this is probably the intensive quantities cache.
4. Create simple CPU functions.
5. Create GPU kernels from simple CPU functions.

However, we should avoid having two different codebases with the same functionality. Changes to one would need to be made to the other.
Maybe code-generation could help us here.
CUDA does support templates, but OpenCL does not.
Especially the Evalution template is used a lot.

I did some profiling on an older version (Jan 2021) and found this:

fvbaseadlocallinearizer.hh:linearize()   12.05
	updateStencil()                   5.02
	updateAllIntensiveQuantities()    1.79
	updatePVWeights() (is empty)
	updateAllExtensiveQuantities()    1.65
	localResidual_.eval()             2.57
	updateLocalLinearization_()       0.65

The numbers are timings in seconds, for a small sample of NORNE.
Some of these functions are combined into updateAll().
The locallinearizer is called for every element, for every assembly.
Each OpenMP thread has 1 elementcontext, which 'shifts' to the next element, requiring resizing of internal variables. Maybe updating the stencil is not needed on the GPU, if a context could be kept for every element.

It probably is not worthwhile to only port some of these functions to the GPU. It should be all of them.
There are also many optional functions to consider, like the extra modules, or options like enableDissolvedGas() and enableVaporizedOil().

@atgeirr

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions