Is a serial code quickly than such one transformed to thread? RRS feed

  • Question

  • I was made simple and very complicated experiments too, when take a serial code and put it in one thread (threads). Execution time increases about two time after that. I’d like to know scientific explanation. As result, two processors (cores) are not enough to increase efficiency of series code because we have two times delay (series code to threads) and some time for synchronization (by events) in some cases.

    I have used in my experiments QuickWin library and Digital Fortran for creation multi-threading. 

    Or may be I mistake?

    Tuesday, July 31, 2012 11:22 AM

All replies

  • Hello,

    This depends on your code and algorithm that you are trying to paralellize. In general, the multi-threaded code will be slower in cases where

    a) the amount of work is very small

    b) transforming from serial to parallel requires heavy synchronization

    c) the algorithm exploits cache locality which can be disrupted in parallel code

    Rahul V. Patil

    Friday, August 10, 2012 6:06 PM
  • Thank you very much Mr. Patil,


    I know about pointed reasons.

    a) the amount of work is not very small

    b) time for synchronization is accounted; I establish increasing time for execution without synchronization about two time. We may take for example very simple code- some cycle which draws square on the screen- one thread only. If transfer this code to thread we may account increasing of the execution time about two times. My basic problem is related to ordinary differential equation integrator development. The time for synchronization is accounted separately. One thread executed on one core (processor) (without any synchronization) takes two times more time than equivalent serial code.

    c) in the simple case pointed above “cache locality“ may not have any signification. I know about example with multiplication of two matrixes with large sizes and the role of “cache locality“. In pointed case we have not operations connected with any cache storage.


    I suppose that transformation serial code to thread’s code may be is connect with some hidden indexing.

    If we have two cores then serial code is quickly than parallel when we have synchronization too or equal if no synchronization; four cores make parallel code quickly than serial one.





    Tuesday, September 4, 2012 7:41 PM