# pinned memory

**URL:** <https://forums.developer.nvidia.com/t/pinned-memory/15108>\
**Category:** CUDA Programming and Performance\
**Created:** [February 23, 2010, 3:33pm UTC](https://forums.developer.nvidia.com/t/pinned-memory/15108 "2010-02-23T15:33:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noxnet](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@noxnet](https://forums.developer.nvidia.com/u/noxnet)\
**Post date:** [February 23, 2010, 3:33pm UTC](https://forums.developer.nvidia.com/t/pinned-memory/15108/1 "2010-02-23T15:33:12Z")

</div>

I have some questions about pinned memory in OpenCL.

First of all what is the difference between pinned memory and normal memory?

As written in “NVIDIA OpenCL Best Practices Guide” applications do not have direct control whether objects are allocated in pinned memory or not. The only thing that can be done is to set CL\_MEM\_ALLOC\_HOST\_PTR flag.

As it isn’t garanteed that pinned memory is used, is there any possiblity to check if pinned memory is used (after setting CL\_MEM\_ALLOC\_HOST\_PTR)?

Are there any special limitations concerning pinned memory (e.g. size)?

I tried to use pinned memory but I didn’t see any performance increases.

```auto
c_mem = clCreateBuffer(context,CL_MEM_READ_WRITE|CL_MEM_ALLOC_HOST_PTR, buffer_size, NULL, &err);	

float* data = NULL;

data = (float*)clEnqueueMapBuffer(cmd_queue, c_mem, CL_TRUE, CL_MAP_WRITE, 0, buffer_size,0,NULL,NULL,NULL);

//filling data

err = clEnqueueWriteBuffer(cmd_queue,c_mem, CL_FALSE, 0, buffer_size, data,0 ,NULL , NULL);

```

Is there any thing else to consider in code?
