Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPoppleton committed Oct 7, 2024
2 parents a168f8d + 306a276 commit 8ba1129
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/source/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cd build # enter the build folder (see above)
make -j4 # compile the updated source
```

If you also want to update `oxpy` don't forget to run `make install` after the compilation.
If you also want to update `oxpy` and `OAT` don't forget to run `make install` after the compilation.

### CMake options

Expand Down Expand Up @@ -104,6 +104,7 @@ cmake -DPython=1 -DPYTHON_EXECUTABLE=$HOME/miniconda3/bin/python -DPYTHON_INCLUD
## Known issues

* An `illegal instruction` is sometimes issued when the code is compiled on a CPU architecture and run on another, or when specific combinations of CPU architecture and compiler are used. Invoke CMake with `-DNATIVE_COMPILATION=Off` and re-compile the code to fix the issue.
* When compiling oxDNA with Python support on Microsoft's WSL, if the local repository is downloaded in Windows (*i.e.*, outside WSL), tests and analysis scripts may fail (see [this issue](https://github.com/lorenzo-rovigatti/oxDNA/issues/122#issue-2499923060)). To avoid these problems, clone the repository directly within the WSL environment.
* A list of other known issues can be browsed online [here](https://github.com/lorenzo-rovigatti/oxDNA/issues).


Expand Down
30 changes: 30 additions & 0 deletions docs/source/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,36 @@ When running CUDA-powered simulations, the box size has a non-trivial effect on

Since there is no dynamic memory on GPUs, in order to avoid crashing simulations oxDNA sets the size of the cells used to build neighbouring lists so that their memory footprint is not too high. If you want to optimise performance is sometimes worth to set `cells_auto_optimisation = false` so that oxDNA uses the smallest possible cells (at the cost of memory consumption). If the resulting memory footprint can be handled by your GPU you'll probably see some (possibly large) performance gains.

There are some heuristics that attempt to limit the memory consumption of CUDA simulations. First of all, the given combination of parameters is used to evaluate the minimum size of the cells required to build neighbouring lists, $r_m$. In turn, $r_m$ is used to compute the number of cells along each coordinate $i$ (where $i = x, y, z$) as

$$
N_i = \max(\lfloor L_i / r_m \rfloor, 3),
$$

where $L_i$ is the length of the box edge along the $i$-th direction. This value of $N_i$ is the number of cells used for the simulation if `cells_auto_optimisation` is set to `false`. However, if it set to `true`, which is the default, then the code checks whether $N_i > \lceil f L_i \rceil$, and if it is then sets

$$
N_i = f L_i,
$$

where

$$
f = \left( \frac{2 N}{L_x L_y L_z} \right)^{1/3}.
$$

The maximum number of particles that are in each given cell, $M$, is another important parameter that can be, to some extent, tuned to avoid crashes. It is defined at the beginning of the simulation, and also each time the total number of cells changes while the simulation is running, as

$$
M = f_\rho M_\text{max},
$$

where $f_\rho$ is a factor that can be set with the `max_density_multiplier` option and defaults to 3, while $M_\text{max}$ is the number of particles found in the cell containing the largest amount of particles in the current configuration.

:::{note}
On newer versions of oxDNA (> 3.6.1), setting `debug = true` will report in the log file (or on screen if `log_file` is not set) the amount of memory that is requested by each allocation on the GPU.
:::

## Monte Carlo

When running Monte Carlo simulations the efficiency of the sampling depends on specific moves employed during the simulation. For regular Monte Carlo and VMMC simulations, the most important options are `delta_translation` and `delta_rotation`, which set the maximum displacement for translations and rotations. Optimal values depend very much on the system at hand, so it is hard to provide some guidelines, although often values around `0.1` given decent performance. Sometimes it may be worth to set [`adjust_moves = true` (together with `equilibration_steps > 0`)](input.md#monte-carlo-options) to let the code look for optimal values.
2 changes: 2 additions & 0 deletions src/CUDA/CUDAUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class GpuUtils {

template<typename T>
cudaError_t GpuUtils::LR_cudaMalloc(T **devPtr, size_t size) {
OX_LOG(Logger::LOG_DEBUG, "Allocating %lld bytes (%.2lf MB) on the GPU", size, size / 1000000.0);

GpuUtils::_allocated_dev_mem += size;
return cudaMalloc((void **) devPtr, size);
}
Expand Down
11 changes: 10 additions & 1 deletion src/Interactions/DRHInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,16 @@ void DRHInteraction::allocate_particles(std::vector<BaseParticle*> &particles) {
}
}

int N_in_strand = sequence.size();
//Needed here to read custom bases
std::vector<int> btypes;
try {
btypes = Utils::btypes_from_sequence(sequence);
}
catch(oxDNAException &e) {
throw oxDNAException("topology file, strand %d (line %d): %s", ns, ns + 1, e.what());
}

int N_in_strand = btypes.size();
for(int i = 0; i < N_in_strand; i++, current_idx++) {
if(current_idx == parser.N()) {
throw oxDNAException("Too many particles found in the topology file (should be %d), aborting", parser.N());
Expand Down
2 changes: 1 addition & 1 deletion src/Observables/KineticEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ number KineticEnergy::get_kinetic_energy() {
std::string KineticEnergy::get_output_string(llint curr_step) {
number K = get_kinetic_energy();

return Utils::sformat("% 10.6lf", K);
return Utils::sformat(_number_formatter, K);
}
3 changes: 2 additions & 1 deletion src/Observables/TotalEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ std::string TotalEnergy::get_output_string(llint curr_step) {
number U = get_U(curr_step);
number K = get_K(curr_step);

return Utils::sformat("% 10.6lf % 10.6lf % 10.6lf", U, K, U + K);
std::string format = Utils::sformat("%s %s %s", _number_formatter.c_str(), _number_formatter.c_str(), _number_formatter.c_str());
return Utils::sformat(format, U, K, U + K);
}

number TotalEnergy::get_U(llint curr_step) {
Expand Down

0 comments on commit 8ba1129

Please sign in to comment.