How to move global memory to constant memory?

Hi! I am using pytorch and can easily create variable in GPU’s global memory, I am wondering can I move data from global to constant memory?

I only see method like:

float pABC[] = {1, 2, 3};
...
cudaMemcpyToSymbol(c_ABC, &pABC, 3 * sizeof(float));

To move from CPU to GPU…

Also, does NVIDIA provide samples for constant memory usage? I did not see much…
Also, in nsight compute, why no constant memory part?

Thank you!!!

constant memory is read-only from device code perspective. You cannot move data from global memory to constant memory using CUDA device code. Only via host code. The only method to populate constant memory directly is via cudaMemcpyToSymbol.

There are numerous examples of constant memory usage on various forums.

The CUDA samples codes: volumeRender, volumeFilter, convolutionSeparable, dxtc, bilateralFilter, convolutionTexture, binomialOptions, quasirandomGenerator, nbody, particles, smokeParticles all demonstrate usage of constant memory.

I suggest asking questions about the profiler on the profiler forums.

1 Like

There’s a profiler forum? :-)

Link please…

1 Like

You can browse and navigate forums at the top of this page. (For example click on Home - that will show all forum categories at a high level.)

Here is the link to the general category of development tools.

The specific forum will vary depending on whether you are interested in nsight systems, nsight compute, etc.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.