Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rocThrust in sort when using HIP #6793

Merged
merged 4 commits into from Mar 11, 2024

Conversation

Rombur
Copy link
Member

@Rombur Rombur commented Feb 8, 2024

This PR add support for rocThrust. Unlike Thrust, rocThrust is not always installed with HIP. For instance, the docker images do not contain rocThrust unless you use the -complete tag. I will note that the 3.0 release of rocThrust is not backward compatible with the 2.X series. This is not an issue for us because sort is the same across version but it is problematic if we decide to require a minimum version of rocThrust because then the 3.0 version will be rejected. Since we are not affected by the break of backward compatibility, I've decided to forego the minimum version requirements. In practice, this means that the minimum version of rocThrust is the minimum version that is compatible with ROCm 5.2

Once this PR is merged, I'll open a PR to document the new option that enables/disables rocThrust.

@@ -62,6 +62,7 @@
#cmakedefine KOKKOS_ENABLE_LIBDL
#cmakedefine KOKKOS_ENABLE_LIBQUADMATH
#cmakedefine KOKKOS_ENABLE_ONEDPL
#cmakedefine KOKKOS_ENABLE_ROCTHRUST
Copy link
Member

Choose a reason for hiding this comment

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

You might want to add that setting to HIP::print_configuration()

@masterleinad same comment about KOKKOS_ENABLE_ONEDPL and SYCL

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me do that after #6758 is merged.

@@ -28,6 +28,9 @@ KOKKOS_LIB_INCLUDE_DIRECTORIES(kokkoscontainers
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

KOKKOS_LINK_TPL(kokkoscontainers PUBLIC ROCTHRUST)
Copy link
Member

Choose a reason for hiding this comment

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

Why link containers?

Copy link
Member Author

Choose a reason for hiding this comment

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

My bad, I meant to add this in algorithm.

@@ -0,0 +1,2 @@
FIND_PACKAGE(rocthrust REQUIRED)
KOKKOS_CREATE_IMPORTED_TPL(ROCTHRUST INTERFACE LINK_LIBRARIES roc::rocthrust)
Copy link
Member

Choose a reason for hiding this comment

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

Do we still have the arborx/ArborX#652 issue where the exported rocThrust package potentially adds flags to compile for all GPU architecture it knows about?

Copy link
Member Author

Choose a reason for hiding this comment

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

At least for the version shipped with ROCm 5.7, it works fine. I see only one architecture.

Copy link
Member

Choose a reason for hiding this comment

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

We need to find out for sure because IIRC compile time blows up

Copy link
Member

Choose a reason for hiding this comment

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

I looked at another PR it looks like the compile time is indeed 2x more for both 5.2 and 5.6 so we need to handle this and set the GPU_TARGETS before attempting to find rocThrust.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@aprokop
Copy link
Contributor

aprokop commented Feb 12, 2024

Just wanted to confirm: will we be able to write something like this downstream and will it work? Including linking to rocthrust as long as we link to Kokkos::kokkos.

if(Kokkos_ENABLE_HIP)
  if(Kokkos_VERSION VERSION_LESS 4.3)
    # Do something
  else
    set(ARBORX_ENABLE_ROCTHRUST ${Kokkos_ENABLE_ROCTHRUST})
  endif()
endif()

@@ -28,6 +28,7 @@ KOKKOS_LIB_INCLUDE_DIRECTORIES(kokkoscontainers
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

Copy link
Member

Choose a reason for hiding this comment

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

Please undo

@@ -0,0 +1,2 @@
FIND_PACKAGE(rocthrust REQUIRED)
KOKKOS_CREATE_IMPORTED_TPL(ROCTHRUST INTERFACE LINK_LIBRARIES roc::rocthrust)
Copy link
Member

Choose a reason for hiding this comment

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

We need to find out for sure because IIRC compile time blows up

@stanmoore1
Copy link
Contributor

stanmoore1 commented Feb 16, 2024

This would be useful for LAMMPS; Kokkos::BinSort isn't cutting it at large scale on Frontier (lammps/lammps#4075) .

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Just realized my comment was pending. Sorry about that.
I had mentioned the issue to Bruno in private.

@@ -0,0 +1,2 @@
FIND_PACKAGE(rocthrust REQUIRED)
KOKKOS_CREATE_IMPORTED_TPL(ROCTHRUST INTERFACE LINK_LIBRARIES roc::rocthrust)
Copy link
Member

Choose a reason for hiding this comment

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

I looked at another PR it looks like the compile time is indeed 2x more for both 5.2 and 5.6 so we need to handle this and set the GPU_TARGETS before attempting to find rocThrust.

@stanmoore1
Copy link
Contributor

This will be in 4.3 correct? Would be really nice if it supported sort_by_key too...

@dalg24
Copy link
Member

dalg24 commented Feb 28, 2024

This will be in 4.3 correct? Would be really nice if it supported sort_by_key too...

This is the plan yes. Bruno is swamped with something else but will get back to it next week. #6793 (comment) needs to be addressed and then we will merge.

@aprokop
Copy link
Contributor

aprokop commented Feb 29, 2024

Rebased on develop to allow integration of rocThrust's sort_by_key in this PR.

@masterleinad
Copy link
Contributor

masterleinad commented Mar 6, 2024

Make sure to take https://github.com/kokkos/kokkos/pull/6856/files into account and define

template <class Layout>
inline constexpr bool sort_on_device_v<Kokkos::HIP, Layout> = true;

edit: I see that sort_by_key isn't part of this pull request (anymore?) were you intending to do that in a follow-up instead?

@Rombur
Copy link
Member Author

Rombur commented Mar 7, 2024

This PR is to add support for rocThrust. sort_by_key will be its own PR.

@dalg24 dalg24 merged commit 35ad698 into kokkos:develop Mar 11, 2024
33 checks passed
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.

None yet

5 participants