brian-team / brian2cuda

A brian2 extension to simulate spiking neural networks on GPUs
https://brian2cuda.readthedocs.io/
GNU General Public License v3.0
61 stars 12 forks source link

Add atomics support for all in-place operations #142

Open denisalevi opened 6 years ago

denisalevi commented 6 years ago

Currently I implemented atomic operations only for +=, -=, *=, /=. For other in-place operations we fall back to serialized effect application. But we can implement any in-place operation with atomicCAS.

@mstimberg Which in-place operations does brian support? And have you ever seen anything else but those standard in-place operations I mentioned above?

mstimberg commented 6 years ago

In principle we also support **= and %=, but I don't think I've ever seen them used "in the wild".

denisalevi commented 6 years ago

@mstimberg **= gives me an AssertionError: Unknown operator "**=". I guess its not supported? And when %= is used with not integer types, I get a compiler error (not caught by brian), just for your information :)

Started implementing and testing these in the issue142_atomic_inplace_operations branch. Tests should be extended for different datatypes (float ('v : 1') with default_float_dtype = float32/float64 and integer ('v : integer'). And currently there is something going wrong for the /= atomic operation? Leaving this for later.