# where is the another 32 byte shared memory

**URL:** <https://forums.developer.nvidia.com/t/where-is-the-another-32-byte-shared-memory/10990>\
**Category:** CUDA Programming and Performance\
**Created:** [July 20, 2009, 4:38am UTC](https://forums.developer.nvidia.com/t/where-is-the-another-32-byte-shared-memory/10990 "2009-07-20T04:38:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shong](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shong](https://forums.developer.nvidia.com/u/shong)\
**Post date:** [July 20, 2009, 4:38am UTC](https://forums.developer.nvidia.com/t/where-is-the-another-32-byte-shared-memory/10990/1 "2009-07-20T04:38:23Z")

</div>

Hi everyone,

recently, I optimize my programme, I found the the size of shared memory in cubin file is greater than I used in the kernel (only greater 32byte). I wonder where I use these shared memory?

[codebox]/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*\*\*\*\*\*\*\*\*\*\*\*/

/\* calculate the maximum and minimum of a vector \*/

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*\*\*\*\*\*\*\*\*\*\*\*/

template

**global** void CalMaxMinD1(int np, float\* idata, float\* odatamax, float\* odatamin)

{

```
int tid = threadIdx.x;

int i = __mul24(blockIdx.x, blockDim.x) + threadIdx.x;

int gridsize = __mul24(gridDim.x, blockDim.x);

__shared__ float maxtemp[256];

__shared__ float mintemp[256];

// load

maxtemp[tid] = idata[i];

mintemp[tid] = maxtemp[tid];

i += gridsize;

while (i < np)

{

	float temp = idata[i];

	if (maxtemp[tid] < temp) { maxtemp[tid] = temp; }

	if (mintemp[tid] > temp) { mintemp[tid] = temp; }

	i += gridsize;

}

__syncthreads();

```

…

do the reduce works

…

```
// output

if (tid == 0)

{

	odatamax[blockIdx.x] = maxtemp[0];

	odatamin[blockIdx.x] = mintemp[0];

}

```

}[/codebox]

In this code, I only use two shared memory array. it is totally 256_4Byte_2 = 2048. While in the cubin file, it shows I used 2080 Byte shared memory. Could you please tell me why?

[codebox]code {

```
name = _Z11CalMaxMinD1ILi2EEviPfS0_S0_

lmem = 0

smem = 2080

reg = 8

bar = 1

const {

		segname = const

		segnum = 1

		offset = 0

		bytes = 4

	mem {

		0x0000001f 

	}

}

bincode {.......

}

```

}[/codebox]

- 

peter

---

<div class="post-metadata">

**Author:** ![seibert](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/seibert/32/520688_2.png) [@seibert](https://forums.developer.nvidia.com/u/seibert)\
**Post date:** [July 20, 2009, 5:16am UTC](https://forums.developer.nvidia.com/t/where-is-the-another-32-byte-shared-memory/10990/2 "2009-07-20T05:16:08Z")

</div>

CUDA uses some of the shared memory for storing kernel parameters and block/grid dimensions.

---

<div class="post-metadata">

**Author:** ![shong](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shong](https://forums.developer.nvidia.com/u/shong)\
**Post date:** [July 21, 2009, 8:55am UTC](https://forums.developer.nvidia.com/t/where-is-the-another-32-byte-shared-memory/10990/3 "2009-07-21T08:55:18Z")

</div>

> [@](#):
>
> CUDA uses some of the shared memory for storing kernel parameters and block/grid dimensions.

Thanks.

- 

peter
