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

Rework BOOST_COMP_HIP and BOOST_LANG_HIP #1974

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions include/alpaka/core/BoostPredef.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright 2023 Benjamin Worpitz, Matthias Werner, Jan Stephan
/* Copyright 2023 Benjamin Worpitz, Matthias Werner, René Widera, Sergei Bastrakov, Jeffrey Kelling,
* Bernhard Manfred Gruber, Jan Stephan
* SPDX-License-Identifier: MPL-2.0
*/

Expand All @@ -12,18 +13,16 @@
#endif

//---------------------------------------HIP-----------------------------------
// __HIPCC__ is defined by hipcc (if either __CUDACC__ is defined)
// __HIP__ is defined by both hip-clang and vanilla clang in HIP mode.
// https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_porting_guide.md#compiler-defines-summary
#if !defined(BOOST_LANG_HIP)
# if defined(__HIPCC__) && (defined(__CUDACC__) || defined(__HIP__))
# include <hip/hip_runtime.h>
j-stephan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually the reason for the CI failures. __forceinline__ is not a HIP keyword but defined somewhere in the header files included by hip_runtime.h.

// HIP defines "abort()" as "{asm("trap;");}", which breaks some kernels
# undef abort
Comment on lines -20 to -21
Copy link
Member Author

Choose a reason for hiding this comment

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

This was problematic when we targeted CUDA devices through HIP. Since we no longer do this we can remove this.

# if defined(__HIP__)
/* BOOST_LANG_CUDA is enabled when either __CUDACC__ (nvcc) or __CUDA__ (clang) are defined. This occurs when
nvcc / clang encounter a CUDA source file. Since there are no HIP source files we treat every source file
as HIP when we are using a HIP-capable compiler. */
# include <hip/hip_version.h>
// HIP doesn't give us a patch level for the last entry, just a gitdate
# define BOOST_LANG_HIP BOOST_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
# if defined(BOOST_LANG_CUDA) && BOOST_LANG_CUDA
# undef BOOST_LANG_CUDA
# define BOOST_LANG_CUDA BOOST_VERSION_NUMBER_NOT_AVAILABLE
# endif
Comment on lines -23 to -26
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above.

# else
# define BOOST_LANG_HIP BOOST_VERSION_NUMBER_NOT_AVAILABLE
# endif
Expand All @@ -40,10 +39,12 @@
# endif
#endif

// hip compiler detection
// HIP compiler detection
#if !defined(BOOST_COMP_HIP)
# if defined(__HIP__)
# define BOOST_COMP_HIP BOOST_VERSION_NUMBER_AVAILABLE
# if defined(__HIP__) // Defined by hip-clang and vanilla clang in HIP mode.
# include <hip/hip_version.h>
// HIP doesn't give us a patch level for the last entry, just a gitdate
# define BOOST_COMP_HIP BOOST_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
Copy link
Member Author

Choose a reason for hiding this comment

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

Essentially, BOOST_COMP_HIP and BOOST_LANG_HIP do the same thing since there is no special HIP language we could test for. If we use a HIP-capable compiler we assume everything it touches is a "HIP source file".

# else
# define BOOST_COMP_HIP BOOST_VERSION_NUMBER_NOT_AVAILABLE
# endif
Expand Down
5 changes: 5 additions & 0 deletions include/alpaka/core/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# include <intrin.h>
#endif

#if BOOST_LANG_HIP
// HIP defines some keywords like __forceinline__ in header files.
# include <hip/hip_runtime.h>
#endif

//! All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_FN_HOST_ACC.
//!
//! \code{.cpp}
Expand Down