Open robinchrist opened 3 years ago
Update:
There was a
CXX_EXTENSIONS NO
in the CMakeLists as part of my usual boilerplate. Turns out that's the issue...
Is there a specific reason why non-standard / non-portable C++ extensions are necessary?
Hi @robinchrist I don't think there's any specific reason for using non-standard extensions. I think this compiler issue should be fixed. Since the copy constructor is explicitly deleted for atomics, the move assignment for the spinlock should be written-out rather than defaulted. If you can work with the CXX_EXTENSIONS
flag on for the time being it would be great.
Hi @robinchrist Please try the change in this pull request. We will merge if this fixes the issue. https://github.com/bloomberg/quantum/pull/152
Hi,
Sorry for my later reply, I've been out of office.
Unfortunately, your PR https://github.com/bloomberg/quantum/pull/152 does not yet fix the issue:
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:20:
In file included from ../quantum/quantum/interface/quantum_icontext.h:19:
In file included from ../quantum/quantum/interface/quantum_icontext_base.h:19:
In file included from ../quantum/quantum/quantum_task_id.h:89:
In file included from ../quantum/quantum/impl/quantum_task_id_impl.h:21:
In file included from /usr/local/include/boost/functional/hash.hpp:6:
In file included from /usr/local/include/boost/container_hash/hash.hpp:761:
In file included from /usr/local/include/boost/container_hash/extensions.hpp:22:
In file included from /usr/local/include/boost/detail/container_fwd.hpp:92:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/list:63:
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_list.h:567:7: error: static_assert failed due to requirement 'is_same<std::shared_ptr<Bloomberg::quantum::ITask>, std::shared_ptr<Bloomberg::quantum::Task>>::value' "std::list must have the same value_type as its allocator"
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../quantum/quantum/quantum_task_queue.h:50:26: note: in instantiation of template class 'std::list<std::shared_ptr<Bloomberg::quantum::Task>, Bloomberg::quantum::ContiguousPoolManager<std::shared_ptr<Bloomberg::quantum::ITask>>>' requested here
using TaskListIter = TaskList::iterator;
^
../quantum/quantum/quantum_task_queue.h:95:18: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter iter,
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
../quantum/quantum/quantum_task_queue.h:100:9: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter _iter; // task iterator
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
../quantum/quantum/quantum_task_queue.h:132:26: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter iter);
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
../quantum/quantum/quantum_task_queue.h:143:5: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter _queueIt;
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
../quantum/quantum/quantum_task_queue.h:144:5: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter _blockedIt;
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
In file included from ../quantum/quantum/quantum_task_queue.h:166:
../quantum/quantum/impl/quantum_task_queue_impl.h:29:31: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
TaskListIter iter,
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
In file included from ../quantum/quantum/quantum_task_queue.h:166:
../quantum/quantum/impl/quantum_task_queue_impl.h:195:37: error: no matching constructor for initialization of 'IQueue::TaskSetterGuard'
IQueue::TaskSetterGuard taskSetter(*this, task);
^ ~~~~~~~~~~~
../quantum/quantum/interface/quantum_iqueue.h:161:26: note: candidate constructor not viable: no known conversion from 'Bloomberg::quantum::TaskQueue' to 'Bloomberg::quantum::IQueue &' for 1st argument
IQueue::TaskSetterGuard::TaskSetterGuard(IQueue& taskQueue,
^
../quantum/quantum/interface/quantum_iqueue.h:83:12: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
struct TaskSetterGuard
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
In file included from ../quantum/quantum/quantum_task_queue.h:166:
../quantum/quantum/impl/quantum_task_queue_impl.h:308:52: error: unknown type name 'TaskListIter'; did you mean 'TaskList'?
ITask::Ptr TaskQueue::doDequeue(std::atomic_bool&, TaskListIter iter)
^~~~~~~~~~~~
TaskList
../quantum/quantum/quantum_task_queue.h:49:11: note: 'TaskList' declared here
using TaskList = std::list<Task::Ptr, ContiguousPoolManager<ITask::Ptr>>;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
In file included from ../quantum/quantum/quantum_task_queue.h:166:
../quantum/quantum/impl/quantum_task_queue_impl.h:321:23: error: indirection requires pointer operand ('Bloomberg::quantum::TaskQueue::TaskList' (aka 'list<shared_ptr<Bloomberg::quantum::Task>, ContiguousPoolManager<shared_ptr<Bloomberg::quantum::ITask>>>') invalid)
ITask::Ptr task = *iter;
^~~~~
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:20:
In file included from ../quantum/quantum/interface/quantum_icontext.h:19:
In file included from ../quantum/quantum/interface/quantum_icontext_base.h:19:
In file included from ../quantum/quantum/quantum_task_id.h:89:
In file included from ../quantum/quantum/impl/quantum_task_id_impl.h:21:
In file included from /usr/local/include/boost/functional/hash.hpp:6:
In file included from /usr/local/include/boost/container_hash/hash.hpp:761:
In file included from /usr/local/include/boost/container_hash/extensions.hpp:22:
In file included from /usr/local/include/boost/detail/container_fwd.hpp:92:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/list:63:
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_list.h:567:7: error: static_assert failed due to requirement 'is_same<std::shared_ptr<Bloomberg::quantum::ITask>, std::shared_ptr<Bloomberg::quantum::IoTask>>::value' "std::list must have the same value_type as its allocator"
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../quantum/quantum/quantum_io_queue.h:44:26: note: in instantiation of template class 'std::list<std::shared_ptr<Bloomberg::quantum::IoTask>, Bloomberg::quantum::StackAllocator<std::shared_ptr<Bloomberg::quantum::ITask>, 1000>>' requested here
using TaskListIter = TaskList::iterator;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:21:
In file included from ../quantum/quantum/quantum_io_queue.h:114:
../quantum/quantum/impl/quantum_io_queue_impl.h:130:37: error: no matching constructor for initialization of 'IQueue::TaskSetterGuard'
IQueue::TaskSetterGuard taskSetter(*this, task);
^ ~~~~~~~~~~~
../quantum/quantum/interface/quantum_iqueue.h:161:26: note: candidate constructor not viable: no known conversion from 'Bloomberg::quantum::IoQueue' to 'Bloomberg::quantum::IQueue &' for 1st argument
IQueue::TaskSetterGuard::TaskSetterGuard(IQueue& taskQueue,
^
../quantum/quantum/interface/quantum_iqueue.h:83:12: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
struct TaskSetterGuard
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:63:
In file included from ../quantum/quantum/quantum_read_write_mutex.h:19:
../quantum/quantum/quantum_read_write_spinlock.h:36:5: warning: explicitly defaulted move constructor is implicitly deleted [-Wdefaulted-function-deleted]
ReadWriteSpinLock(ReadWriteSpinLock&&) = default;
^
../quantum/quantum/quantum_read_write_spinlock.h:171:39: note: move constructor of 'ReadWriteSpinLock' is implicitly deleted because field '_count' has a deleted move constructor
alignas(128) std::atomic_uint32_t _count{0};
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:778:7: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:63:
In file included from ../quantum/quantum/quantum_read_write_mutex.h:19:
../quantum/quantum/quantum_read_write_spinlock.h:42:24: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
ReadWriteSpinLock& operator=(ReadWriteSpinLock&&) = default;
^
../quantum/quantum/quantum_read_write_spinlock.h:171:39: note: move assignment operator of 'ReadWriteSpinLock' is implicitly deleted because field '_count' has a deleted move assignment operator
alignas(128) std::atomic_uint32_t _count{0};
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:779:15: note: 'operator=' has been explicitly marked deleted here
atomic& operator=(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:63:
../quantum/quantum/quantum_read_write_mutex.h:36:5: warning: explicitly defaulted move constructor is implicitly deleted [-Wdefaulted-function-deleted]
ReadWriteMutex(ReadWriteMutex&&) = default;
^
../quantum/quantum/quantum_read_write_mutex.h:202:33: note: move constructor of 'ReadWriteMutex' is implicitly deleted because field '_spinlock' has a deleted move constructor
mutable ReadWriteSpinLock _spinlock;
^
../quantum/quantum/quantum_read_write_spinlock.h:33:5: note: 'ReadWriteSpinLock' has been explicitly marked deleted here
ReadWriteSpinLock(const ReadWriteSpinLock&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:63:
../quantum/quantum/quantum_read_write_mutex.h:42:21: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
ReadWriteMutex& operator=(ReadWriteMutex&&) = default;
^
../quantum/quantum/quantum_read_write_mutex.h:202:33: note: move assignment operator of 'ReadWriteMutex' is implicitly deleted because field '_spinlock' has a deleted move assignment operator
mutable ReadWriteSpinLock _spinlock;
^
../quantum/quantum/quantum_read_write_spinlock.h:39:24: note: 'operator=' has been explicitly marked deleted here
ReadWriteSpinLock& operator=(const ReadWriteSpinLock&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::mutex'
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ext/new_allocator.h:147:23: note: in defaulted move constructor for 'Bloomberg::quantum::TaskQueue' first required here
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/alloc_traits.h:484:8: note: in instantiation of function template specialization '__gnu_cxx::new_allocator<Bloomberg::quantum::TaskQueue>::construct<Bloomberg::quantum::TaskQueue, Bloomberg::quantum::TaskQueue>' requested here
{ __a.construct(__p, std::forward<_Args>(__args)...); }
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:912:17: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<Bloomberg::quantum::TaskQueue>>::construct<Bloomberg::quantum::TaskQueue, Bloomberg::quantum::TaskQueue>' requested here
__traits::construct(__alloc, __dest, std::move(*__orig));
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:950:7: note: in instantiation of function template specialization 'std::__relocate_object_a<Bloomberg::quantum::TaskQueue, Bloomberg::quantum::TaskQueue, std::allocator<Bloomberg::quantum::TaskQueue>>' requested here
std::__relocate_object_a(std::__addressof(*__cur),
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_uninitialized.h:964:14: note: in instantiation of function template specialization 'std::__relocate_a_1<Bloomberg::quantum::TaskQueue *, Bloomberg::quantum::TaskQueue *, std::allocator<Bloomberg::quantum::TaskQueue>>' requested here
return __relocate_a_1(std::__niter_base(__first),
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:453:14: note: in instantiation of function template specialization 'std::__relocate_a<Bloomberg::quantum::TaskQueue *, Bloomberg::quantum::TaskQueue *, std::allocator<Bloomberg::quantum::TaskQueue>>' requested here
return std::__relocate_a(__first, __last, __result, __alloc);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:466:9: note: in instantiation of member function 'std::vector<Bloomberg::quantum::TaskQueue>::_S_do_relocate' requested here
return _S_do_relocate(__first, __last, __result, __alloc, __do_it{});
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/vector.tcc:79:8: note: in instantiation of member function 'std::vector<Bloomberg::quantum::TaskQueue>::_S_relocate' requested here
_S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
^
../quantum/quantum/impl/quantum_dispatcher_core_impl.h:57:17: note: in instantiation of member function 'std::vector<Bloomberg::quantum::TaskQueue>::reserve' requested here
_coroQueues.reserve(coroCount);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/std_mutex.h:94:5: note: 'mutex' has been explicitly marked deleted here
mutex(const mutex&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::condition_variable'
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/condition_variable:84:5: note: 'condition_variable' has been explicitly marked deleted here
condition_variable(const condition_variable&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::atomic_bool' (aka 'atomic<bool>')
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:73:5: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::atomic_bool' (aka 'atomic<bool>')
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:73:5: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::atomic_bool' (aka 'atomic<bool>')
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:73:5: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::atomic_bool' (aka 'atomic<bool>')
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:73:5: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
In file included from ../main.cpp:1:
In file included from ../quantum/quantum/quantum.h:48:
In file included from ../quantum/quantum/quantum_context.h:22:
In file included from ../quantum/quantum/quantum_dispatcher_core.h:20:
../quantum/quantum/quantum_task_queue.h:59:5: error: call to deleted constructor of 'std::atomic_bool' (aka 'atomic<bool>')
TaskQueue(TaskQueue&& other) = default;
^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/atomic:73:5: note: 'atomic' has been explicitly marked deleted here
atomic(const atomic&) = delete;
^
8 warnings and 19 errors generated.
ninja: build stopped: subcommand failed.
I have attached a framework for a simple repro, just make sure you're using Clang as your compiler (Ubuntu clang version 12.0.1-++20210825102835+fed41342a82f-1~exp1~20210825083541.133
for me). The quantum folder contains the contents of https://github.com/safaruqi/quantum/commit/36f9da24742083a84028082ab6a49386e28ac0e3
mkdir build && cd build && cmake -GNinja .. && ninja
It should be the same on all Linux distributions, given you're using Clang 12 and the CMake with CXX_EXTENSIONS OFF
Thanks for providing the framework above for reproducing the issue. I created a newer build environment with newer clang and am now able to reproduce the errors that you are getting. Will work on fixing them when I get some time next.
Hi @robinchrist Please try the change in pull request #153. This should fix the issue.
I was trying to include quantum simply as a subproject, but I can even get it to work in a very reduced example.
First approach (what should work for a properly written header only library based on CMake):
Does not work, because:
Not surprising, because:
It seems like the quantum CMake file was never meant to be used without installing...
Okay, no problem: It's a header only library, right? Let's just include the directory.
Well, that doesn't work:
Okay, cool, that must be due to me including this project as a subdirectory, right? Let's try with the "official" install path:
Nope, that wasn't it.
main.cpp simply includes the quantum header for a start:
Tested on Ubuntu 20.04 with Clang 12.0.1
What am I missing?