libCEED icon indicating copy to clipboard operation
libCEED copied to clipboard

Enable multiple precisions in CeedVector

Open nbeams opened this issue 2 years ago • 0 comments

In this branch, I have attempted to start collecting the result of many discussions, particularly with @jeremylt and @jedbrown, about expanding CeedVectors to be able to contain multiple precisions. This PR is meant as a place for further discussion and refinement, whether or not we end up merging from it.

Summary of changes so far (as of opening of the draft PR, April 22):

  • Vector access functions (Get/Set/Take, as well as Sync) have changed to *Generic at the backend level, that is, the functions that get added to the CeedVector_private struct. They now take void pointers instead of CeedScalar, and an additional parameter for the data type. (These can hopefully be used within other backend functions in the future where we allow mixed precision.) This has been changed in ref, cuda-ref, and hip-ref.
  • At the user level, these functions remain the same, but they now simply call the Generic version with CEED_SCALAR_TYPE as the type parameter in their implementations in interface/ceed-vector.c
  • At the user level, additional versions for specific precisions have been added (named *FP32 and *FP64). These also just call the Generic version "under the hood"

in the hip-ref backend ONLY so far:

  • A first implementation of all the Generic functions, aimed at implementing the previously-discussed multiprecision vector access rules for validity
  • The new CeedScalarArray struct is used to store data

In fd75fdf7cc4919c94f2cfa77e54d2cdeae8b776f I added a user-interface-level function for checking the current array status, inspired by the way MFEM returns memory status flags. I was using this in my own local tests. We may or may not want to keep something like this in the future.

Related issue: #778

nbeams avatar Apr 22 '22 20:04 nbeams