Thread: Multiple thread and parallel programming

  1. #1
    Registered User
    Join Date
    Jan 2009

    Multiple thread and parallel programming

    I am starting to get some taste in multiple thread and parallel programming to see if they can speed up my program running. I am a little confused after reading something online.

    1. is multiple thread a type of parallel programming? Can they both accelerate the computation on a laptop with single processor or on a cluster?

    2. do they require my code being modified to specified which parts can be run simultaneously on different threads, processors and computers? Or they could this automatically via some special C++ library or bash command without further human intervene?

    Thanks in advance and really appreciate if you could point me to some good tutorials on these subject!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    1. Short answer:
    Possibly, yes or no.
    Multithreading will speed things up within a single machine where there are multiple processors or where the code is waiting for something to happen (e.g. reading/writing data from/to hard-disk or dealing with network packets, where there is also some computational/data processing work to get on with whilst the hardware is "waiting").
    It is one form of "parallel programming" - this term covers so many things that it's hard to say what isn't covered and what is covered - it is simply anything that isn't a single thread on one machine.

    Short answer:
    Long answer:
    Again, it's hard to say specifically what will need to be done without understanding the code and what environment it is being run in, etc, etc. Most likely, at least some parts of your code will need to be modified, since any form of running things in parallel will involve splitting the work out, distributing it and collating it, as well as determining which parts can be split out over several threads/processes/machines.

    I'm sure there are MANY sites available to do this, but I'm not sure which ones they are, really.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread safety for tiny simple functions
    By CodeMonkey in forum C++ Programming
    Replies: 16
    Last Post: 12-31-2008, 12:20 AM
  2. Replies: 3
    Last Post: 04-18-2008, 10:06 AM
  3. Replies: 3
    Last Post: 02-29-2008, 01:29 PM
  4. multiple connections via sockets
    By cope in forum Networking/Device Communication
    Replies: 7
    Last Post: 06-07-2007, 10:35 AM
  5. How to make the program not to wait for the function?
    By maxorator in forum C++ Programming
    Replies: 10
    Last Post: 10-02-2005, 03:02 PM