Pouya BCD
Pouya BCD

Reputation: 1031

Can I use C++ header files in kernel part of a CUDA code?

I want to compare two strings in a kernel function. Can I use strcomp in file? Generally, can I use C++ libraries in my CUDA code?

Upvotes: 1

Views: 2112

Answers (1)

Brooks Moses
Brooks Moses

Reputation: 9537

It would surprising if the CUDA libraries include a kernel-side version of the C++ standard library, which you would need in order for this to work, since (as Paul R noted in a comment), this and many other standard functions are not particularly appropriate for GPU acceleration.

According to the CUDA language rules, only __device__ functions are callable from the Device. Functions such as strcmp are not declared as __device__ in the C++ standard library, so if the CUDA language does not include them as extensions -- and it does not, since the CUDA Programming Guide does not include any documentation of them -- then they cannot be used in kernels.

What happened when you tried it?

Upvotes: 1

Related Questions