make accelerate-cuda thread safe

This makes it possible to, for example, 'parMap' an accelerate function resulting from 'run1'.

In particular, this requires locking the memory tables. The implementation still uses one table per application, so it may be necessary to move to one table per capability to improve scalability.