ispc/ispc

"is mask all on" paradigm to be added to stdlib

开放

#2,296 创建于 2022年4月6日

 (4 条评论) (0 个反应) (0 位负责人)C++ (350 个派生)auto 404
Good First IssueStandard Library

仓库指标

星标
 (2,930 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Doing performance fine tuning, it may be beneficial to have separate code paths if the mask is "all on". Right now there are multiple ways of expressing this paradigm, which are not guaranteed to be optimal on all platforms. Possible ways of checking this are:

  1. __all(__mask). Seem to produces good code on all platforms, but uses builtins (that are not recommended for the use outside of standard library)
  2. ((1<<TARGET_WIDTH)-1 ^ lanemask()) == 0. Produces same good code, but not an obvious construct.
  3. popcnt(lanemask()) == programCount. Does no produce optimal code.

I suggest adding a standard library function, which implement the first case:

inline uniform bool is_mask_all_on() {
    return __all(__mask);
}

贡献者指南