views:

290

answers:

2

Hi,

as far as i know i can use C++ templates 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

A: 

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.

aaa
+2  A: 

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.

Tom
Is it just the allocators that make STL not compatible with CUDA? If we were to write our own allocators, could we use STL in CUDA?
John Dibling
That is, what i wanted to know ... learned another lection: Next time i'll give the cue STL.
macs