weixin_39944944
weixin_39944944
2021-01-09 08:23

[REVIEW] fix gcc-9 compile errors under CUDA 11

When compiling libcudf with gcc-9 under CUDA 11, getting these type of errors:

bash
error: moving a local object in a return statement prevents copy elision

Compiler suggests removing the std::move() call.

该提问来源于开源项目:rapidsai/cudf

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

7条回答

  • weixin_39945679 weixin_39945679 4月前

    Codecov Report

    Merging #5982 into branch-0.15 will not change coverage. The diff coverage is n/a.

    Impacted file tree graph

    diff
    @@             Coverage Diff              @@
    ##           branch-0.15    #5982   +/-   ##
    ============================================
      Coverage        84.53%   84.53%           
    ============================================
      Files               81       81           
      Lines            13865    13865           
    ============================================
      Hits             11721    11721           
      Misses            2144     2144           
    

    Continue to review full report at Codecov.

    Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7718ddb...cb286fa. Read the comment docs.

    点赞 评论 复制链接分享
  • weixin_39834984 weixin_39834984 4月前

    Just looked it up, and yes, standard says that it will try treating the object as an rvalue before treating it as an lvalue. So return moves are completely redundant (at best).

    In preferential order, the compiler will attempt to do: RVO/copy-elision > invoke the move ctor (if exists) > invoke copy ctor

    If you do return std::move(...) then you force the compiler to skip RVO/copy-elision which is actually more efficient than doing a move construction.

    点赞 评论 复制链接分享
  • weixin_39520979 weixin_39520979 4月前

    Can one of the admins verify this patch?

    点赞 评论 复制链接分享
  • weixin_39520979 weixin_39520979 4月前

    Please update the changelog in order to start CI tests.

    View the gpuCI docs here.

    点赞 评论 复制链接分享
  • weixin_39725403 weixin_39725403 4月前

    Do we know that copy elision definitely kicks in at these sites (i.e. does compiler warn only in such cases)? Because, for cudf::column, a move is negligible but a copy overhead is significant and so your PR looks scary without some sort of indication that the elision really happens. Maybe there's a benchmark that can exercise at least one of these paths?

    点赞 评论 复制链接分享
  • weixin_39905816 weixin_39905816 4月前

    I believe that the worse case for RVO is that if the compiler cannot perform copy elision, it will implicitly invoke the move constructor. That makes std::move() redundant in all return cases, doesn't it?

    is always correcting people when they return std::move, so perhaps he can confirm.

    点赞 评论 复制链接分享
  • weixin_39725403 weixin_39725403 4月前

    Just looked it up, and yes, standard says that it will try treating the object as an rvalue before treating it as an lvalue. So return moves are completely redundant (at best).

    点赞 评论 复制链接分享

相关推荐