代码之家  ›  专栏  ›  技术社区  ›  Astor

C++并行STL矢量化算法未实现p2408

  •  0
  • Astor  · 技术社区  · 2 年前

    我正在用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是按照 this post .

    有人知道我做错了什么吗?TBB已安装

    代码似乎有同样的问题 on godbolt .

    1 回复  |  直到 2 年前
        1
  •  1
  •   NathanOliver    2 年前

    根据 compiler support guide 在…上 cppreference 只有MSVC 19.34及以上版本支持p2408R5。