merge main branch
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixCompute.Basic"
|
||||
// Project: StgSharp
|
||||
@@ -30,7 +34,10 @@ using StgSharp.HighPerformance;
|
||||
using StgSharp.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
<<<<<<< HEAD
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
=======
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Security.AccessControl;
|
||||
@@ -39,10 +46,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
public static partial class MatrixCompute
|
||||
{
|
||||
|
||||
public static unsafe void Add(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
=======
|
||||
public static class MatrixCompute
|
||||
{
|
||||
|
||||
public static unsafe Matrix<float> Add(
|
||||
Matrix<float> left,
|
||||
Matrix<float> right,
|
||||
Matrix<float> ans)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
if (left.ColumnLength != right.ColumnLength ||
|
||||
left.RowLength != right.RowLength ||
|
||||
@@ -58,7 +75,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_add(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -69,22 +90,35 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_add(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Left = (nint)left.Buffer;
|
||||
package->Right = (nint)right.Buffer;
|
||||
package->Result = (nint)ans.Buffer;
|
||||
package->ElementSize = sizeof(float);
|
||||
<<<<<<< HEAD
|
||||
package->PrimCount = ans.KernelColumnLength;
|
||||
package->SecCount = ans.KernelRowLength;
|
||||
=======
|
||||
package->PrimCount = left.KernelColumnLength;
|
||||
package->SecCount = left.KernelRowLength;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
package->ComputeMode = new MatrixOpMode(MatrixOperationStyle.BUFFER_OP, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
|
||||
package->ComputeHandle = (IntPtr)NativeIntrinsic.Intrinsic.f32_buffer_add;
|
||||
MatrixParallelHandle taskGroup = MatrixParallel.ScheduleTask(package);
|
||||
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
|
||||
public static unsafe void Fill(Matrix<float> ans, float value)
|
||||
@@ -117,6 +151,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
taskGroup.Dispose();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public static unsafe void Mul(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
{
|
||||
// For matrix multiplication (left: MxK) * (right: KxN) => ans: MxN
|
||||
@@ -190,6 +225,22 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
public static unsafe void Mul(Matrix<float> left, float right, Matrix<float> ans)
|
||||
=======
|
||||
public static unsafe Matrix<float> Mul(
|
||||
Matrix<float> left,
|
||||
Matrix<float> right,
|
||||
Matrix<float> ans)
|
||||
{
|
||||
if (left.RowLength != right.ColumnLength ||
|
||||
left.RowLength != ans.RowLength ||
|
||||
right.ColumnLength != ans.ColumnLength) {
|
||||
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static unsafe Matrix<float> Mul(Matrix<float> left, float right, Matrix<float> ans)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
if (left.ColumnLength != ans.ColumnLength || left.RowLength != ans.RowLength) {
|
||||
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
|
||||
@@ -203,7 +254,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
|
||||
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -213,7 +268,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Right = (nint)left.Buffer;
|
||||
@@ -229,10 +288,20 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
MatrixParallelFactory.Release(scalar);
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
}
|
||||
|
||||
public static unsafe void Sub(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
=======
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static unsafe Matrix<float> Sub(
|
||||
Matrix<float> left,
|
||||
Matrix<float> right,
|
||||
Matrix<float> ans)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
if (left.ColumnLength != right.ColumnLength ||
|
||||
left.RowLength != right.RowLength ||
|
||||
@@ -248,7 +317,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_sub(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -259,7 +332,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_sub(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Left = (nint)left.Buffer;
|
||||
@@ -274,7 +351,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixComputeModel"
|
||||
// Project: StgSharp
|
||||
@@ -76,13 +80,21 @@ namespace StgSharp.Mathematics.Numeric
|
||||
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
||||
((delegate* unmanaged[Cdecl]< void*, void*, ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Right + offset),
|
||||
(void*)(p->Result + offset),
|
||||
<<<<<<< HEAD
|
||||
p->Scalar,
|
||||
count);
|
||||
=======
|
||||
p->Scalar, count);
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeBinary(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_Binary(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
@@ -134,7 +146,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeBinaryScalar(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_BinaryScalar(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
@@ -186,7 +202,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeUnary(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_Unary(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
@@ -231,7 +251,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeUnaryScalar(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_UnaryScalar(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
@@ -275,7 +299,10 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void PanelComputeBinary(MatrixParallelTaskPackage* p) { }
|
||||
|
||||
=======
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallel"
|
||||
// Project: StgSharp
|
||||
@@ -27,6 +31,7 @@
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Collections;
|
||||
using System;
|
||||
<<<<<<< HEAD
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -35,6 +40,17 @@ using System.Threading.Tasks;
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public static class MatrixParallel
|
||||
=======
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public static partial class MatrixParallel
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
|
||||
private static bool _meaningful;
|
||||
@@ -96,4 +112,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallelThread"
|
||||
// Project: StgSharp
|
||||
@@ -114,6 +118,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
switch (p->ComputeMode.ParameterStyle)
|
||||
{
|
||||
case MatrixOperationParam.RIGHT_ANS_PARAM:
|
||||
<<<<<<< HEAD
|
||||
MatrixComputeModel.KernelComputeUnary(p);
|
||||
break;
|
||||
case MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM:
|
||||
@@ -124,6 +129,18 @@ namespace StgSharp.Mathematics.Numeric
|
||||
break;
|
||||
case MatrixOperationParam.LEFT_RIGHT_ANS_SCALAR_PARAM:
|
||||
MatrixComputeModel.KernelComputeBinaryScalar(p);
|
||||
=======
|
||||
MatrixComputeModel.Compute_Unary(p);
|
||||
break;
|
||||
case MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM:
|
||||
MatrixComputeModel.Compute_UnaryScalar(p);
|
||||
break;
|
||||
case MatrixOperationParam.LEFT_RIGHT_ANS_PARAM:
|
||||
MatrixComputeModel.Compute_Binary(p);
|
||||
break;
|
||||
case MatrixOperationParam.LEFT_RIGHT_ANS_SCALAR_PARAM:
|
||||
MatrixComputeModel.Compute_BinaryScalar(p);
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -400,9 +417,13 @@ namespace StgSharp.Mathematics.Numeric
|
||||
private static extern IntPtr GetCurrentThread();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
<<<<<<< HEAD
|
||||
private static extern nuint SetThreadAffinityMask(
|
||||
IntPtr hThread,
|
||||
nuint dwThreadAffinityMask);
|
||||
=======
|
||||
private static extern nuint SetThreadAffinityMask(IntPtr hThread, nuint dwThreadAffinityMask);
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
|
||||
[LibraryImport("kernel32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
||||
Reference in New Issue
Block a user