-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from JPRichings/main
updates to slide titles and clarification on what to do in exercises
- Loading branch information
Showing
11 changed files
with
88 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
In your clone of this repository, find the `complex` exercise and list the files | ||
|
||
``` | ||
$ cd archer2-cpp/exercises/complex$ ls Makefile complex.cpp complex.hpp test.cpp | ||
``` | ||
|
||
The files `complex.hpp` and `complex.cpp` contain a partially working complex number class and `test.cpp` holds some basic unit tests. | ||
|
||
You can compile and run with: | ||
|
||
``` | ||
$ make && ./testc++ --std=c++14 -I../include -c -o complex.o complex.cppc++ --std=c++14 -I../include -c -o test.o test.cppc++ complex.o test.o -o test===============================================================================All tests passed (34 assertions in 6 test cases) | ||
``` | ||
|
||
But to get to this point you need to complete the code and fix a few bugs! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/bin/bash | ||
module purge | ||
module load spack | ||
module load eigen-3.3.7-gcc-6.3.0-qka5wf6 | ||
module load clang | ||
module load gnuplot/5.0.5-x11 | ||
module load intel-compilers-18 | ||
module load PrgEnv-gnu | ||
module load cray-python | ||
module load eigen/3.4.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
|
||
# Morton order matrices in C++ | ||
## Rupert Nash | ||
## [email protected] | ||
## James Richings | ||
## [email protected] | ||
|
||
|
||
# Sample code | ||
|
||
Source for this can be obtained from Github. Get a new copy with: | ||
|
||
``` | ||
git clone https://github.com/EPCCed/archer2-CPP-2021-07-20 | ||
git clone https://github.com/EPCCed/archer2-cpp | ||
``` | ||
|
||
or update your existing one with | ||
|
@@ -17,26 +21,28 @@ git pull | |
then you can | ||
|
||
``` | ||
cd archer2-CPP-2021-07-20/exercises/morton-order | ||
cd archer2-cpp/exercises/morton-order | ||
``` | ||
|
||
# Morton ordering | ||
|
||
The Morton ordering (or z-ordering) of a matrix lays out the elements | ||
along a recursive z-shaped curve, as shown in the figure of four | ||
iterations of the Z-order curve (from | ||
[Wikipedia](https://en.wikipedia.org/wiki/Z-order_curve)). | ||
[z ordered curve](https://en.wikipedia.org/wiki/Z-order_curve)). | ||
|
||
![Morton order](mortonorder.png) | ||
# Indices | ||
|
||
You can compute the Morton index `z` from the x- and y-indices (`i` | ||
and `j` respectively) by interleaving their bits. An example is shown | ||
in the table. | ||
|
||
| | 0 | 1 | 2 | 3 | | ||
|----|----|----|----|----| | ||
| 0 | 0| 1| 4| 5| | ||
| 1 | 2| 3| 6| 7| | ||
| 2 | 8| 9| 12| 13| | ||
| 3 | 10| 11| 14| 15| | ||
| 0 | 0| 1| 4| 5 | | ||
| 1 | 2| 3| 6| 7| | ||
| 2 | 8| 9| 12| 13| | ||
| 3 | 10| 11| 14| 15| | ||
|
||
Mapping between `x-y` indexes and Morton index for a 4 by 4 | ||
matrix. Decimal on the left and binary on the right. | ||
|
@@ -51,6 +57,8 @@ matrix. Decimal on the left and binary on the right. | |
Mapping between `x-y` indexes and Morton index for a matrix of size | ||
4-by-4. Decimal on the left and binary on the right. | ||
|
||
|
||
|
||
The advantage of laying out data in this way is that it improves data | ||
locality (and hence cache use) without having to tune a block size or | ||
similar parameter. On a modern multilevel cache machine[^1], this | ||
|
@@ -76,7 +84,7 @@ number. | |
Go to the step 1 directory: | ||
|
||
```bash | ||
cd archer2-CPP-2021-07-20/exercises/morton-order/step1 | ||
cd archer2-cpp/exercises/morton-order/step1 | ||
``` | ||
|
||
Using the partial implemenation in `matrix.hpp`, your task is to | ||
|
@@ -95,7 +103,7 @@ supplied `Makefile` should work. | |
Go to the step 2 directory: | ||
|
||
```bash | ||
cd archer2-CPP-2021-07-20/exercises/morton-order/step2 | ||
cd archer2-cpp/exercises/morton-order/step2 | ||
``` | ||
|
||
I have a potential solution to part 1 here, but feel free to copy your | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
template: titleslide | ||
# Linear Algebra for C++ (using Eigen) | ||
## Joseph Lee, EPCC | ||
## j.lee@epcc.ed.ac.uk | ||
## James Richings, EPCC | ||
## j.richings@epcc.ed.ac.uk | ||
|
||
--- | ||
# Source | ||
|
||
Original: | ||
- Chris Richardson ([email protected]) | ||
- Rupert Nash ([email protected]) | ||
- Joseph Lee ([email protected]) | ||
--- | ||
|
||
# Rundown | ||
|
@@ -448,8 +449,9 @@ The matrix A is very similar - just flip the sign of the delta terms | |
--- | ||
# Exercise: Diffusion equation (sparse) | ||
Hints: | ||
There is also a way to implement this example using the sparse matrix interface in eigen. | ||
Some changes to look out for in the `sparse.cpp` example: | ||
```C++ | ||
#include <Eigen/Sparse> | ||
``` | ||
|
@@ -468,4 +470,23 @@ for (int i = 0; i < n - 1; ++i) | |
A.setFromTriplets(fill.begin(), fill.end()); | ||
``` | ||
|
||
See `exercises/eigen/sparse.cpp` | ||
See `exercises/eigen/sparse.cpp` | ||
|
||
--- | ||
# Exercise: Diffusion equation 3 ways | ||
|
||
- Use `modules.sh` to load correct environment on ARCHER2 | ||
|
||
- Compile the examples using `make` | ||
|
||
- Run each of the three examples explicit, implicit and sparse | ||
|
||
- Generate the movie using the provided python script | ||
|
||
To view the movie you will need to either: | ||
- Download the data and generate it locally | ||
|
||
or | ||
|
||
- Set up a python virtual environment on ARCHER2 with matplotlib | ||
- User `ssh -X` to view graphics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
template: titleslide | ||
|
||
# Resource management | ||
## James Richings, EPCC | ||
## [email protected] | ||
|
||
--- | ||
# Resources | ||
|
@@ -779,3 +782,7 @@ etc wrapped here. | |
Try out some of this with exercises/morton-order | ||
Instructions can be found here: | ||
archer2-cpp/exercises/morton-order/instructions.md | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
template: titleslide | ||
|
||
# C++ Threads - Basics | ||
## James Richings, EPCC | ||
## [email protected] | ||
|
||
--- | ||
|
||
# Overview | ||
|
||
- Introduction | ||
|