Questions tagged [parallel-for]

Parallel.For executes a for loop in which iterations may run in parallel to each other.

Parallel.For executes a for loop in which iterations may run in parallel to each other.

References

98 questions
0
votes
0 answers

static structure array openmp parallel for

I have C code structured like below: typedef struct { double diam; double more_values; other_struct other_structures; ... }ant_struct; and a static declaration below: static ant_struct ant[MAX_NUM_ANTENNAS]; I have another section…
0
votes
0 answers

Error when using tbb::parallel_for

I'm having an error when I'm using parallel_for of the TBB library. I can't understand why.. I have been able to use tbb::atomic so i'm guessing this in not a linking problem. Here is the part of my code where i use tbb : auto values =…
tony497
  • 321
  • 2
  • 11
0
votes
1 answer

parallel openMP loop in cpp

I am trying to learn parallelization with openMP in cpp. I am using the following test example #pragma parallel for num_threads( 4 ) for ( int i = 0 ; i < N ; i++ ){ for ( int j = 0 ; j < 100000 ; j++ ){ data[ i ] = data[ i ] + (…
zodiac
  • 161
  • 10
0
votes
2 answers

C++: how can I use parallel-for macro multiple times in same scope?

I'm using a local function definition to run a code block N times acting like a parallel-for version of C# but it gives multiple definition error for f function when I use two or more of it in same scope. How can I make the function name…
huseyin tugrul buyukisik
  • 9,464
  • 3
  • 39
  • 81
0
votes
1 answer

Does tbb::parallel_for always utilize the calling thread

I have a piece of code where I am using tbb::parallel_for to multithread a loop, which is called by main thread. In that loop I need main thread to update the UI to reflect the progress. From what I have observed, tbb::parallel_for always uses the…
Serge
  • 939
  • 9
  • 19
0
votes
1 answer

C# Parallel.For and Oracle database access - memory exception

I am working on some code that I would like to access an Oracle database inside of a Parallel.For loop. The loop will run for several minutes, and then result in the error: "Attempted to read or write protected memory. This is often an …
tuj
  • 553
  • 2
  • 9
  • 23
0
votes
0 answers

OpenMp For-Loop Parallelization

I try to parallelize the following piece of code with OpenMP. #pragma omp parallel for collapse(2) { for (int mNdx = 0; mNdx < M; ++mNdx) { for (int nNdx = mNdx; nNdx < N; ++nNdx) { for (int elemNdx = mNdx;…
QckNdDrt
  • 1
  • 1
  • 3
0
votes
1 answer

Parallel.For() updating properties of an item

Suppose I have a "distinct" list of Persons that I need to update. I would like to use Parallel.For() method in question: public void UpdatePerson(Person row){ row.Name = //get from cache and update property } VS public Person…
ShaneKm
  • 18,605
  • 41
  • 141
  • 250
0
votes
1 answer

Different thread affinities in Parallel.For Iterations

I need an iteration of a parallel for loop to use 7 cores(or stay away from 1 core) but another iteration to use 8(all) cores and tried below code: Parallel.For(0,2,i=>{ if(i=0) Process.GetCurrentProcess().ProcessorAffinity =…
huseyin tugrul buyukisik
  • 9,464
  • 3
  • 39
  • 81
0
votes
1 answer

Common keyword to 'continue' in sequential and parallel for loops

In a sequential for loop, the current iteration can be interrupted by calling continue. Similarly, in a Concurrency::parallel_for loop, the current iteration - which is a thread calling a lambda function - can be interrupted with return. From time…
mOfl
  • 468
  • 2
  • 13
0
votes
0 answers

Matlab sim command in parfor

I would like to run a Simulink model in a parfor loop on many cores with different data. However, I could not get the sim results when I use parfor whereas I can obtain them while using only for loop. It simply get [t,u] from workspace1, consider a…
okale
  • 1
0
votes
1 answer

Intel TBB parallel loop thread id

How do I determine thread id in a TBB parallel loop body? Essentially what I need is per-thread copies of an object so I thought I'd have those in array indexed by thread id. I'm looking for the portable TBB way of doing this, not OS native…
lsr
  • 23
  • 3
0
votes
1 answer

Parallel loop counter in Julia

In Julia, I would like to print out inside a parallel for loop the number of iterations the loop has completed. Is this a safe way to do so, and/or is there a better way? a = SharedArray(Int, 10) counter = SharedArray(Int, 1) arr = 1:10 tot =…
gozzilli
  • 6,931
  • 6
  • 49
  • 80
0
votes
2 answers

OpenMP Parallel for with scheduling in C

I want to run a parallel, scheduled(eg. static/dynamic/guided) for-loop, where each thread has its own set of variables, based on their thread-id. I know that any variable declared within the parallel pragma is private, but I don't want to…
Chris Phillips
  • 1,484
  • 2
  • 14
  • 26
0
votes
1 answer

How do I use tbb::parallel_invoke to run large number of tasks in parallel?

My problem similar to producer-consumer problem. For e.g. I need to run 999 producers and 1 consumer in parallel. Basically all 999 producers do the same task.