Closed SpiderMonkey1975 closed 9 years ago
Hello.
What is the error message exactly, please?
And what if you replace
workers.emplace_back(std::thread(std::bind(&BatchProducer::batchProducerThread,this,nThread)));
with
workers.emplace_back(std::thread(&BatchProducer::batchProducerThread,this,nThread));
??
Regards
Ben Graham (b.graham@warwick.ac.uk)
Here is the error I get using the original code:
bash-3.2$ make cifar10
nvcc -c -o BatchProducer.o BatchProducer.cu -std=c++11 -O3
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits(3476): error: function "std::1::nat::~nat()"
(1027): here cannot be referenced -- it is a deleted function
detected during:
instantiation of class "std::1::invokable_imp<_Fp, _Args...> [with Fp=BatchProducer &, _Args=<>]"
(3484): here
instantiation of class "std::1::invokable<_Fp, _Args...> [with _Fp=BatchProducer *&, _Args=<>]"
(3503): here
instantiation of class "std::1::invoke_of<_Fp, _Args...> [with _Fp=BatchProducer *&, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2023): here
instantiation of "std::1::bind_return<_Fp, _BoundArgs, _Args, std::__1::_is_valid_bind_return<_Fp, _BoundArgs, _Args>::value>::type std::1::apply_functor(_Fp &, _BoundArgs &, std::1::tuple_indices<_Indx...>, _Args &&) [with Fp=void (BatchProducer::)(int), _BoundArgs=std::1::tuple<BatchProducer *, int>, _Indx=<0UL, 1UL>, _Args=std::1::tuple<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2087): here
instantiation of "std::1::bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::1::tuple<_Args &&...>, std::1::_is_valid_bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::__1::tuple<_Args &&...>>::value>::type std::1::bind<_Fp, _BoundArgs...>::operator()(_Args &&...) [with Fp=void (BatchProducer::)(int), _BoundArgs=<BatchProducer *, int &>, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base(413): here
instantiation of "auto std::1::invoke(_Fp &&, _Args &&...)->decltype((
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits(3476): error: function "std::1::nat::~nat()"
(1027): here cannot be referenced -- it is a deleted function
detected during:
instantiation of class "std::1::invokable_imp<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
(3484): here
instantiation of class "std::1::invokable<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
(3503): here
instantiation of class "std::1::invoke_of<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2023): here
instantiation of "std::1::bind_return<_Fp, _BoundArgs, _Args, std::1::_is_valid_bind_return<_Fp, _BoundArgs, _Args>::value>::type std::1::apply_functor(_Fp &, _BoundArgs &, std::1::tuple_indices<_Indx...>, _Args &&) [with Fp=void (BatchProducer::)(int), _BoundArgs=std::1::tuple<BatchProducer *, int>, _Indx=<0UL, 1UL>, _Args=std::1::tuple<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2087): here
instantiation of "std::1::bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::1::tuple<_Args &&...>, std::1::_is_valid_bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::1::tuple<_Args &&...>>::value>::type std::1::bind<_Fp, _BoundArgs...>::operator()(_Args &&...) [with Fp=void (BatchProducer::)(int), _BoundArgs=<BatchProducer *, int &>, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional_base(413): here
instantiation of "auto std::1::invoke(_Fp &&, _Args &&...)->decltype((
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits(3476): error: function "std::1::nat::~nat()"
(1027): here cannot be referenced -- it is a deleted function
detected during:
instantiation of class "std::1::invokable_imp<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
(3484): here
instantiation of class "std::1::invokable<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
(3503): here
instantiation of class "std::1::invoke_of<_Fp, _Args...> [with _Fp=int &, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2023): here
instantiation of "std::1::bind_return<_Fp, _BoundArgs, _Args, std::1::_is_valid_bind_return<_Fp, _BoundArgs, _Args>::value>::type std::1::apply_functor(_Fp &, _BoundArgs &, std::1::tuple_indices<_Indx...>, _Args &&) [with Fp=void (BatchProducer::)(int), _BoundArgs=std::1::tuple<BatchProducer *, int>, _Indx=<0UL, 1UL>, _Args=std::1::tuple<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional(2087): here
instantiation of "std::1::bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::1::tuple<_Args &&...>, std::1::_is_valid_bind_returnstd::1::decay<_Fp::type, std::1::tuplestd::1::decay<_BoundArgs::type...>, std::1::tuple<_Args &&...>>::value>::type std::1::bind<_Fp, _BoundArgs...>::operator()(_Args &&...) [with Fp=void (BatchProducer::)(int), _BoundArgs=<BatchProducer *, int &>, _Args=<>]"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional_base(413): here
instantiation of "auto std::1::invoke(_Fp &&, _Args &&...)->decltype((
2 errors detected in the compilation of "/var/folders/41/f35mc0q121g3rfzcsqbdvz400000gn/T//tmpxft_0000b00f_00000000-7_BatchProducer.cpp1.ii". make: *\ [BatchProducer.o] Error 2
Dang! Compile worked when I removed the bind call like you suggested. I was sure that I tried that on Saturday. Serves me right coding without coffee. Sincere apologies for the mix-up!
I have updated the repo, thanks. The "bind" was left-over from when I was using Boost threads rather than C++11 threads. Ben
Trying to compile the source code on my Mac (OS X 10.10) with the latest CUDA 7.0 and Xcode drivers. I cannot get pass the compilation of BatchProducer.cu. The NVCC compiler complains when trying to full the thread vector (workers) in the BatchProducer constructor function. You have each thread binded to the creation of a batchProducerThread object. Unfortunately, I keep getting error that the thread is being binded to a deleted function. If change the thread target to a vector of threads defined explicitly outside the constructor, the everything works fine.
How you seen this before?