Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@multitalentloes
Copy link
Member

@multitalentloes multitalentloes commented Jul 30, 2024

Start work on property evaluation on GPUs

  • Make header with macros for function decoration needed by cuda/hip
  • decorate functions that must be callable from both the cpu and gpu
  • implement make_view functions that will be used in cuda kernels later to serve as the interface to the property data


template <class TraitsT, class ContainerType, class ViewType>
PiecewiseLinearTwoPhaseMaterialParams<TraitsT, ViewType> make_view(const PiecewiseLinearTwoPhaseMaterialParams<TraitsT, ContainerType>& params) {
ViewType SwPcwnSamples = make_view<const float, float>(params.SwPcwnSamples());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be float unconditionally, and not depend on the underlying scalar type requested in the ViewType?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, It should depend on the viewType which should store something that matches the containerType

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a static_assert in your future...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the type and added the static assert now

@multitalentloes multitalentloes changed the title Prepare property evaluation for GPU acceleration Prepare PiecewiseLinearTwoPhaseMaterial for GPU support Aug 1, 2024
@multitalentloes multitalentloes marked this pull request as ready for review August 1, 2024 07:46
@multitalentloes
Copy link
Member Author

Jenkins build this please

1 similar comment
@multitalentloes
Copy link
Member Author

Jenkins build this please

Copy link
Contributor

@kjetilly kjetilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. A lot of files include both config.h and gpuDecorators.h, but the former is only needed for the macros gpuDecorators.h, which already include config.h. Also, there seems to be some inconsistencies with the defintions in gpuDecorators.h

@multitalentloes multitalentloes force-pushed the gpu_property_evaluation branch 2 times, most recently from 7fab79f to 259d3ba Compare August 5, 2024 14:53
@multitalentloes
Copy link
Member Author

Jenkins build this please

@multitalentloes multitalentloes force-pushed the gpu_property_evaluation branch from e38d557 to de6bbcc Compare August 6, 2024 09:43
@multitalentloes
Copy link
Member Author

Jenkins build this please

1 similar comment
@multitalentloes
Copy link
Member Author

Jenkins build this please

@bska
Copy link
Member

bska commented Aug 7, 2024

I haven't looked at anything here, but for future reference we usually prefer that PRs be made from branches on your own fork instead of a development branch created directly in the main OPM/opm-common repository.

@multitalentloes
Copy link
Member Author

Good catch @bska, this was probably caused by an unintentional git push --set-upstream=origin/branch_name instead of --set-upstream=myfork/branch_name when creating the remote branch. I am actually a bit surprised I was even allowed create a branch here, but yeah, lets delete it after the merge. It will be merged sometime next week after review from @atgeirr.

@multitalentloes
Copy link
Member Author

Jenkins build this please

@multitalentloes multitalentloes force-pushed the gpu_property_evaluation branch from ac44e51 to 71e216a Compare August 12, 2024 08:28
@multitalentloes
Copy link
Member Author

Jenkins build this please

@atgeirr
Copy link
Member

atgeirr commented Aug 12, 2024

A comment on config.h: This file shall be included in all compilation units (= .cpp files) as the first thing, before any other includes. No header files shall include it! If a header file contains conditional compilation depending on config.h-defined things, it will get the definition of any such macros via the .cpp file including config.h, not by including it itself.

@bska
Copy link
Member

bska commented Aug 12, 2024

[config.h] shall be included in all compilation units (= .cpp files) as the first thing, before any other includes. No header files shall include it!

True, although we do break that rule in a couple of important cases. For instance in PR OPM/opm-simulators#5227.

@kjetilly
Copy link
Contributor

A comment on config.h: This file shall be included in all compilation units (= .cpp files) as the first thing, before any other includes. No header files shall include it! If a header file contains conditional compilation depending on config.h-defined things, it will get the definition of any such macros via the .cpp file including config.h, not by including it itself.

I get that from a technical standpoint this needs to be the case (since config.h does not have opm in it's path, therefore could conflict with other files, and hence can't be installed alongside of the rest of the header files) but this is also a very, very dangerous design. That means in practice that the inclusion of any header file that requires defines from config.h would behave differently when compiling OPM and when using it as a library, which in turn means that any such header files that requires defines from config.h probably can't be public (ie. can't be part of what gets (implicitly) included when using OPM as a library).

This problem has probably not been relevant up until now, but with the CUDA/HIP definitions that do rely on the defines in config.h, this does become a potential issue. While I believe one can mostly circumvent the issue since it (probably) won't change the ABI of the generated library files, so it might not matter in practice, but it's still too close for comfort. AFAIK, this is also a problem with say determining MPI support etc of an installed OPM library.

If we look at other libraries, they typically include a library_name/config.h file in the installation. Is there a good reason the same hasn't been done for the config files in OPM? So say opm/common/config.h etc. The change could probably be handled automatically.

@multitalentloes
Copy link
Member Author

In light of these comments I have removed the include of the config.h file from gpuDecorators.hpp.

@multitalentloes
Copy link
Member Author

Jenkins build this please

@atgeirr atgeirr merged commit b2b8f28 into master Aug 13, 2024
@bska
Copy link
Member

bska commented Aug 13, 2024

The PR was merged and I think we should delete the branch now, at least unless it will be needed in the near future.

@multitalentloes
Copy link
Member Author

@bska you can safely delete the branch now

@bska
Copy link
Member

bska commented Aug 13, 2024

you can safely delete the branch now

Thanks for letting me know. I'll delete the branch now.

@bska bska deleted the gpu_property_evaluation branch August 13, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants