# Pointers from Shared Memory, Constant memory into global memory

**URL:** <https://forums.developer.nvidia.com/t/pointers-from-shared-memory-constant-memory-into-global-memory/10581>\
**Category:** CUDA Programming and Performance\
**Created:** [July 2, 2009, 6:09pm UTC](https://forums.developer.nvidia.com/t/pointers-from-shared-memory-constant-memory-into-global-memory/10581 "2009-07-02T18:09:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nksureshkumar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nksureshkumar](https://forums.developer.nvidia.com/u/nksureshkumar)\
**Post date:** [July 2, 2009, 6:09pm UTC](https://forums.developer.nvidia.com/t/pointers-from-shared-memory-constant-memory-into-global-memory/10581/1 "2009-07-02T18:09:29Z")

</div>

Hi,

I would like to do the following. Is it safe ?

**constant** int \* constMemToGlobalMem[1024];

constMemToGlobalMem contains integer pointer in global memory space. i.e. I’m strong the address of integer arrays in global memory space in constant memory space.

**global** void myKernel()  
{  
**shared** int \* myThreadBlockPtr = constMemToGlobalMem[blockId.x]; // \<------------ Here the warning is produced.  
// Is the above statement legal. It is a shared memory pointer pointing to an address in constant memory space that points to global memory space ?  
myThreadBlockPtr[threadId.x] = 10;  
}

When I compile my code I get the following warning ./test.cu(17): Warning: Cannot tell what pointer points to, assuming global memory space

Regards,  
Suresh Kumar

---

<div class="post-metadata">

**Author:** ![JaredHoberock](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jaredhoberock/32/166135_2.png) [@JaredHoberock](https://forums.developer.nvidia.com/u/JaredHoberock)\
**Post date:** [July 2, 2009, 6:36pm UTC](https://forums.developer.nvidia.com/t/pointers-from-shared-memory-constant-memory-into-global-memory/10581/2 "2009-07-02T18:36:59Z")

</div>

> [@](#):
>
> Hi,
> 
> I would like to do the following. Is it safe ?
> 
> **constant** int \* constMemToGlobalMem[1024];
> 
> constMemToGlobalMem contains integer pointer in global memory space. i.e. I’m strong the address of integer arrays in global memory space in constant memory space.
> 
> **global** void myKernel()
> 
> {
> 
> **shared** int \* myThreadBlockPtr = constMemToGlobalMem[blockId.x]; // \<------------ Here the warning is produced.
> 
> // Is the above statement legal. It is a shared memory pointer pointing to an address in constant memory space that points to global memory space ?
> 
> myThreadBlockPtr[threadId.x] = 10;
> 
> }
> 
> When I compile my code I get the following warning ./test.cu(17): Warning: Cannot tell what pointer points to, assuming global memory space
> 
> Regards,
> 
> Suresh Kumar

Yes, it’s safe. In this case, nvcc has assumed correctly – your pointers inside the constMemToGlobalMem array refer to the global memory space.

---

<div class="post-metadata">

**Author:** ![nksureshkumar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nksureshkumar](https://forums.developer.nvidia.com/u/nksureshkumar)\
**Post date:** [July 2, 2009, 6:47pm UTC](https://forums.developer.nvidia.com/t/pointers-from-shared-memory-constant-memory-into-global-memory/10581/3 "2009-07-02T18:47:16Z")

</div>

> [@](#):
>
> Yes, it’s safe. In this case, nvcc has assumed correctly – your pointers inside the constMemToGlobalMem array refer to the global memory space.

Thank you. Is there any way for the me to tell the compiler that the pointer is supposed to point to a constant space or global memory space or the shared memory space ?
