71 lines
3.2 KiB
C#
71 lines
3.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// -----------------------------------------------------------------------
|
|
// file="MatrixParallelThread.Model"
|
|
// Project: StgSharp
|
|
// AuthorGroup: Nitload Space
|
|
// Copyright (c) Nitload Space. All rights reserved.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
//
|
|
// -----------------------------------------------------------------------
|
|
// -----------------------------------------------------------------------
|
|
using StgSharp.Mathematics;
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace StgSharp.Mathematics.Numeric
|
|
{
|
|
public partial class MatrixParallelThread
|
|
{
|
|
|
|
private const int KernelStealCount = 64;
|
|
|
|
internal unsafe void BufferCompute(MatrixParallelTask* p)
|
|
{
|
|
// while () { }
|
|
int size = p->ElementSize * 16;
|
|
long count = Unsafe.As<int, long>(ref p->PrimCount);
|
|
long offset = Unsafe.As<int, long>(ref p->PrimTileOffset) * size;
|
|
ScalarPacket* scalar = p->Scalar;
|
|
IntPtr computeHandle = _context[p->ComputeHandle];
|
|
((delegate* unmanaged[Cdecl]<void*, void*, void*, void*, long, void>)computeHandle)((void*)(p->Left + offset),
|
|
(void*)(p->Right + offset),
|
|
(void*)(p->Answer + offset),
|
|
scalar, count);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
internal unsafe void SpecialBufferCompute(MatrixParallelTask* p)
|
|
{
|
|
switch ((MatrixElementType)p->ElementSize)
|
|
{
|
|
case MatrixElementType.F64:
|
|
ComputeFmaPanelF64(p);
|
|
return;
|
|
case MatrixElementType.F32:
|
|
ComputeFmaPanelF32(p);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|