Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Fix alignment in dyn_smem example
Browse files Browse the repository at this point in the history
  • Loading branch information
gevtushenko committed Sep 25, 2021
1 parent 1bc8794 commit e2240f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/block/example_block_reduce_dyn_smem.cu
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ __global__ void BlockReduceKernel(
using BlockReduceT = cub::BlockReduce<int, BLOCK_THREADS>;
using TempStorageT = typename BlockReduceT::TempStorage;

union ShmemLayout
{
TempStorageT reduce;
int aggregate;
};

// shared memory byte-array
extern __shared__ char smem[];
extern __shared__ __align__(alignof(ShmemLayout)) char smem[];

// cast to lvalue reference of expected type
auto& temp_storage = reinterpret_cast<TempStorageT&>(smem);
Expand Down

0 comments on commit e2240f6

Please sign in to comment.