developing.md

Developing dust

As the project has grown, we've added a few processes around updating parts of the package.

Adding features

Adding new methods to the dust object requires a few steps (most of which will be caught by CI)

Versioning

All PRs, no matter small, must increase the version number. This is enforced by github actions. We aim to use semanitic versioning as much as is reasonable, but our main aim is that all commits to master are easily findable in future.

Random number library

We keep the random number library in inst/include/dust so that it does not depend on anything else in the source tree so that it could be reused in other projects (R or otherwise).

To update the underlying generator code with the reference implementations at https://prng.di.unimi.it/ you should run the script at ./extra/generate.sh which will download, compile, and run small programs with the upstream implementation and write out reference output in the test directory.

Headers

As the project has become more complex, keeping the headers under control has become harder. Basic principles here:

The script scripts/check_headers will validate that headers are self contained and that only interface headers include cpp11 files (directly or indirectly).

Documentation

There are lots of places to consider putting documentation

Debugging cuda

R -d cuda-gdb

It might be useful to set this:

set cuda api_failures stop

Then start the process by running r <enter> and all the usual gdb things work reasonably well.

To find memory errors, compile a model with gpu = dust::dust_cuda_options(debug = TRUE) to enable debug symbols, then run with

R -d cuda-memcheck

which will report the location of invalid access.

Using printf() within kernels works fine, though it does make a mess of the screen.

Finding unexpcted double precision code

You want the -warn-double-usage argument, passed via -Xptxas.

gpu <- dust::dust_cuda_options(
  fast_math = TRUE, profile = FALSE, quiet = FALSE, debug = FALSE,
  flags = paste("--keep --source-in-ptx --generate-line-info",
                "-Xptxas -warn-double-usage"))

The additional flags are required to make this nice to use:



mrc-ide/dust documentation built on May 11, 2024, 1:08 p.m.