As far as I know I can use C++ temp开发者_如何学Clates in CUDA device code. So If i'm using map to create a dictionary will the operation of inserting new values be atomic?
I want to count the number of appearances of a certain values, i.e. create a code-dictionary with probabilities of the codes.
Thanks
Macs
You cannot use STL within device code. You could check thrust for similar functionality (check the experimental namespace in particular).
Templates are fine in device code, CUDA C currently supports quite a few C++ features although some of the big ones such as virtual functions and exceptions are not yet possible ( and will only be possible on Fermi hardware).
If you decide to implement this yourself, you can use the atomicAdd() intrinsic to get an atomic operation, check out the CUDA Programming Guide for more information.
if I understand your question correctly, you are trying to use STL map inside cuda? most likely it is not going to work. You will have to devise your own implementation. You may be able to find implementation in thrust library however.
精彩评论