# persistent global memory?

**URL:** <https://forums.developer.nvidia.com/t/persistent-global-memory/16365>\
**Category:** CUDA Programming and Performance\
**Created:** [April 30, 2010, 4:45am UTC](https://forums.developer.nvidia.com/t/persistent-global-memory/16365 "2010-04-30T04:45:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_habanero](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m\_habanero](https://forums.developer.nvidia.com/u/m_habanero)\
**Post date:** [April 30, 2010, 4:45am UTC](https://forums.developer.nvidia.com/t/persistent-global-memory/16365/1 "2010-04-30T04:45:05Z")

</div>

So I’m calling two different kernels with a shared global device array, that are all placed in a .so library:

[codebox]void \*device;

**global** void kernel1() {

```
// write data to device array

```

}

**global** void kernel2() {

```
// read data from device array

```

}[/codebox]

I thought that global memory was persistent, but it seems that even though the device pointer points to the same device memory, that memory has already been overwritten by the time kernel2 is launched. Is this caused by something I am doing wrong, or am I wrong about global device memory being persistent until cudaFreed?

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![m\_habanero](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m\_habanero](https://forums.developer.nvidia.com/u/m_habanero)\
**Post date:** [April 30, 2010, 6:21am UTC](https://forums.developer.nvidia.com/t/persistent-global-memory/16365/2 "2010-04-30T06:21:23Z")

</div>

Actually, I’ve found the problem, caused by accessing the device array from two different threads:

Several host threads can execute device code on the same device, but by design, a host thread can execute device code on only one device. As a consequence, multiple host threads are required to execute device code on multiple devices. Also, any CUDA resources created through the runtime in one host thread cannot be used by the runtime from another host thread.
