From bbc8832023b106588a89808cd8f4076eb3318b89 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 12 Jan 2021 18:09:55 +0100 Subject: [PATCH] Added thread group synchronization intrinsics --- src/ComputeSharp.Core/Intrinsics/Hlsl.cs | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs index c58a3301..3d757637 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs @@ -153,6 +153,28 @@ namespace ComputeSharp [Pure] public static bool All(Float4 x) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(All)}({nameof(Float4)})"); + /// + /// Blocks execution of all threads in a group until all memory accesses have been completed. + /// + /// + /// A memory barrier guarantees that outstanding memory operations have completed. + /// Threads are synchronized at GroupSync barriers. + /// This may stall a thread or threads if memory operations are in progress. + /// + [PreserveMemberName] + public static void AllMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(AllMemoryBarrier)}()"); + + /// + /// Blocks execution of all threads in a group until all memory accesses have been completed and all threads in the group have reached this call. + /// + /// + /// A memory barrier guarantees that outstanding memory operations have completed. + /// Threads are synchronized at GroupSync barriers. + /// This may stall a thread or threads if memory operations are in progress. + /// + [PreserveMemberName] + public static void AllMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(AllMemoryBarrierWithGroupSync)}()"); + /// /// Determines if any components of the specified value are non-zero. /// @@ -616,6 +638,18 @@ namespace ComputeSharp [Pure] public static Float3 Degrees(Float4 x) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(Degrees)}({nameof(Float4)})"); + /// + /// Blocks execution of all threads in a group until all device memory accesses have been completed. + /// + [PreserveMemberName] + public static void DeviceMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(DeviceMemoryBarrier)}()"); + + /// + /// Blocks execution of all threads in a group until all device memory accesses have been completed and all threads in the group have reached this call. + /// + [PreserveMemberName] + public static void DeviceMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(DeviceMemoryBarrierWithGroupSync)}()"); + /// /// Returns a distance scalar between two values. /// @@ -870,6 +904,18 @@ namespace ComputeSharp [Pure] public static Float4 Frexp(Float4 x, out Float4 exp) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(Frexp)}({nameof(Float4)},{nameof(Float4)})"); + /// + /// Blocks execution of all threads in a group until all group shared accesses have been completed. + /// + [PreserveMemberName] + public static void GroupMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(GroupMemoryBarrier)}()"); + + /// + /// Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call. + /// + [PreserveMemberName] + public static void GroupMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(GroupMemoryBarrierWithGroupSync)}()"); + /// /// Performs a guaranteed atomic add of a value to a destination. ///