Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

Welcome, Guest
Guest Settings

Thread: TParallel.For loop and stride=1 for only two separate threads

This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Permlink Replies: 0
Wilfried Visser

Posts: 7
Registered: 6/21/01
TParallel.For loop and stride=1 for only two separate threads  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2017 10:51 AM
I am trying to use the PPL to optimize a simulation application execution speed. I want to use the TParallel.For loop to start a range of Tasks that is variable, depending on the simulation model configuration. Often, onle one or two parallel tasks need to be started. So then I set the stride parameter to 2. However, I have discovered that with a TParallel.For loop from 0 to 1 for example and with stride=1 executes from the same thread. When looping from 0 to 2 (3 tasks) the 1st and the last are the same. So it seems I can not get a performance gain if using to for only 2 parallel tasks. What is the rationale here? Is the TParallel.For loop only for large numbers of tasks?
Should I use a task array instead? But then the question arises how to pass the for loop step variable (i going from 0 to 1 or 2 for example) to the task.

Any ideas?

regards, thanks, Wilfried Visser
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02