# Shared memory declaration Simple question about shared memory

**URL:** <https://forums.developer.nvidia.com/t/shared-memory-declaration-simple-question-about-shared-memory/12576>\
**Category:** CUDA Programming and Performance\
**Created:** [October 5, 2009, 9:24am UTC](https://forums.developer.nvidia.com/t/shared-memory-declaration-simple-question-about-shared-memory/12576 "2009-10-05T09:24:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_De\_Gaetano](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/andrea_de_gaetano/32/12089_2.png) [@Andrea\_De\_Gaetano](https://forums.developer.nvidia.com/u/Andrea_De_Gaetano)\
**Post date:** [October 5, 2009, 9:24am UTC](https://forums.developer.nvidia.com/t/shared-memory-declaration-simple-question-about-shared-memory/12576/1 "2009-10-05T09:24:08Z")

</div>

Hi,

I’m trying to start using shared memory but I have to clear some problem using it.

For what I understand , shared memory is the memory shared between thread inside a block.

I can declare it in launch like this (for example):

```auto
int sh_Size = 1000 * sizeof(int);

 launchKRN<<< grid, threads, sh_Size >>>(d_srcArray);

```

These are my questions about these lines:

1. shared memory Size must be lower than 16 kb?

2. the 16 kb max size dimension for shared memory is referred to the total shared memory on the device to use or to the single block shared memory size?

(If I declare 4 blocks, I have sh\_Size shared memory dimension or 4 \* sh\_Size?)

1. when I declared the third parameter in launchKRN (sh\_Size) it is referred to:

---

<div class="post-metadata">

**Author:** ![CaLu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@CaLu](https://forums.developer.nvidia.com/u/CaLu)\
**Post date:** [October 5, 2009, 9:51am UTC](https://forums.developer.nvidia.com/t/shared-memory-declaration-simple-question-about-shared-memory/12576/2 "2009-10-05T09:51:45Z")

</div>

Andrea,

> [@](#):
>
> 1. shared memory Size must be lower than 16 kb?

yes

> [@](#):
>
> 1. the 16 kb max size dimension for shared memory is referred to the total shared memory on the device to use or to the single block shared memory size?

single block shared memory

> [@](#):
>
> 1. when I declared the third parameter in launchKRN (sh\_Size) it is referred to:
> 
> A ) the size of the total shared memory on the device that I want to use ?
> 
> or
> 
> B ) the size of the shared memory for block on device ?

for one block

Shared memory is on-chip memory available for all threads running on one multiprocessor. There are 16 kb of shared memory on GT80 and GT200 chip for every MP.

cheers,

luca

---

<div class="post-metadata">

**Author:** ![Andrea\_De\_Gaetano](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/andrea_de_gaetano/32/12089_2.png) [@Andrea\_De\_Gaetano](https://forums.developer.nvidia.com/u/Andrea_De_Gaetano)\
**Post date:** [October 5, 2009, 9:55am UTC](https://forums.developer.nvidia.com/t/shared-memory-declaration-simple-question-about-shared-memory/12576/3 "2009-10-05T09:55:30Z")

</div>

> [@](#):
>
> Andrea,
> 
> yes
> 
> single block shared memory
> 
> for one block
> 
> Shared memory is on-chip memory available for all threads running on one multiprocessor. There are 16 kb of shared memory on GT80 and GT200 chip for every MP.
> 
> cheers,
> 
> luca

Thank you,

grazie Luca!
