0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::simt: Add overloads for scalar types for now.

This commit is contained in:
Jason Volk 2022-01-23 11:03:32 -08:00
parent 5e824a4f6f
commit d733fe8ef9
2 changed files with 57 additions and 0 deletions

View file

@ -25,3 +25,18 @@ ircd_simt_broadcast_f4lldr(__local float4 *const buf,
buf[li] = buf[0];
}
#endif
#ifdef __OPENCL_VERSION__
/// Broadcast originating from the local leader (index [0]). All threads in the
/// group participate.
inline void
ircd_simt_broadcast_flldr(__local float *const buf,
const uint ln,
const uint li)
{
barrier(CLK_LOCAL_MEM_FENCE);
if(li > 0)
buf[li] = buf[0];
}
#endif

View file

@ -32,6 +32,48 @@ ircd_simt_reduce_add_f4lldr(__local float4 *const buf,
#ifdef __OPENCL_VERSION__
/// Sum all elements in the buffer. All threads in the group participate;
/// result is placed in index [0], the rest of the buffer is trashed.
inline void
ircd_simt_reduce_add_flldr(__local float *const buf,
const uint ln,
const uint li)
{
for(uint stride = ln >> 1; stride > 0; stride >>= 1)
{
barrier(CLK_LOCAL_MEM_FENCE);
if(li < stride)
buf[li] += buf[li + stride];
}
}
#endif
#ifdef __OPENCL_VERSION__
/// Sum all elements in the buffer. All threads in the group participate;
/// result is placed in index [0], the rest of the buffer is trashed.
inline void
ircd_simt_reduce_add_illdr(__local int *const buf,
const uint ln,
const uint li)
{
if(li > 0)
atomic_add(buf + 0, buf[li]);
}
#endif
#ifdef __OPENCL_VERSION__
/// Sum all elements in the buffer. All threads in the group participate;
/// result is placed in index [0], the rest of the buffer is trashed.
inline void
ircd_simt_reduce_add_ulldr(__local uint *const buf,
const uint ln,
const uint li)
{
if(li > 0)
atomic_add(buf + 0, buf[li]);
}
#endif
#ifdef __OPENCL_VERSION__
inline float
__attribute__((always_inline))
ircd_simt_reduce_add_f4(const float4 in)