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 8726325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:13:19+00:00 2026-06-13T08:13:19+00:00

http://developer.download.nvidia.com/CUDA/training/GTC_Express_Sarah_Tariq_June2011.pdf In the above tutorial (slide 29), they initiate 3 pointers to ints: int

  • 0

http://developer.download.nvidia.com/CUDA/training/GTC_Express_Sarah_Tariq_June2011.pdf

In the above tutorial (slide 29), they initiate 3 pointers to ints:

int *a, *b, *c;

Clearly this is of type (int *), yet they somehow make it possible for the kernel to access its indices with syntax a[index]

They also use some (to me) unknown command to initialize their values:

a = (int *)malloc(size); random_ints(a, N);

So what does this command do? First it casts the pointer *a to point to an int (but later on a magically becomes a vector). I can’t find any sources on what random_ints precisely does (and my compiler doesn’t recognize it either because it probably requires some include). I guess it makes a a vector of length N with random ints (though a is of type int).

I tried working around this by doing the same thing with vector <int> * a; etc etc but I still have trouble passing that to my kernel (it won’t add the elements no matter what I try).

I’m working in C++. Thanks in advance.

Edit: could this be pseudocode? Because the explicit C++ example does this in a different (comprehensible way)

  • 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-06-13T08:13:20+00:00Added an answer on June 13, 2026 at 8:13 am
    • You can use pointer in C/C++ in the way like normal array. See:

    Example

    int* p = new int[2];
    p[1] = 2;  
    *(p + 1) = 2; // same as line above - just other syntax
    *(1 + p) = 2; // and other way
     1[p] = 2; // don't use it - but still valid
    
    • You can allocate memory by malloc in C++ (it is derived from C way) but only for POD types, like int

    Example

    int* p = (int*)malloc(12 * sizeof(int)); // C way equivalent to C++: new int [12]
    

    Be aware that you must free this pointer by free(p), not by delete [] p.

    • I guess the implementation of this function is just assigning N random numbers to int array represented by pointer:

    Example:

    void random_ints(int* a, int N)
    {
       int i;
       for (i = 0; i < N; ++i)
        a[i] = rand();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the FFT2D paper http://developer.download.nvidia.com/compute/cuda/2_2/sdk/website/projects/convolutionFFT2D/doc/convolutionFFT2D.pdf in the figure 1 and 2 it's stated that:
I've implemented Cascaded Shadow Mapping as in the nvidia SDK (http://developer.download.nvidia.com/SDK/10.5/Samples/cascaded_shadow_maps.zip). However my lookup
Came across this implementation of FxAA from NVidia. http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf http://timothylottes.blogspot.in/2011/12/fxaa-40-stills-and-features.html The source code as
I am following these instructions: http://developer.android.com/guide/market/billing/billing_integrate.html#billing-download and they say to open the Android SDK
As seen in this page: http://developer.apple.com/ios/manage/distribution/index.action , under the Create and download your iOS
I want to use this project: http://developer.android.com/resources/samples/ActionBarCompat/index.html How can I download all files at
I don't quite understand the SWFObject examples downloaded http://download.macromedia.com/pub/developer/alternative_content_examples.zip'>here. Why the availability of the
The tutoriel in question is http://developer.android.com/resources/tutorials/views/hello-gridview.html The Tutorial asks that you 1- Create a
i am trying to display google map on Android refering to this tutorial http://developer.android.com/resources/tutorials/views/hello-mapview.html
I installed .NET 4.5 Developer preview from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27541 , which 'replaces' .NET 4.0 version.

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.