Skip to content

Commit 1e53625

Browse files
committed
add instructions to add new backends
1 parent 7e1d0b5 commit 1e53625

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ As a rule of thumb (from our experience with Veros), the performance of a Fortra
6969
For CPU:
7070

7171
```bash
72-
$ conda create -f environment_cpu.yml
72+
$ conda create -f environment-cpu.yml
7373
$ conda activate pyhpc-bench-cpu
7474
```
7575

7676
GPU:
7777

7878
```bash
79-
$ conda create -f environment_gpu.yml
79+
$ conda create -f environment-gpu.yml
8080
$ conda activate pyhpc-bench-gpu
8181
```
8282

@@ -195,3 +195,22 @@ Lessons I learned by assembling these benchmarks: (your mileage may vary)
195195
## Contributing
196196

197197
Community contributions are encouraged! Whether you want to donate another benchmark, share your experience, optimize an implementation, or suggest another backend - [feel free to ask](https://github.com/dionhaefner/pyhpc-benchmarks/issues) or [open a PR](https://github.com/dionhaefner/pyhpc-benchmarks/pulls).
198+
199+
### Adding a new backend
200+
201+
Adding a new backend is easy!
202+
203+
Let's assume that you want to add support for a library called `speedygonzales`. All you need to do is:
204+
205+
- Implement a benchmark to use your library, e.g. `benchmarks/equation_of_state/eos_speedygonzales.py`.
206+
- Register the benchmark in the respective `__init__.py` file, by adding `speedygonzales` to its `__implementations__` tuple.
207+
- Register the backend, by adding its setup function to the `__backends__` dict in `backends.py`.
208+
209+
A setup function is what is called before every call to your benchmark, and can be used for custom setup and teardown. In the simplest case, it is just
210+
211+
```python
212+
def setup_speedygonzales(device='cpu'):
213+
# code to run before benchmark
214+
yield
215+
# code to run after benchmark
216+
```

0 commit comments

Comments
 (0)