Skip to content

Commit 29dd16f

Browse files
committed
Fix Friflo SystemWithThreeComponents bug
1 parent 4f4514d commit 29dd16f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

source/Ecs.CSharp.Benchmark/SystemWithThreeComponents/FrifloEngineEcs.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void FrifloEngineEcs_MultiThread()
5656

5757
private static void Update(ref Component1 c1, ref Component2 c2, ref Component3 c3)
5858
{
59-
c1.Value = c2.Value + c3.Value;
59+
c1.Value += c2.Value + c3.Value;
6060
}
6161

6262
[BenchmarkCategory(Categories.FrifloEngineEcs)]
@@ -72,10 +72,12 @@ public void FrifloEngineEcs_SIMD_MonoThread()
7272
int step = component1.StepSpan256; // step = 8
7373
for (int n = 0; n < component1Span.Length; n += step)
7474
{
75+
Span<int> component3Slice = component3Span.Slice(n, step);
7576
Vector256<int> value1 = Vector256.Create<int>(component1Span.Slice(n, step));
7677
Vector256<int> value2 = Vector256.Create<int>(component2Span.Slice(n, step));
77-
Vector256<int> result = Vector256.Add(value1, value2); // execute 8 add instructions at once
78-
result.CopyTo(component3Span.Slice(n, step));
78+
Vector256<int> value3 = Vector256.Create<int>(component3Slice);
79+
Vector256<int> result = Vector256.Add(value3, Vector256.Add(value1, value2)); // execute 16 add instructions
80+
result.CopyTo(component3Slice);
7981
}
8082
}
8183
}

0 commit comments

Comments
 (0)