Use atomic flag writes in heuristic trial division

This commit is contained in:
Marek Lemańczyk committed 2025-10-29 20:40:40 +01:00
1 parent 5ac05489c1
commit f9504a6a19
4 files changed
+19 -22

No files matched your search

+5 -5
View File
@@ -279,7 +279,7 @@ public sealed class HeuristicPrimeTester
int count = 0;
var inputView = gpu.Input.View;
var outputView = gpu.Output.View;
var flagView = gpu.HeuristicFlag.View;
bool ProcessBatch(int length)
{
@@ -289,11 +289,11 @@ public sealed class HeuristicPrimeTester
}
inputView.CopyFromCPU(ref divisorArray[0], length);
byte compositeFlag = 0;
outputView.CopyFromCPU(ref compositeFlag, 1);
kernel(length, inputView, n, outputView);
int compositeFlag = 0;
flagView.CopyFromCPU(ref compositeFlag, 1);
kernel(length, inputView, n, flagView);
accelerator.Synchronize();
outputView.CopyToCPU(ref compositeFlag, 1);
flagView.CopyToCPU(ref compositeFlag, 1);
return compositeFlag != 0;
}