我正在使用 g++ 14.0.0 编译下面的 C++ 代码:
g++ -I/path/to/c++/14.0.0 -L/path/to/c++/libstdc++ -ltbb -std=c++23 -o main main.cc
#include <iostream>
#include <algorithm>
#include <execution>
#include <ranges>
#include <thread>
#include <syncstream>
int main()
{
using namespace std::chrono_literals;
auto r = std::views::iota(0) | std::views::take(10);
auto input_range = std::ranges::common_view(r);
std::for_each(std::execution::par_unseq, std::ranges::begin(input_range), std::ranges::end(input_range),
[&](int i) {
std::thread::id this_id = std::this_thread::get_id();
std::this_thread::sleep_for(2000ms);
std::osyncstream(std::cout) << this_id << std::endl ;
});
return 0;
}
代码可以编译,但我收到警告
In function ‘_RandomAccessIterator __pstl::__internal::__brick_unique(_RandomAccessIterator, _RandomAccessIterator, _BinaryPredicate, std::true_type)’:
note: ‘#pragma message: [Parallel STL message]: "Vectorized algorithm unimplemented, redirected to serial"’
1219 | _PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
我正在配置 gcc
./configure --prefix=/path/to/install/dir --disable-multilib --with-system-zlib --enable-default-pie --enable-default-ssp --disable-fixincludes --with-mpfr=/path/to/mpfr --with-mpc=/path/to/mpc --with-gmp=/path/to/gmp --enable-languages=c,c++,fortran,go,lto,m2,objc,obj-c++ --no-create --no-recursion
并且
config.log
具有变量 PKG_CONFIG_PATH
以及 MKL TBB 的正确路径。
我认为 p2408 是按照这篇文章实现的。
有人知道我做错了什么吗? TBB已安装
代码似乎也有同样的问题on godbolt。
根据 cppreference 上的编译器支持指南,仅 MSCV 19.34 支持 p2408R5。