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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:31:14+00:00 2026-05-22T11:31:14+00:00

Hey there, I have the following piece of code: #if USE_CONST == 1 __constant__

  • 0

Hey there,
I have the following piece of code:

#if USE_CONST == 1
    __constant__ double PNT[ SIZE ];    
#else
    __device__ double *PNT;
#endif

and a bit later I have:

#if USE_CONST == 0
    cudaMalloc((void **)&PNT, sizeof(double)*SIZE);
    cudaMemcpy(PNT, point, sizeof(double)*SIZE, cudaMemcpyHostToDevice);
#else
    cudaMemcpyToSymbol(PNT, point, sizeof(double)*SIZE);
#endif

whereas point is somewhere defined in the code before. When working with USE_CONST=1 everything works as expected, but when working without it, than it doesn’t. I access the array in my kernel-function via

PNT[ index ]

Where’s the problem between the both variants?
Thanks!

  • 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-22T11:31:14+00:00Added an answer on May 22, 2026 at 11:31 am

    The correct usage of cudaMemcpyToSymbol prior to CUDA 4.0 is:

    cudaMemcpyToSymbol("PNT", point, sizeof(double)*SIZE)
    

    or alternatively:

    double *cpnt;
    cudaGetSymbolAddress((void **)&cpnt, "PNT");
    cudaMemcpy(cpnt, point, sizeof(double)*SIZE, cudaMemcpyHostToDevice);
    

    which might be a bit faster if you are planning to access the symbol from the host API more than once.

    EDIT: misunderstood the question. For the global memory version, do something similar to the second version for constant memory

    double *gpnt;
    cudaGetSymbolAddress((void **)&gpnt, "PNT");
    cudaMemcpy(gpnt, point, sizeof(double)*SIZE.  cudaMemcpyHostToDevice););
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there, I have the following code: sVal = analogRead(potPin); // read the value
Hey there, assuming I have the following code in a mex routine: mxArray *newPoint
Hey all. I have the following code: http://jsfiddle.net/g7Cgg/ As you can see, there are
Hey there, I'm trying to make a site which have following: News, Products, About
I have use following code to display category and there product on click patent
Hey there, I have a probably straight-forward question about the following problem: I have
hey there, I have a Navigation Menu and my code looks like this.. <ul
I have the following JSON: { @id: hey there, id: hey there 2 }
hey there i wonder if any of you have come across a similar issue?
hey there, i have a div that expands when the page is loaded, now

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.