parallel-computing
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| parallel-computing [July 27, 2026 at 14:09] – Ivan Janevski | parallel-computing [August 22, 2026 at 15:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| # Parallel computing | # Parallel computing | ||
| - | **Parallel computing** is a style of programming where a computation is broken into parts that run simultaneously across multiple processors, cores, or machines. The motivation is straightforward: | ||
| - | Not every program benefits equally. [[amdahls-law|Amdahl' | + | **[Parallel computing](https:// |
| + | [[amdahls-law|Amdahl' | ||
| + | |||
| + | ## Example | ||
| + | |||
| + | This example shows a simple parallel computation using OpenMP. | ||
| + | |||
| + | ```c | ||
| + | // compile: gcc -fopenmp -o parallel parallel.c | ||
| + | // run: ./parallel | ||
| + | // description: | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | int main() { | ||
| + | int arr[100]; | ||
| + | for (int i = 0; i < 100; i++) arr[i] = i; | ||
| + | | ||
| + | int sum = 0; | ||
| + | #pragma omp parallel for reduction(+: | ||
| + | for (int i = 0; i < 100; i++) { | ||
| + | sum += arr[i]; | ||
| + | } | ||
| + | | ||
| + | printf(" | ||
| + | return 0; | ||
| + | } | ||
| + | ``` | ||
parallel-computing.1785161349.md.gz · Last modified: by Ivan Janevski
