ArticleslgStudy

computer science

Task parallelism

Task parallelism is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Task parallelism rather than just read about it. In short: Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple processors in parallel computing environments. Task parallelism focuses on distributing tasks—concurrently performed by processes or threads—across different processors.

Key takeaways

  • Task parallelism belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Task parallelism to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Task parallelism from memory before moving on to harder problems.

Reference excerpt

Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple processors in parallel computing environments. Task parallelism focuses on distributing tasks—concurrently performed by processes or threads—across different processors. In contrast to data parallelism which involves running the same task on different components of data, task parallelism is distinguished by running many different tasks at the same time on the same data. A common type of task parallelism is pipelining, which consists of moving a single set of data through a series of separate tasks where each task can execute independently of the others.

Description In a multiprocessor system, task parallelism is achieved when each processor executes a different thread (or process) on the same or different data. The threads may execute the same or different code. In the general case, different execution threads communicate with one another as they work, but this is not a requirement. Communication usually takes place by passing data from one thread to the next as part of a workflow. As a simple example, if a system is running code on a 2-processor system (CPUs "a" & "b") in a parallel environment and we wish to do tasks "A" and "B", it is possible to tell CPU "a" to do task "A" and CPU "b" to do task "B" simultaneously, thereby reducing the run time of the execution. The tasks can be assigned using conditional statements as described below. Task parallelism emphasizes the distributed (parallelized) nature of the processing (i.e. threads), as opposed to the data (data parallelism). Most real programs fall somewhere on a continuum between task parallelism and data parallelism. Thread-level parallelism (TLP) is the parallelism inherent in an application that runs multiple threads at once. This type of parallelism is found largely in applications written for commercial servers such as databases. By running many threads at once, these applications are able to tolerate the high amounts of I/O and memory system latency their workloads can incur - while one thread is delayed waiting for a memory or disk access, other threads can do useful work. The exploitation of thread-level parallelism has also begun to make inroads into the desktop market with the advent of multi-core microprocessors. This has occurred because, for various reasons, it has become increasingly impractical to increase either the clock speed or instructions per clock of a single core. If this trend continues, new applications will have to be designed to utilize multiple threads in order to benefit from the increase in potential computing power. This contrasts with previous microprocessor innovations in which existing code was automatically sped up by running it on a newer/faster computer.

Example The pseudocode below illustrates task parallelism:

program: ... if CPU = "a" then do task "A" else if CPU="b" then do task "B" end if ... end program

The goal of the program is to do some net total task ("A+B"). If we write the code as above and launch it on a 2-processor system, then the runtime environment will execute it as follows.

In an SPMD (single program, multiple data) system, both CPUs will execute the code. In a parallel environment, both will have access to the same data. The "if" clause differentiates between the CPUs. CPU "a" will read true on the "if" and CPU "b" will read true on the "else if", thus having their own task. Now, both CPU's execute separate code blocks simultaneously, performing different tasks simultaneously. Code executed by CPU "a":

program: ... do task "A" ... end program

Code executed by CPU "b":

program: ... do task "B" ... end program

This concept can now be generalized to any number of processors.

Language support Task parallelism can be supported in general-purpose languages by either built-in facilities or libraries. Notable examples include:

Ada: Tasks (built-in) C++ (Intel): Threading Building Blocks C++ (Intel): Cilk Plus C++ (Open Source/Apache 2.0): RaftLib C, C++, Objective-C, Swift (Apple): Grand Central Dispatch D: tasks and fibers Delphi (System.Threading.TParallel) Go: goroutines Java: Java concurrency .NET: Task Parallel Library Examples of fine-grained task-parallel languages can be found in the realm of Hardware Description Languages like Verilog and VHDL.

See also Algorithmic skeleton Data parallelism Fork–join model Parallel programming model

References

Worked examples

Example 1 — a first encounter with Task parallelism

Start with the simplest possible case. Write down what Task parallelism claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Task parallelism before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Task parallelism ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Task parallelism

In research
Task parallelism appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Task parallelism in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Task parallelism is common in secondary-school and first-year university syllabi. It links to neighbouring topics Parallel computing, Threads (computing), so understanding it makes those chapters shorter.
In everyday life
Look for Task parallelism outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Task parallelism” →

How to study Task parallelism in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Task parallelism means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Task parallelism out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Task parallelism in simple terms?

Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple processors in parallel computing environments. Task parallelism focuses on distributing tasks—concurrently performed by processes or threads—across different p…

Why does Task parallelism matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Task parallelism?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Task parallelism.

Tags

  • Parallel computing
  • Threads (computing)

Keep exploring