O'Reilly logo

CUDA Programming by Shane Cook

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constant memory updates at runtime

Constant memory of the GPU is not really constant memory, in that there is no dedicated special area of memory set aside for constant memory. The 64 K limit is exactly a 16-bit offset, allowing very quick 16-bit addressing. This presents some opportunities and some problems. First, constant memory can be updated in chunks or tiles of up to 64 K at a time. This is done with the cudaMemcpyToSymbol API call. Revising our constant program somewhat, let’s look at how this works.

#include "stdio.h"

#include "conio.h"

#include "assert.h"

  

typedef unsigned short int u16;

typedef unsigned int u32;

  

#define CUDA_CALL(x) {const cudaError_t a = (x); if (a != cudaSuccess) { printf("\nCUDA Error: %s (err_num=%d) \n", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required