Skip to content

Commit

Permalink
fix HIP build
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Aug 16, 2023
1 parent 13f6701 commit 7df0d93
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions include/targets/hip/shared_memory_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace quda
/**
@brief Class which is used to allocate and access shared memory.
The shared memory is treated as an array of type T, with the
number of elements given by the static member S::size(). The
offset from the beginning of the total shared memory block is
given by the static member O::shared_mem_size(block), or 0 if O
is void.
number of elements given by the call to the static member
S::size(target::block_dim()). The offset from the beginning of
the total shared memory block is given by the static member
O::shared_mem_size(target::block_dim()), or 0 if O is void.
*/
template <typename T, typename S, typename O = void> class SharedMemory
{
Expand Down Expand Up @@ -56,23 +56,24 @@ namespace quda
return target::dispatch<cache_dynamic>(offset);
}

public:
static constexpr unsigned int get_offset(dim3 block)
{
unsigned int o = 0;
if constexpr (!std::is_same_v<O, void>) { o = O::shared_mem_size(block); }
return o;
}

public:
static constexpr unsigned int shared_mem_size(dim3 block)
{
return get_offset(block) + S::size()*sizeof(T);
return get_offset(block) + S::size(block)*sizeof(T);
}

/**
@brief Constructor for SharedMemory object.
*/
constexpr SharedMemory() : data(cache(get_offset(target::block_dim()))), size(S::size()) {}
constexpr SharedMemory() : data(cache(get_offset(target::block_dim()))),
size(S::size(target::block_dim())) {}

/**
@brief Subscripting operator returning a reference to element.
Expand Down

0 comments on commit 7df0d93

Please sign in to comment.