SixTrack / sixtracklib

Library for single charged particle simulations in accelerators
GNU Lesser General Public License v2.1
12 stars 16 forks source link

Fixes issues in python CudaTrackJob; provides example for pycuda interaction #83

Closed martinschwinzerl closed 5 years ago

martinschwinzerl commented 5 years ago

Important: If the pycuda clean-up routines kick in before pysixtracklib elements such as CudaController, CudaArgument, CudaTrackJob are destroyed, the device memory regions will be invalidated.

In order to avoid this, it is suggested to stick to this sequence:

This is the sequence implemented in the example file examples/python/pycuda_particle_addr.py

Failing to do things properly may result in all kind of problems resulting from accessing already freed memory but will, positively, result in hitting an assert statement in the C++ CudaController destructor if the library has been compiled in debug mode (i.e. with cmake .. -DCMAKE_BUILD_TYPE=Debug). Watch out for the message

python: sixtracklib/cuda/control/controller.cpp:374:
virtual sixtrack::CudaController::~CudaController(): Assertion `( err == ::cudaSuccess )' failed.
Aborted (core dumped)