Gromacs  2025.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Typedefs | Functions | Variables
hip_sycl_kernel_utils.h File Reference
#include "config.h"
#include <type_traits>
+ Include dependency graph for hip_sycl_kernel_utils.h:

Description

Shared device methods for SYCL and HIP targets.

This file contains the following shared methods: *

TODO add more shared methods to this file

Author
Andrey Alekseenko al42a.nosp@m.nd@g.nosp@m.mail..nosp@m.com
Paul Bauer paul..nosp@m.baue.nosp@m.r.q@g.nosp@m.mail.nosp@m..com

Macros

#define GMX_ALWAYS_INLINE_ATTRIBUTE   __attribute__((always_inline))
 
#define GMX_FUNC_ATTRIBUTE   GMX_HOSTDEVICE_ATTRIBUTE GMX_ALWAYS_INLINE_ATTRIBUTE
 

Typedefs

template<typename TPtr >
using CharPtr = std::conditional_t< std::is_const_v< std::remove_pointer_t< TPtr >>, const char *, char * >
 Convert type of pointer to char while preserving const-ness.
 

Functions

template<typename ValueType , typename IndexType , std::enable_if_t< std::is_integral< IndexType >::value, bool > = true>
static GMX_DEVICE_ATTRIBUTE __attribute__ ((always_inline)) IndexType calculateOffset(IndexType index)
 Helper method to calculate offsets to memory locations on AMD hardware. More...
 

Variables

static GMX_DEVICE_ATTRIBUTE
IndexType 
idx
 

Function Documentation

template<typename ValueType , typename IndexType , std::enable_if_t< std::is_integral< IndexType >::value, bool > = true>
static GMX_DEVICE_ATTRIBUTE __attribute__ ( (always_inline)  )
inlinestatic

Helper method to calculate offsets to memory locations on AMD hardware.

Return address relative to buffer and offset by idx.

Uses builtin_assume to work around the compiler generating extra instructions for negative offsets.

This method helps hipcc (as late as of rocm 6.2.2, hipcc 6.2.41134-65d174c3e and likely later) to generate faster code for loads where 64-bit scalar + 32-bit vector registers are used instead of 64-bit vector versions, saving a few instructions for computing 64-bit vector addresses.

Variable Documentation

GMX_DEVICE_ATTRIBUTE IndexType idx
Initial value:
{
return reinterpret_cast<PointerType>(reinterpret_cast<CharPtr<decltype(address)>>(address)
+ calculateOffset<std::remove_pointer_t<PointerType>>(idx))
std::conditional_t< std::is_const_v< std::remove_pointer_t< TPtr >>, const char *, char * > CharPtr
Convert type of pointer to char while preserving const-ness.
Definition: hip_sycl_kernel_utils.h:87