Questions tagged [parallel.for]
Parallel.For is a .NET method that allows iterations of a for-like loop to execute in parallel using tasks.
parallel.for
260
questions
-1
votes
2
answers
126
views
Avoid closures when calling Parallel.For()
I'm performing some element UI hit testing like this:
internal MyElement[] HitTest((double x, double y) point, double scale)
{
ConcurrentBag<MyElement> geoms = new ConcurrentBag<...
0
votes
0
answers
22
views
ATen parallel_for grain_size 0
I want to use the at::parallel_for to do my for loop in parallel, and reading other code, I noticed that the grain_size is frequently set to 0.
I've read the description at https://github.com/pytorch/...
-1
votes
3
answers
112
views
Each thread is slower when more threads are present
I have 16 files I need to read from and process the data. All of data is independent. This is a snippet of code that processes that data:
int threadCount = 1;
ConcurrentBag<SomeClass> items = ...
2
votes
1
answer
95
views
C# Microsoft.CodeAnalysis.CSharp.Scripting is not waiting for Parallel.For
I tried a very simple test with Microsoft.CodeAnalysis.CSharp.Scripting with the following code snippet:
var code = @"
var myList = new List<string>();
Parallel.For(0, 300, i =>
{
...
2
votes
1
answer
152
views
use Span inside of Parallel.For loop
I am using Span to cast a float array to a byte array. Using a normal for loop is no problem, but for the amount of numbers I have, I need to parallelize my code, so I ended up using Parallel.For. The ...
1
vote
0
answers
151
views
Why SIMD only improves performance by only a little bit for RGB to Grayscale, with SIMD multiply but scalar add of vector elements?
I am learning how to use SIMD for image processing. However, I wonder why I have not seen much improvement in the performance after using SIMD.
Image size: 3840*2160
Image format: PixelFormat....
-3
votes
1
answer
84
views
How to invoke Action<String^> via Parallel::For
I would like to invoke an Action<String^ via Parallel::For but get the error below.
My code:
Action<String^> ^act = gcnew Action<String^>(this, &Form1::loadFileInternam);
System:...
1
vote
1
answer
57
views
Do Parallel Loops with MaxDegreesOfParallelism = 1 run on the calling thread?
The MSDN page does not really state what happens when ParallelOptions.MaxDegreesOfParallelism equals 1.
I make extensive use of the Parallel loops and I would like to debug it when it runs ...
0
votes
0
answers
72
views
Capturing results from multiple async tasks
For a project I needed a program which checks IP's for a response:
class Program
{
public static int rcount = 0;
public static int count = 0;
static void Main(string[] args)
{
...
0
votes
1
answer
62
views
Usage of Parallel also for dependant references to the underlying span/array?
Consider this hypothetical code-snippet:
for (slotIdx = 1; slotIdx < slotCount/2; slotIdx++)
{
//we always have to go 2x slotIdx, to find the value we wanna swap behind!
int ...
1
vote
1
answer
524
views
C# - AsyncLocal value reused on parallel.for
The Microsoft documentation about AsyncLocal states that:
Represents ambient data that is local to a given asynchronous control flow, such as an asynchronous method.
I have a class that is used to ...
1
vote
2
answers
131
views
Should I limit MaxDegreeOfParallelism because of memory concerns?
I am using Parallel.For to start a large number of jobs (say 1000). This works well, however each job is also quite memory intensive, and from what I can tell Prallel For starts a much higher number ...
1
vote
3
answers
85
views
How to break from ParallelFor loop at the lowest iteration that matches the condition?
I am trying to speed up the execution by parallelizing the matching between a given pattern myPattern and a long List of patterns patterns. The code I have below works fine if patterns had only one ...
1
vote
2
answers
91
views
How to lock Parallel.For every n iterations instead every time?
I 've the following code:
int counter = 1;
var lockTarget = new object();
Parallel.For(1, totalSIM, i => {
/* do some stuff */
lock(lockTarget) {
_printConcurrent(counter++);
...
2
votes
1
answer
887
views
Long-running parallel Tasks with Entity Framework cause high CPU peak and memory usage
I am shifting a C# ASP.NET Core 7 project from using SqlClient with regular SQL queries to using Entity Framework instead. I have a particular place when the application runs multiple long-running ...