示例#1
0
 public static void AtomicSub(this VariableView <Vector4> target, Vector4 operand)
 {
     Atomic.Sub(target.GetSubView <float>(Vector4XOffset), operand.X);
     Atomic.Sub(target.GetSubView <float>(Vector4YOffset), operand.Y);
     Atomic.Sub(target.GetSubView <float>(Vector4ZOffset), operand.Z);
     Atomic.Sub(target.GetSubView <float>(Vector4WOffset), operand.W);
 }
示例#2
0
        /// <summary>
        /// A simple 1D kernel using basic atomic functions.
        /// The second parameter (<paramref name="dataView"/>) represents the target
        /// view for all atomic operations.
        /// </summary>
        /// <param name="index">The current thread index.</param>
        /// <param name="dataView">The view pointing to our memory buffer.</param>
        /// <param name="constant">A uniform constant.</param>
        static void AtomicOperationKernel(
            Index index,               // The global thread index (1D in this case)
            ArrayView <int> dataView,  // A view to a chunk of memory (1D in this case)
            int constant)              // A sample uniform constant
        {
            // dataView[0] += constant
            Atomic.Add(dataView.GetVariableView(0), constant);

            // dataView[1] -= constant
            Atomic.Sub(dataView.GetVariableView(1), constant);

            // dataView[2] = Max(dataView[2], constant)
            Atomic.Max(dataView.GetVariableView(2), constant);

            // dataView[3] = Min(dataView[3], constant)
            Atomic.Min(dataView.GetVariableView(3), constant);

            // dataView[4] = Min(dataView[4], constant)
            Atomic.And(dataView.GetVariableView(4), constant);

            // dataView[5] = Min(dataView[5], constant)
            Atomic.Or(dataView.GetVariableView(5), constant);

            // dataView[6] = Min(dataView[6], constant)
            Atomic.Xor(dataView.GetVariableView(6), constant);
        }
示例#3
0
 public static void AtomicSub(this VariableView <Vector2> target, Vector2 operand)
 {
     Atomic.Sub(target.GetSubView <float>(Vector2XOffset), operand.X);
     Atomic.Sub(target.GetSubView <float>(Vector2YOffset), operand.Y);
 }