Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:48:13+00:00 2026-05-20T10:48:13+00:00

Appendix D of the 3.2 version of the CUDA documentation refers to C++ support

  • 0

Appendix D of the 3.2 version of the CUDA documentation refers to C++ support in CUDA device code.
It is clearly mentioned that CUDA supports “Classes for devices of compute capability 2.x”. However, I’m working with devices of compute capability 1.1 and 1.3 and I can use this feature!

For instance, this code works:

// class definition voluntary simplified
class Foo {
  private:
    int x_;

  public:
    __device__ Foo() { x_ = 42; }
    __device__ void bar() { return x_; }
};


//kernel using the previous class
__global__ void testKernel(uint32_t* ddata) {
    Foo f;
    ddata[threadIdx.x] = f.bar(); 
}

I’m also able to use widespread libraries such as Thrust::random random generation classes.
My only guess is that I’m able to do so thanks to the automatic inlining of __device__ marked function, but this does not explain the handling of member variables withal.

Have you ever used such features in the same conditions, or can you explain to me why my CUDA code behaves this way? Is there something wrong in the reference guide?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:48:13+00:00Added an answer on May 20, 2026 at 10:48 am

    Oficially, CUDA has no support for classes on devices prior to 2.0.

    Practically, from my experience, you can use all C++ features on all devices as long as the functionality can be resolved at compile-time. Devices prior to 2.0 do not support function calls (all functions are inlined) and no program jumps to a variable address (only jumps at constant address).

    This means, you can use the following C++ constructs:

    • Visibility (public/protected/private)
    • non-virtual inheritance
    • whole template programming and metaprogramming (until you stuble on nvcc bugs; there are quite a few of them as of version 3.2)
    • constructors (except when object is declared in __ shared __ memory)
    • namespaces

    You cannot use the following:

    • new & delete operators (I believe devices >=2.0 can do that)
    • virtual methods (requires jumps at variable address)
    • function recursion (requires function calls)
    • exceptions

    Actually, all examples in chapter D.6 of the CUDA Programming Guide can compile for devices <2.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've taken a code from here (SO) that crops images. I tried it on
I'm planning to put some Java code in an appendix to my report. The
I'd like to add a code appendix to my LyX document. There are a
I've read through the FAQ of Android Dev Guid (http://developer.android.com/guide/appendix/faq/commontasks.html#opennewscreen ) but I'm not
As it is a looong appendix, I would like to add a tableofSECTION on
I am trying to insert a PDF or doc file as an appendix in
In my Master thesis i want to append a paper as an appendix to
I was programming the example code from Frank Luna's book Introduction to 3D Game
Possible Duplicate: hide an entry from Toc in latex Appendix A Section 1 A.1
I'm using Saxon-EE 9.3.0.4 for xsl transformations and found that when <xsl:result-document> is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.