Error c++11, Mavenized Jcuda

Hi, I’m running Mavenized Jcuda.
I need the unordered sets in the cuda code, therefore I included the c++11 with “nvcc --std=c++11”. I have Cuda 7.5 installed, that is supposed to support the c++11 libraries properly.
I get however the following error:

nvcc process exitValue 2
errorMessage:
/usr/include/c++/4.9/bits/alloc_traits.h(248): error: expected a “>”
detected during instantiation of type “std::allocator_traits<_Alloc>::__has_construct<_Tp, _Args…>”
(251): here

/usr/include/c++/4.9/type_traits(130): error: not a class or struct name
detected during:
instantiation of class “std::_and<_B1> [with _B1=]”
(1957): here
instantiation of type “std::_Require<>”
/usr/include/c++/4.9/bits/alloc_traits.h(251): here

/usr/include/c++/4.9/type_traits(1957): error: class “std::_and<>” has no member “value”
detected during instantiation of type “std::_Require<>”
/usr/include/c++/4.9/bits/alloc_traits.h(251): here

/usr/include/c++/4.9/type_traits(1957): error: class “std::enable_if<, void>” has no member “type”
detected during instantiation of type “std::_Require<>”
/usr/include/c++/4.9/bits/alloc_traits.h(251): here

From my point of view, it looks like mavenized Jcuda uses an older version of Cuda, is it possible?
It calls c++4.9, that is the correct one according to several forums (meaning, the binding should be smooth).
Any help will be deeply appreciated.

*** Edit ***

Update: It seems that if I instead include the files needing the c++11 through a header, the whole system doesn’t complain as much. Weird.

Admittedly, I’m not sure whether I understood this correctly - it sounds like you want to use unordered maps in CUDA kernels.

Although it is resolved, maybe you can try to make this clearer (as it may be relevant for others as well)

  • What do you mean by „unordered sets in the cuda code“? How do you intend to use them in a kernel? (And in fact, unordered maps should not be specific to c++11…)

  • Blindly doing a websearch for something like alloc_traits.h(248): error: expected a ">" brings many results, most of them being related to some Intel compiler bug, but also one stating

It may be that you are trying to compile with CUDA 6.5 and GCC 4.9, this combination is not supported by CUDA.

I’d have to scan through these more thoroughly to figure out which ones really are relevant

  • What did you actually do to solve it? I mean, did you refrain from using C++ in the .CU file?

I think that this is not really related to Mavenized JCuda, so I’m not sure whether I should mention @Mysterion now…

I actually didn’t solve it. I solved a suberror but not the whole of it (I have been busy with something else).

What I try to do is using the following withing a cuda code:

std::unordered_set mySet;

I have to include
#include <unordered_set>

As in here, I tried a similar thing with hashtable - c++ unordered_map compiling issue with g++ - Stack Overflow

But it didn’t work. I have now other problems in my code (see the other post that I posted). But once they’re sorted out, I will try this again and update here if something doesn’t work.

Do you have any other questions for now, or is something still unclear?

I tried to reply, but apparently something went wrong.
[edit SlaterB: had to be unlocked, spam-protection…]

What I tried to do, was simply include (in a file named myfile.cu)
#include<unordered_map>

and use:
std::unordered_set visited;

To do so, I had to run nvcc --std=c++11, that caused the error. I however now am trying to sort out other errors (see my new post), and afterwards I will return to this one, since it seems that I actually didn’t sort this one out (I tried several ways and I got different errors, and I thought that it compiled correctly but instead it didn’t compile at all).

I see, so my assuption that you wanted to use unordered_map in a CUDA kernel was right.

Unfortnuately, this is not possible. You cannot use the STL classes in CUDA kernels. (Note that this is not a limitation of JCuda, but of CUDA in general).

You might also want to have a look at something like Using std::vector in CUDA device code - Stack Overflow - it aimed at vector, but applies to all STL classes.

Implementing an unordered_map (aka hash map) is not entirely trivial. And implementing this for the GPU is a great challenge. The people of CUDPP tackled this, in CUDPP: Overview of CUDPP hash tables . There are also Java bindings for CUDPP ( jcuda.org - JCudpp ), but since CUDPP is a bit tedious to compile, it is not updated with each new CUDA version (the latest one at jcuda.org - Downloads is for CUDA 7).

I’d strongly recommend you to try finding a solution that works without unordered maps. What would you use as the “key” for this map? Of course, being able to emulate this with an array would be perfect, but sometimes, this is not easy, and sometimes not possible at all…

I honestly don’t want specifically a hashmap ( I mistyped above one out of 4). I just need a hashset. Or a set, if there is any. Just because I don’t know how many items will go there, and allocating too much memory is always a problem (at least, from my short experience). And I didn’t really want to realloc every time due to speed and memory problems. I guess that a list would be fine (read: structure that points to another istance of itself). I however managed without it, although I fear the performance is not as high. Thank you for the explanation!