Using multiple cores - API wanted

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 68
Reputation: Tigran is an unknown quantity at this point 
Solved Threads: 6
Tigran Tigran is offline Offline
Junior Poster in Training

Using multiple cores - API wanted

 
0
  #1
Apr 4th, 2009
Hello,

A few days ago I visited a lecture of a teacher in an university that was about parallel processing.

He explained why it's good etc, and how you can make programs that use multiple cpus in C.
He used MPI and the code looked nice, wasn't too hard and got the job done. But in order to compile the program u needed to use mpicc (so not gcc, vcc or bcc)
and to run the program you had to write something like:
  1. shell$ /opt/openmpi-1.3.1/bin/mpirun -np 4 a.out
in that line, you also specify how many cores you want to use.

So my question is: Is there any other multiprocessing api that uses local variables, and messages to coordinate the work of the cpus that can be compiled by visual c++ or devc++ and doesn't need that weird command line to execute. that you can choose the amount of cores inside the program?

I hope that makes sense, else, please reply for a detailed explanation.

Thanks in advance,
Tigran
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Using multiple cores - API wanted

 
0
  #2
Apr 4th, 2009
What about POSIX Threads ?
Here's a tutorial about it ...

Hope this helps !
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 68
Reputation: Tigran is an unknown quantity at this point 
Solved Threads: 6
Tigran Tigran is offline Offline
Junior Poster in Training

Re: Using multiple cores - API wanted

 
0
  #3
Apr 4th, 2009
Thanks for the reply,

But why are there terms like multithreading and multiprocessing?
For what i've heared (but i'm not sure of) multithreading organises the tasks in one core. But i'm probably wrong

Are these POSIX threads also usable for windows? and are they as fast as the threads in the windows api?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Using multiple cores - API wanted

 
0
  #4
Apr 4th, 2009
You're right, but normally it's the Operating System's task to distribute all the threads over the available CPU-cores ...

POSIX Threads is also available for Windows here ...
If you want to use Windows' native API you might want to check this ...
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 181
Reputation: adam1122 is an unknown quantity at this point 
Solved Threads: 28
adam1122 adam1122 is offline Offline
Junior Poster

Re: Using multiple cores - API wanted

 
0
  #5
Apr 4th, 2009
MPI is likely not what you want if you simply want to utilize multiple cores/CPUs on a single computer.

Learn multithreading first.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 68
Reputation: Tigran is an unknown quantity at this point 
Solved Threads: 6
Tigran Tigran is offline Offline
Junior Poster in Training

Re: Using multiple cores - API wanted

 
0
  #6
Apr 4th, 2009
So why would i even bother learning MPI if multithreading does all the multicore stuff.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Using multiple cores - API wanted

 
0
  #7
Apr 4th, 2009
I think that if you're dealing with normal computers multithreading will speed-up your program more than enough, but it's still the operating system which has the task to distribute those threads among all the available CPU-cores, so the efficiency also depends on what os you are using ...
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC