如何在使用Boost的lockfree spsc_queue时进行编译? [英] How do I compile while using Boost's lockfree spsc_queue?
问题描述
& boost,我遇到编译器错误/lockfree/spsc_queue.hpp>
。 此时,我在设备上什么也不做, $ c> spsc_queue 对象。
最初我使用Boost 1.54,使用GCC 4.8.4编译,并使用所有的标志它们作为CUDA 7.0 makefile的一部分以及以下自定义标志: -Xcompiler -fopenmp -lgomp -std = c ++ 11 -lpthread
。这些在变量MYFLAGS中,如下所示:
main.o:main.cu
$(EXEC)$ (NVCC)$(INCLUDES)$(ALL_CCFLAGS)$(GENCODE_FLAGS)-c $(MYFLAGS)main.cu。
然后在连接步骤中,我有
$(EXEC)$(NVCC)$(ALL_LDFLAGS)$(GENCODE_FLAGS)-O2 $(MYFLAGS)-o runnable $(OBJECTS)$(LIBRARIES)。
包含标题时,我收到此错误:
/usr/include/boost/utility/detail/result_of_iterate.hpp:135:75:错误:
无效使用qualified-name std :: allocator_traits< _Alloc> :: propagate_on_container_swap'
我在Boost中搜索可能的错误, href =http://stackoverflow.com/questions/30779322/compile-error-when-using-boostlockfreespsc-queue-is-it-a-bug-in-boost>这一个。
我升级到Boost 1.58,现在我收到不同的错误:
boost_1_58_0 / boost / lockfree / spsc_queue.hpp(352):错误:函数调用中的参数太少。
spsc_queue.hpp
中的问题代码部分的复位例程,但是我还没有声明一个对象。
void reset(void)
{
if(!boost :: has_trivial_destructor< T> :: value){
//确保调用所有析构函数!
T dummy_element;
while(pop(dummy_element))
{}
} else {
write_index_.store(0,memory_order_relaxed);
read_index_.store(0,memory_order_release);
}
}
因此,我的问题: Boost的lockfree spsc_queue?
问题是 nvcc
不像例如那样成熟 g ++
当涉及到复杂的C ++代码,如Boost。一些Boost库使用 nvcc
,其他编译失败; boost :: lockfree
似乎属于后面的组。
一个可能的解决方案是拆分主机和设备代码,并编译所有包含头 nvcc
的主机代码不能理解 g ++
。
I'm trying to write a program in CUDA that will use Boost's single-producer/single-consumer queue on the host side, but I run into compiler errors as soon as I include <boost/lockfree/spsc_queue.hpp>
.
At this point, I am doing nothing on the device, nor am I creating an spsc_queue
object. The errors occurred as soon as I tried to compile with the above header.
Originally I was using Boost 1.54, compiling with GCC 4.8.4, and using all of the flags that come as part of the CUDA 7.0 makefile along with the following custom flags: -Xcompiler -fopenmp -lgomp -std=c++11 -lpthread
. These are in the variable MYFLAGS, seen below:
main.o: main.cu
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -c $(MYFLAGS) main.cu.
Then in the linking step, I have
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -O2 $(MYFLAGS) -o runnable $(OBJECTS) $(LIBRARIES).
As soon as I included the header, I received this error:
/usr/include/boost/utility/detail/result_of_iterate.hpp:135:75: error:
invalid use of qualified-name std::allocator_traits<_Alloc>::propagate_on_container_swap’
I searched for possible bugs in Boost, and I discovered this one. Unfortunately, that's not at all the issue I'm having.
I upgraded to Boost 1.58, and now I receive a different error:
boost_1_58_0/boost/lockfree/spsc_queue.hpp(352): error: too few arguments in function call.
The problem code in spsc_queue.hpp
is part of a "reset" routine, but again, I haven't even declared an object yet.
void reset(void)
{
if ( !boost::has_trivial_destructor<T>::value ) {
// make sure to call all destructors!
T dummy_element;
while (pop(dummy_element))
{}
} else {
write_index_.store(0, memory_order_relaxed);
read_index_.store(0, memory_order_release);
}
}
Hence, my question: How do I compile while using Boost's lockfree spsc_queue? What am I doing wrong?
The problem is that nvcc
is not as mature as e.g. g++
when it comes to complex C++ code such as Boost. Some Boost libraries work with nvcc
, others fail to compile; boost::lockfree
seems to belong to latter group.
A possible solution is to split host and device code, and compile all host code which includes headers nvcc
does not understand with g++
.
这篇关于如何在使用Boost的lockfree spsc_queue时进行编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!