ispc/ispc

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

Ouverte

#2 296 ouverte le 6 avr. 2022

 (4 commentaires) (0 réaction) (0 personne assignée)C++ (350 forks)auto 404
Good First IssueStandard Library

Métriques du dépôt

Stars
 (2 930 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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);
}

Guide contributeur