Skip to content

Commit

Permalink
Merge pull request #5 from JPRichings/main
Browse files Browse the repository at this point in the history
updates to slide titles and clarification on what to do in exercises
  • Loading branch information
JPRichings authored Apr 9, 2024
2 parents 86b0745 + 0cc3466 commit 8fb3bf4
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 35 deletions.
15 changes: 15 additions & 0 deletions exercises/complex/README.md
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!
10 changes: 4 additions & 6 deletions exercises/eigen/modules.sh
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

32 changes: 20 additions & 12 deletions exercises/morton-order/instructions.md
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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lectures/algorithms-lambdas-traits/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
template: titleslide

# Algorithms, lambdas, traits
## Rupert Nash
## r.nash@epcc.ed.ac.uk
## James Richings
## j.richings@epcc.ed.ac.uk

---

Expand Down Expand Up @@ -534,7 +534,7 @@ void Comm::send(const std::vector<T>& data, int dest, int tag) {
# Real example
Then we can then provide a specialised defintion for all the types we
Then we can then provide a specialised definition for all the types we
can handle:
```C++
Expand Down
4 changes: 2 additions & 2 deletions lectures/classes/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
template: titleslide
# Classes
## Maurice Jamieson, EPCC
## m.jamieson@epcc.ed.ac.uk
## James Richings, EPCC
## j.richings@epcc.ed.ac.uk


---
Expand Down
6 changes: 3 additions & 3 deletions lectures/cpp-intro/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
template: titleslide

# A brief introduction to C++
## Maurice Jamieson, EPCC
## m.jamieson@epcc.ed.ac.uk
## James Richings, EPCC
## j.richings@epcc.ed.ac.uk

---

Expand Down Expand Up @@ -243,7 +243,7 @@ template: titleslide
---
# Machine choice
You can use your laptop or Cirrus
You can use your laptop or ARCHER2
__Your machine__ : you need a C++ compiler that supports at least
C++11. If you use Windows and MSVC we may not be able to help
Expand Down
29 changes: 25 additions & 4 deletions lectures/eigen/README.md
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
Expand Down Expand Up @@ -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>
```
Expand All @@ -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
6 changes: 3 additions & 3 deletions lectures/loops-containers/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
template: titleslide
# Containers, loops, and iterators
## Rupert Nash
## r.nash@epcc.ed.ac.uk
## James Richings
## j.richings@epcc.ed.ac.uk

???

Expand Down Expand Up @@ -464,7 +464,7 @@ In your clone of this repository, find the `containers` exercise and list
the files
```
$ cd archer2-CPP-2021-07-20/exercises/containers
$ cd archer2-cpp/exercises/containers
$ ls
Makefile test.cpp vector_ex.cpp vector_ex.hpp
```
Expand Down
7 changes: 7 additions & 0 deletions lectures/resources/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
template: titleslide

# Resource management
## James Richings, EPCC
## [email protected]

---
# Resources
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions lectures/templates/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
template: titleslide
# Templates
## Rupert Nash
## r.nash@epcc.ed.ac.uk
## James Richings
## j.richings@epcc.ed.ac.uk

???

Expand Down
4 changes: 4 additions & 0 deletions lectures/threads-1/README.md
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
Expand Down

0 comments on commit 8fb3bf4

Please sign in to comment.