There was an error while loading. Please reload this page.
1 parent 4728d12 commit 118a36fCopy full SHA for 118a36f
1 file changed
docs/day4/parallel.rst
@@ -434,6 +434,24 @@ in Python rather than learning to write those codes.
434
Optional flags for ``srun`` for writing output and error files are ``-o output_%j.out -e error_%j.err`` instead
435
of writing on the terminal screen.
436
437
+ **Data dependencied**
438
+
439
+ In general, one cannot parallelize an serial algorithm; let's take the case of:
440
441
442
+ .. code-block:: python
443
444
+ a[0] = 0
445
+ for i in range(1, N):
446
+ a[i] = a[i-1] + i
447
448
+ Here, the iteration *i* depends on the previous iteration *i-1*. One needs to transform this algorithm:
449
450
451
452
+ for i in range(N):
453
+ a[i] = 0.5 * i * (i + 1)
454
455
456
457
2D integration
0 commit comments