back to matrix
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixCompute.Sequential"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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
|
||||
@@ -40,7 +40,11 @@ namespace StgSharp.Mathematics.Numeric.Linear
|
||||
public static unsafe partial class MatrixCompute
|
||||
{
|
||||
|
||||
public static void Add(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
|
||||
public static void Add(
|
||||
Matrix<float> left,
|
||||
Matrix<float> right,
|
||||
Matrix<float> ans
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(left, nameof(left));
|
||||
ArgumentNullException.ThrowIfNull(right, nameof(right));
|
||||
@@ -69,6 +73,7 @@ namespace StgSharp.Mathematics.Numeric.Linear
|
||||
t->Mat3 = (MatrixKernel*)ansPtr;
|
||||
t->ElementType = MatrixElementType.F64;
|
||||
t->Scalar.Data<long>(0) = count;
|
||||
MatrixParallelThread[] pool;
|
||||
if (count <= 256)
|
||||
{
|
||||
add(t);
|
||||
@@ -78,32 +83,44 @@ namespace StgSharp.Mathematics.Numeric.Linear
|
||||
return;
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
pool = MatrixParallel.LeadParallel(1);
|
||||
add(t);
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
return;
|
||||
}
|
||||
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask<SequentialPredictor>((nuint)add, t);
|
||||
pool = MatrixParallel.LeadParallel((int)(count / 1024));
|
||||
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask<SequentialPredictor>(pool, t);
|
||||
|
||||
taskGroup.LaunchParallel(SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
private sealed class SequentialPredictor : MatrixPredictor<SequentialPredictor>
|
||||
private struct SequentialPredictor : IMatrixPredictor<SequentialPredictor>
|
||||
{
|
||||
|
||||
public override bool Predict(Span<CacheLinePrediction> node, out int count)
|
||||
public bool Predict(
|
||||
Span<CacheLinePrediction> node,
|
||||
out int count
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Prefetch(nuint origin, ulong policy, Span<byte> cache)
|
||||
public void Prefetch(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
Span<byte> cache
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteBack(nuint origin, ulong policy, ReadOnlySpan<byte> cache)
|
||||
public void WriteBack(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
ReadOnlySpan<byte> cache
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user