Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,


I want to calculate the value of PI upto 100 decimal places using multiple CPU. If I have four CPU the work is divided among four cpu. Then in that case the first CPU will calculate the value of upto 0 to 25 decimal places. And second CPU simultaneously 2nd CPU will calculate the value upto 25 to 50 decimal places and 3rd CPU will calculate the value upto 50 to 75 decimal places and 4th CPU will calculate upto 75 to 100 decimal places simultaneously. In a way I want to Calculate the value of PI in parallel processing. Main Idea behind the dividing the work in four different CPU is that to process the output fast then using single CPU.

The main logic is that if any single CPU will calculate in 10 sec if that work is divided in four cpu the the work will be fast and it will be completed in approx 4 sec.

I want to use background worker class.



Thanks,
Deepak
Posted
Comments
Sergey Alexandrovich Kryukov 17-Feb-11 1:10am    
Thank you for information on your plans. Please report on your progress as soon as you have essential results.
--SA
Tarun.K.S 17-Feb-11 1:30am    
Interesting and good luck with that!

1 solution

I think TPL in .Net 4.0, would be a better option.
I suppose you already have your algorithm for PI in place.I found this one useful. http://www.boyet.com/Articles/PiCalculator.html[^]

You can refere to the following MSDN Magazine article "" Optimize Managed Code For Multi-Core Machines[^]

The Task Parallel Library (TPL) is designed to make it much easier to write managed code that can automatically use multiple processors.
 
Share this answer
 
v2
Comments
aryan2010 17-Feb-11 4:19am    
I have read the article Real Multi-threading in .NET 2.0
By Jose Luis Latorre published in CodeProject.The link below is the link of the published article


http://www.codeproject.com/KB/threads/RealMultiThreading.aspx

But Now I am in trouble how to implement this with multiple CPU. How the main CPU identify his slave CPU and Main CPU will do his work along with his slave CPU? And where the main code will be put.
Olivier Levrey 17-Feb-11 5:34am    
If you are talking about dual-cpu or quad-cpu (or n-cpu) mother board, there is no "main cpu" and "slave cpu". The Operating System is responsible for allocating the cpu to whatever thread it chooses via its scheduler. It is possible to choose by yourself which cpu should execute a specific code, but it is not recommanded: in most cases the scheduler is efficient enough and you might even reduce performance if you decide to do it by yourself.

To make it short: just write your threads, the OS will do the rest.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900