我正在研究与 oneAPI basekit 一起提供的 vectorAdd 示例应用程序。当我尝试在内核中打印总和时,出现以下错误。
编译时请查找随附的源代码和错误。
//Source code
cgh.parallel_for<class VectorAdd>(num_items, [=](id<1> wiID) {
sum_accessor[wiID] = addend_1_accessor[wiID] + addend_2_accessor[wiID];
std::cout<<"Sum : "<<sum_accessor[wiID]<<std::endl; // I want to print this sum
});
在编译期间,我收到以下错误。
//Error generated while compiling
usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/ostream.tcc:359:25: error: SYCL kernel cannot have a class with a virtual function table
extern template class basic_ostream<char>;
^
vector-add.cpp:159:6: note: used here
std::cout<<"Sum : "<<sum_accessor[wiID]<<std::endl;
^
vector-add.cpp:159:11: error: SYCL kernel cannot use a global variable
std::cout<<"Sum : "<<sum_accessor[wiID]<<std::endl;