4

Now I am studying parallel computing and algorithms I am little bit confused about the terms concurrent execution and simultaneous execution.

What is the difference between these terms? When do we have to use concurrent and when do we have to use simultaneous in parallel computing?

Mureinik
  • 297,002
  • 52
  • 306
  • 350

1 Answers1

9

Simultaneous execution is about utilizing multiple resources (cores, HW threads, etc..) in order to perform multiple tasks at the same time. The tasks don't have to interact in any way, you may have two different applications running simultaneously on two different cores for example, or on the same core.
The art of designing systems to be able to perform multiple tasks at the same time can be said to deal with simultaneous execution. Hyper-threading for e.g. is also called "SMT", simultaneous multi-threading, since it deals with the ability to run two threads with their full contexts at the same time on a single core (This is Intels' approach, AMD has a slightly different solution, see - Difference between intel and AMD multithreading)

Concurrency is a term residing on a higher level of abstraction, relating to the OS world. It's a property of your execution environment in which you have multiple tasks that may be executed over time, while you have no control over the order or even the form of interleaving in which they're performed. It doesn't really matter if they operate simultaneously on multiple cores, on one core with SMT, or even on a single-threaded core with some preemption mechanism and some scheduling algorithm that breaks the tasks into chunks and constantly swaps between them. The important thing here is that concurrency forces you to design your tasks in a way that guarantees correctness (especially if they interact or share data) on any type of system with any order or interleaving.

If the task is designed correctly (with proper locking, barriers, semaphores, and anything guaranteeing correct data flow) and the OS does its job properly (saving states on context switch for example or clearing caches and shooting down TLB entries when needed), then it can run with any form of execution model "under the hood".

Since you're referring to parallel algorithms, the proper term for you is probably concurrent execution.

There are quite a lot of examples in this thread (with additional links to sources - I won't copy it here to avoid plagiarism :) - What is the difference between concurrency and parallelism?

Leeor
  • 19,260
  • 5
  • 56
  • 87
  • I like this answer.But still i do have a doubt. Can you elaborate on this:"...Simultaneous multi-threading, since it deals with the ability to run two threads with their full contexts at the same time on a single core...". I mean is it possible for 2 threads to exceute at exactly the same time on a single core. – Farhan stands with Palestine Oct 02 '14 at 13:43
  • @ShirgillAnsari, that is the concept of simultaneous multi-threading. The hardware duplicates some of the components (logical registers and architectural state elements), splits others (some of the queues for example), and shares the rest (caches, predictors, random allocation arrays). The implementations may differ per CPU, but some may allow you to issue and commit instructions from the multiple contexts on every cycle, while others may arbitrate between them on every cycle, but instructions from different contexts will still coexist in the pipeline together, without need for context switch. – Leeor Oct 02 '14 at 14:42
  • You said, "Simultaneous execution is about utilizing multiple cores". As per my understanding your answer suggests that Simultaneous execution is not possible on a single core. Am i correct? – Farhan stands with Palestine Oct 02 '14 at 17:25
  • @ShirgillAnsari, I wrote "Simultaneous execution is about utilizing multiple *resources*", one such example is multi cores (often called CMP) - it's easy to understand how each core can progress regardless of the others with minimal contention (only some conflicts on shared caches and buses). Another example is simultaneous multi threading (SMT), where you can have multiple contexts even in the same core. These don't contradict, but rather complete each other, creating a total number of logical cores that can execute simultaneously in a given CPU. Other forms of parallelism also exist. – Leeor Oct 02 '14 at 17:50