C# Parallel.For

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.

Re: C# Parallel.For

Postby Jackolantern » Tue Dec 23, 2014 12:52 pm

Oh wow haha. Well, I will say that optimizing through concurrency works best when you are using less, higher-loaded theads. For example, I am not sure how well starting millions of threads in a concurrent for loop will work due to the context-switching overhead. Instead, you want to look at threads as "task runners". You want to find entire tasks that can be done at the same time. For example, once you have all of the initial values in your data structure, you could start one thread to find the median, one to find the mean, another to get another value from it, etc. As long as you aren't writing to the data structure, little synchronization is necessary for reading. Just be careful about reading a copy of the data structure into a local version inside a thread, since you will start doubling your memory usage, which would be a problem in this case.
The indelible lord of tl;dr
User avatar
Posts: 10892
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 92 times
Blog: View Blog (1)


Return to Advanced Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest