mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
// Matrix Construct
|
|
//
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
// Copyright (C) 2016-2021 Jason Volk <jason@zemos.net>
|
|
//
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
#pragma once
|
|
#define HAVE_IRCD_SIMT_BROADCAST_H
|
|
|
|
#ifdef __OPENCL_VERSION__
|
|
/// Broadcast originating from the local leader (index [0]). All threads in the
|
|
/// group participate.
|
|
inline void
|
|
ircd_simt_broadcast_f4lldr(__local float4 *const buf,
|
|
const uint ln,
|
|
const uint li)
|
|
{
|
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
|
|
if(li > 0)
|
|
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)
|
|
#if defined(cl_khr_subgroups)
|
|
{
|
|
const float
|
|
ret = work_group_broadcast(buf[0], 0);
|
|
|
|
buf[li] = ret;
|
|
}
|
|
#else
|
|
{
|
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
|
|
if(li > 0)
|
|
buf[li] = buf[0];
|
|
}
|
|
#endif
|
|
#endif
|