Skip to content

Commit

Permalink
[libspirv] Restore missing builtin removed in 1b6070c
Browse files Browse the repository at this point in the history
  • Loading branch information
frasercrmck committed Feb 27, 2025
1 parent 2b1e0ae commit e40b162
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libclc/libspirv/lib/ptx-nvidiacl/group/group_non_uniform.cl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "membermask.h"

#include <clc/integer/clc_popcount.h>
#include <libspirv/spirv.h>
#include <libspirv/spirv_types.h>

Expand All @@ -33,4 +34,19 @@ _Z29__spirv_GroupNonUniformBallotjb(unsigned flag, bool predicate) {
res[0] = __nvvm_vote_ballot_sync(threads, predicate);

return res;
}

_CLC_DEF _CLC_CONVERGENT uint
_Z37__spirv_GroupNonUniformBallotBitCountN5__spv5Scope4FlagEiDv4_j(
uint scope, uint flag, __clc_vec4_uint32_t mask) {
// here we assume scope == __spv::Scope::Subgroup
// flag == InclusiveScan is not yet implemented
if (flag == Reduce) {
return __clc_popcount(mask[0]);
} else if (flag == ExclusiveScan) {
return __clc_popcount(__nvvm_read_ptx_sreg_lanemask_lt() & mask[0]);
} else {
__builtin_trap();
__builtin_unreachable();
}
}

0 comments on commit e40b162

Please sign in to comment.