remove branch conflict
This commit is contained in:
@@ -26,17 +26,11 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance;
|
||||
<<<<<<< HEAD
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
=======
|
||||
using StgSharp.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -45,19 +39,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
public partial class MatrixCompute
|
||||
{
|
||||
|
||||
<<<<<<< HEAD
|
||||
private static unsafe void ComputeFmaPanelF32(
|
||||
MatrixKernel* left,
|
||||
MatrixKernel* right,
|
||||
MatrixKernel* ans,
|
||||
ScalarPacket* scalar)
|
||||
{
|
||||
const int eSize = 32;
|
||||
int colum = scalar->Data<int>(0);
|
||||
int row = scalar->Data<int>(1);
|
||||
int k =
|
||||
|
||||
=======
|
||||
internal static unsafe void ComputeFmaPanelF32(MatrixParallelTaskPackage* p)
|
||||
{
|
||||
int size = p->ElementSize;
|
||||
@@ -97,7 +78,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixPanel.Destroy(leftPanel);
|
||||
MatrixPanel.Destroy(rightPanel);
|
||||
MatrixPanel.Destroy(ansPanel);
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixCompute"
|
||||
// Project: StgSharp
|
||||
@@ -37,57 +25,24 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
=======
|
||||
using StgSharp.Collections;
|
||||
using StgSharp.HighPerformance;
|
||||
using StgSharp.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
=======
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Security.AccessControl;
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
public static partial class MatrixCompute { }
|
||||
=======
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< 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
|
||||
========
|
||||
public static partial class MatrixCompute
|
||||
{
|
||||
|
||||
public static unsafe void Add(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
{
|
||||
if (left.ColumnLength != right.ColumnLength ||
|
||||
left.RowLength != right.RowLength ||
|
||||
@@ -102,16 +57,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* rightPtr = right.Buffer;
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_add(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -122,49 +68,21 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_add(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Left = (nint)left.Buffer;
|
||||
package->Right = (nint)right.Buffer;
|
||||
package->Answer = (nint)ans.Buffer;
|
||||
package->ElementSize = sizeof(float);
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< 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->PrimCount = ans.KernelColumnLength;
|
||||
package->SecCount = ans.KernelRowLength;
|
||||
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
package->ComputeHandle = (IntPtr)NativeIntrinsic.Intrinsic.f32_buffer_add;
|
||||
MatrixParallelHandle taskGroup = MatrixParallel.ScheduleTask(package);
|
||||
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
}
|
||||
|
||||
public static unsafe void Fill(Matrix<float> ans, float value)
|
||||
@@ -197,89 +115,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
taskGroup.Dispose();
|
||||
}
|
||||
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
public static unsafe void Mul(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
{
|
||||
// For matrix multiplication (left: MxK) * (right: KxN) => ans: MxN
|
||||
// ColumnLength = number of columns (N), RowLength = number of rows (M)
|
||||
if (left.ColumnLength != right.RowLength ||
|
||||
ans.ColumnLength != right.ColumnLength ||
|
||||
ans.RowLength != left.RowLength)
|
||||
{
|
||||
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
|
||||
}
|
||||
long count = (long)left.KernelColumnLength * left.KernelRowLength;
|
||||
if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = null;
|
||||
if (count > 256) {
|
||||
pool = MatrixParallel.LeadParallel(1);
|
||||
}
|
||||
MatrixPanel<float>* leftPanel = MatrixPanel.Create<float>();
|
||||
MatrixPanel<float>* rightPanel = MatrixPanel.Create<float>();
|
||||
MatrixPanel<float>* ansPanel = MatrixPanel.Create<float>();
|
||||
int size = MatrixPanel.KernelSideCount<float>();
|
||||
for (int i = 0; i < left.RowLength; i += size)
|
||||
{
|
||||
for (int j = 0; j < right.ColumnLength; j += size)
|
||||
{
|
||||
NativeIntrinsic.Intrinsic.f32_clear_panel((MatrixPanel*)ansPanel);
|
||||
for (int k = 0; k < left.ColumnLength; k += size)
|
||||
{
|
||||
NativeIntrinsic.Intrinsic
|
||||
.f32_build_panel((MatrixKernel*)left.Buffer,
|
||||
(MatrixPanel*)leftPanel,
|
||||
left.ColumnLength, left.RowLength, i,
|
||||
k);
|
||||
NativeIntrinsic.Intrinsic
|
||||
.f32_build_panel((MatrixKernel*)right.Buffer,
|
||||
(MatrixPanel*)rightPanel,
|
||||
right.ColumnLength, right.RowLength, k,
|
||||
j);
|
||||
NativeIntrinsic.Intrinsic
|
||||
.f32_panel_fma((MatrixPanel*)leftPanel,
|
||||
(MatrixPanel*)rightPanel,
|
||||
(MatrixPanel*)ansPanel);
|
||||
}
|
||||
NativeIntrinsic.Intrinsic
|
||||
.f32_store_panel((MatrixKernel*)ans.Buffer,
|
||||
(MatrixPanel*)ansPanel, ans.ColumnLength,
|
||||
ans.RowLength, i, j);
|
||||
}
|
||||
}
|
||||
MatrixPanel.Destroy(leftPanel);
|
||||
MatrixPanel.Destroy(rightPanel);
|
||||
MatrixPanel.Destroy(ansPanel);
|
||||
if (count > 256) {
|
||||
MatrixParallel.ReturnParallelResources(ref pool!);
|
||||
}
|
||||
return;
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Right = (nint)left.Buffer;
|
||||
package->Result = (nint)ans.Buffer;
|
||||
package->ElementSize = sizeof(float);
|
||||
package->PrimCount = left.KernelColumnLength;
|
||||
package->SecCount = left.KernelRowLength;
|
||||
package->ComputeMode = new MatrixOpMode(MatrixOperationStyle.BUFFER_OP, MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM);
|
||||
package->ComputeHandle = (IntPtr)NativeIntrinsic.Intrinsic.f32_buffer_scalar_mul;
|
||||
MatrixParallelHandle taskGroup = MatrixParallel.ScheduleTask(package);
|
||||
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
========
|
||||
public static unsafe void Mul(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
{
|
||||
// For matrix multiplication (left: MxK) * (right: KxN) => ans: MxN
|
||||
// ColumnLength = number of columns (N), RowLength = number of rows (M)
|
||||
@@ -357,12 +193,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
return;
|
||||
}
|
||||
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
public static unsafe Matrix<float> Mul(Matrix<float> left, float right, Matrix<float> ans)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
public static unsafe void Mul(Matrix<float> left, float right, Matrix<float> ans)
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
{
|
||||
if (left.ColumnLength != ans.ColumnLength || left.RowLength != ans.RowLength) {
|
||||
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
|
||||
@@ -375,16 +206,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* leftPtr = left.Buffer;
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
|
||||
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -394,15 +216,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Right = (nint)left.Buffer;
|
||||
@@ -418,27 +232,10 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
MatrixParallelFactory.Release(scalar);
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< 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
|
||||
========
|
||||
return;
|
||||
}
|
||||
|
||||
public static unsafe void Sub(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
{
|
||||
if (left.ColumnLength != right.ColumnLength ||
|
||||
left.RowLength != right.RowLength ||
|
||||
@@ -453,16 +250,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<float>* rightPtr = right.Buffer;
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_sub(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
@@ -473,15 +261,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
NativeIntrinsic.Intrinsic.f32_buffer_sub(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
}
|
||||
MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask<float>();
|
||||
package->Left = (nint)left.Buffer;
|
||||
@@ -496,17 +276,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
<<<<<<<< HEAD:StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs
|
||||
<<<<<<< HEAD
|
||||
return;
|
||||
=======
|
||||
return ans;
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
========
|
||||
return;
|
||||
>>>>>>>> stgsharp-dev/giga:StgSharp.Mathematics/Numeric/MatrixCompute.cs
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixComputeModel"
|
||||
// Project: StgSharp
|
||||
@@ -61,11 +53,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
long count = Unsafe.As<int, long>(ref p->PrimCount);
|
||||
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
||||
ScalarPacket* scalar = p->Scalar;
|
||||
((delegate* unmanaged[Cdecl]<void*, void*, void*,ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Left + offset),
|
||||
(void*)(p->Right + offset),
|
||||
(void*)(p->Answer + offset),
|
||||
scalar,
|
||||
count);
|
||||
((delegate* unmanaged[Cdecl]<void*, void*, void*, ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Left + offset),
|
||||
(void*)(p->Right + offset),
|
||||
(void*)(p->Answer + offset),
|
||||
scalar,
|
||||
count);
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
@@ -74,8 +66,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
int size = p->ElementSize * 16;
|
||||
long count = Unsafe.As<int, long>(ref p->PrimCount);
|
||||
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
||||
((delegate* unmanaged[Cdecl]<void*, ScalarPacket*,long, void>)p->ComputeHandle)((void*)(p->Answer + offset),
|
||||
p->Scalar, count);
|
||||
((delegate* unmanaged[Cdecl]<void*, ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Answer + offset),
|
||||
p->Scalar, count);
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
@@ -86,8 +78,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
||||
|
||||
((delegate* unmanaged[Cdecl]<void*, void*, long, void>)p->ComputeHandle)((void*)(p->Right + offset),
|
||||
(void*)(p->Answer + offset),
|
||||
count);
|
||||
(void*)(p->Answer + offset),
|
||||
count);
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
@@ -96,25 +88,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
int size = p->ElementSize * 16;
|
||||
long count = Unsafe.As<int, long>(ref p->PrimCount);
|
||||
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
||||
((delegate* unmanaged[Cdecl]< void*, void*, ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Right + offset),
|
||||
<<<<<<< HEAD
|
||||
(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
|
||||
=======
|
||||
((delegate* unmanaged[Cdecl]<void*, void*, ScalarPacket*, long, void>)p->ComputeHandle)((void*)(p->Right + offset),
|
||||
(void*)(p->Answer + offset),
|
||||
p->Scalar,
|
||||
count);
|
||||
@@ -122,7 +96,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
internal static unsafe void SpecialBufferCompute(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
{
|
||||
switch ((MatrixOperationSpecial)p->ComputeMode.ParameterStyle)
|
||||
{
|
||||
@@ -132,170 +105,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
default:
|
||||
break;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeBinaryScalar(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_BinaryScalar(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
// base pointer to matrix kernels
|
||||
nint l = p->Left, r = p->Right, a = p->Result;
|
||||
long
|
||||
|
||||
// set beginning value to counters for primary offsets
|
||||
lCount = (long)p->LeftPrimOffset * p->LeftPrimStride,
|
||||
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
|
||||
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
|
||||
pCount = int.Min(p->PrimCount, p->PrimColumnCountInTile + p->PrimTileOffset) /*_count of tile may be too much*/,
|
||||
//edge to reset counters
|
||||
lLimit = pCount - p->LeftPrimOffset,
|
||||
rLimit = pCount - p->RightPrimOffset,
|
||||
aLimit = pCount - p->ResultPrimOffset;
|
||||
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, ScalarPacket*, void> op =
|
||||
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, IntPtr, ScalarPacket*, void>)p->ComputeHandle;
|
||||
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
|
||||
{
|
||||
// update primary counters
|
||||
// if reaches edge, reset to zero
|
||||
lCount = i < lLimit ? lCount + p->LeftPrimStride : 0;
|
||||
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
|
||||
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
|
||||
|
||||
// get kernel column pointers
|
||||
nint left = l + (nint)(lCount * eSize);
|
||||
nint right = r + (nint)(rCount * eSize);
|
||||
nint ans = a + (nint)(aCount * eSize);
|
||||
long
|
||||
lc = (long)p->LeftSecOffset * p->LeftSecStride,
|
||||
rc = (long)p->RightSecOffset * p->RightSecStride,
|
||||
ac = (long)p->ResultSecOffset * p->ResultSecStride,
|
||||
sCount = int.Min(p->SecCount, p->PrimColumnCountInTile * p->SecTileOffset);
|
||||
long
|
||||
ll = sCount - p->LeftSecOffset,
|
||||
rl = sCount - p->RightSecOffset,
|
||||
al = sCount - p->ResultSecOffset;
|
||||
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
|
||||
{
|
||||
lc = j < ll ? lc + p->LeftSecStride : 0;
|
||||
rc = j < rl ? rc + p->RightSecStride : 0;
|
||||
ac = j < al ? ac + p->ResultSecStride : 0;
|
||||
op(left + (nint)lc, right + (nint)rc, ans + (nint)ac, p->Scalar);
|
||||
}
|
||||
}
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeUnary(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_Unary(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
// base pointer to matrix kernels
|
||||
nint r = p->Right, a = p->Result;
|
||||
long
|
||||
|
||||
// set beginning value to counters for primary offsets
|
||||
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
|
||||
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
|
||||
pCount = int.Min(p->PrimCount, p->PrimColumnCountInTile + p->PrimTileOffset) /*_count of tile may be too much*/,
|
||||
//edge to reset counters
|
||||
rLimit = pCount - p->RightPrimOffset,
|
||||
aLimit = pCount - p->ResultPrimOffset;
|
||||
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, void> op =
|
||||
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, void>)p->ComputeHandle;
|
||||
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
|
||||
{
|
||||
// update primary counters
|
||||
// if reaches edge, reset to zero
|
||||
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
|
||||
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
|
||||
|
||||
// get kernel column pointers
|
||||
nint right = r + (nint)(rCount * eSize);
|
||||
nint ans = a + (nint)(aCount * eSize);
|
||||
long
|
||||
rc = (long)p->RightSecOffset * p->RightSecStride,
|
||||
ac = (long)p->ResultSecOffset * p->ResultSecStride,
|
||||
sCount = int.Min(p->SecCount, p->PrimColumnCountInTile * p->SecTileOffset);
|
||||
long
|
||||
rl = sCount - p->RightSecOffset,
|
||||
al = sCount - p->ResultSecOffset;
|
||||
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
|
||||
{
|
||||
rc = j < rl ? rc + p->RightSecStride : 0;
|
||||
ac = j < al ? ac + p->ResultSecStride : 0;
|
||||
op(right + (nint)rc, ans + (nint)ac);
|
||||
}
|
||||
}
|
||||
MatrixParallelFactory.Release(p);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void KernelComputeUnaryScalar(MatrixParallelTaskPackage* p)
|
||||
=======
|
||||
internal static unsafe void Compute_UnaryScalar(MatrixParallelTaskPackage* p)
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
int eSize = p->ElementSize;
|
||||
|
||||
// base pointer to matrix kernels
|
||||
nint r = p->Right, a = p->Result;
|
||||
long
|
||||
|
||||
// set beginning value to counters for primary offsets
|
||||
rCount = (long)p->RightPrimOffset * p->RightPrimStride,
|
||||
aCount = (long)p->ResultPrimOffset * p->ResultPrimStride,
|
||||
pCount = int.Min(p->PrimCount, p->PrimColumnCountInTile + p->PrimTileOffset) /*_count of tile may be too much*/,
|
||||
//edge to reset counters
|
||||
rLimit = pCount - p->RightPrimOffset,
|
||||
aLimit = pCount - p->ResultPrimOffset;
|
||||
delegate* unmanaged[Cdecl]<IntPtr, IntPtr, ScalarPacket*, void> op =
|
||||
(delegate* unmanaged[Cdecl]<IntPtr, IntPtr, ScalarPacket*, void>)p->ComputeHandle;
|
||||
for (long i = p->PrimTileOffset % pCount; i < pCount; i++)
|
||||
{
|
||||
// update primary counters
|
||||
// if reaches edge, reset to zero
|
||||
rCount = i < rLimit ? rCount + p->RightPrimStride : 0;
|
||||
aCount = i < rLimit ? aCount + p->ResultPrimStride : 0;
|
||||
|
||||
// get kernel column pointers
|
||||
nint right = r + (nint)(rCount * eSize);
|
||||
nint ans = a + (nint)(aCount * eSize);
|
||||
long
|
||||
rc = (long)p->RightSecOffset * p->RightSecStride,
|
||||
ac = (long)p->ResultSecOffset * p->ResultSecStride,
|
||||
sCount = int.Min(p->SecCount, p->PrimColumnCountInTile * p->SecTileOffset);
|
||||
long
|
||||
rl = sCount - p->RightSecOffset,
|
||||
al = sCount - p->ResultSecOffset;
|
||||
for (long j = p->SecTileOffset % sCount; j < sCount; j++)
|
||||
{
|
||||
rc = j < rl ? rc + p->RightSecStride : 0;
|
||||
ac = j < al ? ac + p->ResultSecStride : 0;
|
||||
op(right + (nint)rc, ans + (nint)ac, p->Scalar);
|
||||
}
|
||||
}
|
||||
MatrixParallelFactory.Release(p);
|
||||
=======
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
internal static unsafe void PanelComputeBinary(MatrixParallelTaskPackage* p) { }
|
||||
|
||||
=======
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallel"
|
||||
// Project: StgSharp
|
||||
@@ -35,20 +27,6 @@
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Collections;
|
||||
using System;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public static class MatrixParallel
|
||||
=======
|
||||
using System.Collections.Concurrent;
|
||||
=======
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -57,7 +35,6 @@ using System.Threading.Tasks;
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public static partial class MatrixParallel
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
{
|
||||
|
||||
private static bool _meaningful;
|
||||
@@ -119,12 +96,4 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
=======
|
||||
}
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
//-----------------------------------------------------------------------
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
=======
|
||||
//-----------------------------------------------------------------------
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallelThread"
|
||||
// Project: StgSharp
|
||||
@@ -120,41 +112,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
break;
|
||||
}
|
||||
break;
|
||||
<<<<<<< HEAD
|
||||
case MatrixOperationStyle.KERNEL_OP:
|
||||
switch (p->ComputeMode.ParameterStyle)
|
||||
{
|
||||
case MatrixOperationParam.RIGHT_ANS_PARAM:
|
||||
<<<<<<< HEAD
|
||||
MatrixComputeModel.KernelComputeUnary(p);
|
||||
break;
|
||||
case MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM:
|
||||
MatrixComputeModel.KernelComputeUnaryScalar(p);
|
||||
break;
|
||||
case MatrixOperationParam.LEFT_RIGHT_ANS_PARAM:
|
||||
MatrixComputeModel.KernelComputeBinary(p);
|
||||
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;
|
||||
}
|
||||
break;
|
||||
=======
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -426,19 +383,9 @@ namespace StgSharp.Mathematics.Numeric
|
||||
private static extern IntPtr GetCurrentThread();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
private static extern nuint SetThreadAffinityMask(
|
||||
IntPtr hThread,
|
||||
nuint dwThreadAffinityMask);
|
||||
=======
|
||||
private static extern nuint SetThreadAffinityMask(IntPtr hThread, nuint dwThreadAffinityMask);
|
||||
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
|
||||
=======
|
||||
private static extern nuint SetThreadAffinityMask(
|
||||
IntPtr hThread,
|
||||
nuint dwThreadAffinityMask);
|
||||
>>>>>>> stgsharp-dev/giga
|
||||
|
||||
[LibraryImport("kernel32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
||||
Reference in New Issue
Block a user