https://github.com/hvass-labs/parallel-pipelines
Convert serial computations into parallel pipelines
https://github.com/hvass-labs/parallel-pipelines
audio cpp parallel-computing
Last synced: 6 months ago
JSON representation
Convert serial computations into parallel pipelines
- Host: GitHub
- URL: https://github.com/hvass-labs/parallel-pipelines
- Owner: Hvass-Labs
- License: mit
- Created: 2022-09-13T11:24:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-02T10:09:49.000Z (about 3 years ago)
- Last Synced: 2025-02-09T09:12:47.681Z (8 months ago)
- Topics: audio, cpp, parallel-computing
- Language: C++
- Homepage:
- Size: 151 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parallel Pipelines for Streaming Data
[Original repository on GitHub](https://github.com/Hvass-Labs/Parallel-Pipelines)
Original author is [Magnus Erik Hvass Pedersen](http://www.hvass-labs.org)
## Introduction
This is a demonstration using C++ source-code of a little-known method for parallelizing the computation of serially dependent functions on streaming data, which is a particular kind of Parallel Pipeline. It can be used to turn a serial computation into a parallel computation whenever you have serially chained or nested functions that are working on streaming data.
For example, in audio processing this can be used to make audio effects that are connected in series instead run in parallel on multiple CPU cores. This can be used to greatly improve the multi-core CPU efficiency of Digital Audio Workstations (DAW).
All of this is explained in more detail in the [paper](https://github.com/Hvass-Labs/Parallel-Pipelines/raw/main/pedersen2022parallel-pipelines.pdf).
## Example
Consider the expression `y[i] = G(F(x[i]))` where `F` and `G` are some functions, and `x[i]` is the input data and `y[i]` is the output data for index `i`. Because the output of the function `F` is used as the input to the function `G`, and because the computations must be made in the correct order on the index `i`, the two functions are said to be serially dependent and it may seem impossible to calculate them in parallel.
But when `x[i]` is just one element in a stream of data e.g. with `i` going from `0` to some value `n-1`, then we can parallelize the nested computation of the functions `F` and `G` by first computing `F(x[i])` in one thread and saving the result in a variable called `F_buffer`, and in the second thread we then use the buffer that was written in the previous iteration to compute `y[i-1] = G(F_buffer)`. Once the two threads are both finished with their computations, we update `F_buffer` with the new result from the function `F`. This can be written as simplified pseudo-code:
for (int i=0; i