Gromacs  2026.0-dev-20250612-fdec757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions | Variables
hip_sycl_kernel_utils.h File Reference
#include "config.h"
#include <type_traits>
#include "gputraits.h"
+ Include dependency graph for hip_sycl_kernel_utils.h:
+ This graph shows which files directly or indirectly include this file:

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

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 __attribute__ ((always_inline)) IndexType calculateOffset(IndexType index)
 Helper method to calculate offsets to memory locations on AMD hardware. More...
 

Variables

static IndexType idx
 

Function Documentation

template<typename ValueType , typename IndexType , std::enable_if_t< std::is_integral< IndexType >::value, bool > = true>
static __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

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:62