diff --git a/include/cuda/std/barrier b/include/cuda/std/barrier index ab7e1a31d2..e52da48d19 100644 --- a/include/cuda/std/barrier +++ b/include/cuda/std/barrier @@ -14,6 +14,7 @@ #define _CUDA_BARRIER #include "atomic" +#include "cstddef" #include "detail/__config" @@ -47,8 +48,10 @@ public: } }; +struct __block_scope_barrier_base {}; + template<> -class barrier { +class barrier : public __block_scope_barrier_base { using __barrier_base = std::__barrier_base; __barrier_base __barrier; @@ -62,6 +65,7 @@ public: _LIBCUDACXX_INLINE_VISIBILITY barrier(std::ptrdiff_t __expected, std::__empty_completion __completion = std::__empty_completion()) { + static_assert(offsetof(barrier, __barrier) == 0, "fatal error: bad barrier layout"); init(this, __expected, __completion); } diff --git a/include/cuda/std/detail/__config b/include/cuda/std/detail/__config index c6f03e1753..eae03dea96 100644 --- a/include/cuda/std/detail/__config +++ b/include/cuda/std/detail/__config @@ -96,6 +96,12 @@ # define _LIBCUDACXX_CUDA_ABI_VERSION 2 #endif +#ifdef _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION +#if _LIBCUDACXX_PIPELINE_ASSUMED_ABI_VERSION != _LIBCUDACXX_CUDA_ABI_VERSION +#error cuda_pipeline.h has assumed a different libcu++ ABI version than provided by this library. To fix this, please include a libcu++ header before including cuda_pipeline.h, or upgrade to a version of the toolkit this version of libcu++ shipped in. +#endif +#endif + #ifndef _LIBCUDACXX_CUDA_ABI_NAMESPACE # define _LIBCUDACXX_CUDA_ABI_NAMESPACE _LIBCUDACXX_CONCAT(__,_LIBCUDACXX_CUDA_ABI_VERSION) #endif