From 2363b37b6d336aafaae9f72b93fcf5a6241a3f79 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 21 Feb 2024 17:24:47 +0000 Subject: [PATCH] Fix compilation with nvcc --- folly/Conv.h | 4 ++-- folly/synchronization/RelaxedAtomic.h | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/folly/Conv.h b/folly/Conv.h index e52507fb331..bad4311c4fe 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -286,8 +286,8 @@ namespace detail { template using LastElement = type_pack_element_t; -#ifdef _MSC_VER -// MSVC can't quite figure out the LastElementImpl::call() stuff +#if defined(_MSC_VER) || defined(__CUDACC__) +// MSVC and NVCC can't quite figure out the LastElementImpl::call() stuff // in the base implementation, so we have to use tuples instead, // which result in significantly more templates being compiled, // though the runtime performance is the same. diff --git a/folly/synchronization/RelaxedAtomic.h b/folly/synchronization/RelaxedAtomic.h index 9891310b38e..85133abad6b 100644 --- a/folly/synchronization/RelaxedAtomic.h +++ b/folly/synchronization/RelaxedAtomic.h @@ -98,7 +98,7 @@ struct relaxed_atomic_base : protected std::atomic { }; template -struct relaxed_atomic_integral_base : private relaxed_atomic_base { +struct relaxed_atomic_integral_base : protected relaxed_atomic_base { private: using atomic = std::atomic; using base = relaxed_atomic_base; @@ -108,7 +108,9 @@ struct relaxed_atomic_integral_base : private relaxed_atomic_base { using base::relaxed_atomic_base; using base::operator=; +#ifndef __CUDACC__ using base::operator T; +#endif using base::compare_exchange_strong; using base::compare_exchange_weak; using base::exchange; @@ -206,7 +208,9 @@ struct relaxed_atomic : detail::relaxed_atomic_base { using base::relaxed_atomic_base; using base::operator=; +#ifndef __CUDACC__ using base::operator T; +#endif }; template @@ -220,7 +224,9 @@ struct relaxed_atomic : detail::relaxed_atomic_base { using detail::relaxed_atomic_base::relaxed_atomic_base; using base::operator=; +#ifndef __CUDACC__ using base::operator T*; +#endif T* fetch_add(std::ptrdiff_t arg) noexcept { return atomic::fetch_add(arg, std::memory_order_relaxed);