# Inst\_executed and thread\_inst\_executed

**URL:** <https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021>\
**Category:** Nsight Compute\
**Created:** [September 9, 2020, 7:57pm UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021 "2020-09-09T19:57:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahmood.nt](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mahmood.nt](https://forums.developer.nvidia.com/u/mahmood.nt)\
**Post date:** [September 9, 2020, 7:57pm UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021/1 "2020-09-09T19:57:33Z")

</div>

I would like to know what is there difference between **sm\_\_inst\_executed.sum** and **smsp\_\_thread\_inst\_executed.sum** metrics. Maybe the first one is at warp level. Am I right? Please let me know if there are more information.

---

<div class="post-metadata">

**Author:** ![felix\_dt](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/felix_dt/32/14043_2.png) [@felix\_dt](https://forums.developer.nvidia.com/u/felix_dt)\
**Post date:** [September 10, 2020, 8:35am UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021/2 "2020-09-10T08:35:45Z")

</div>

Yes, that’s correct, the difference is in counting per warp or per thread. You can find the description for each metric using the ncu --query-metrics flag on the command line. The UI also shows the descriptions when hovering over the metric as a tool tip.

> smsp\_\_inst\_executed # of warp instructions executed  
> smsp\_\_thread\_inst\_executed # of thread instructions executed  
> smsp\_\_thread\_inst\_executed\_pred\_on # of thread instructions executed where guard predicate was true

The difference between sm\_\_ and smsp\_\_ metrics is if they are collected on the SM-level, or on the SMSP-level

> **[Kernel Profiling Guide :: Nsight Compute Documentation](https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html#metrics-decoder)**
>
> Nsight Compute profiling guide.

---

<div class="post-metadata">

**Author:** ![mahmood.nt](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mahmood.nt](https://forums.developer.nvidia.com/u/mahmood.nt)\
**Post date:** [September 16, 2020, 7:02pm UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021/3 "2020-09-16T19:02:03Z")

</div>

Hi,

In a sample run I see

```
smsp__inst_executed.sum inst 1107736.000000 1107736.000000 1107736.000000
smsp__thread_inst_executed.sum inst 31322624.000000 31322624.000000 31322624.000000
smsp__thread_inst_executed_pred_on.sum inst 30651904.000000 30651904.000000 30651904.000000

```

It seems that 31,322,624-1,107,736=30,214,888 which is close to the pred\_on stat. So, I guess the thread\_inst is the sum of pred\_on and inst\_executed.

Is that right in terminology of nsight compute?

If we divide thread\_inst by 32, I guess it should be the same as inst\_executed. Isn’t it? But i see

31,322,624/32 = 978,832

So, there is a difference between that and 1,107,736. The difference is not small though.

Any idea about that?

---

<div class="post-metadata">

**Author:** ![Greg](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/greg/32/14043_2.png) [@Greg](https://forums.developer.nvidia.com/u/Greg)\
**Post date:** [September 17, 2020, 6:18am UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021/4 "2020-09-17T06:18:45Z")

</div>

A SM has 4 sub-partitions (SMSP). Each sub-partition has a warp scheduler, register files, warp slots, dispatch unit, and multiple execution units (ALU, FMA, FP16x2, Tensor Cores, etc.). Metrics starting with smsp refers to counters collected at the SM sub-partition level.

The value of sm\_\_inst\_executed.sum == smsp\_\_inst\_executed.sum  
The value of sm\_\_inst\_executed.avg == smsp\_\_inst\_executed.avg x 4

felix\_dt as provided the description of the counters.

A warp may have 1-MAX\_THREADS\_PER\_WARP active threads per cycle. For CC Tesla - Ampere architecture MAX\_THREADS\_PER\_WARP == 32. The number of threads can be less than MAX\_THREADS\_PER\_WARP if

1. The kernel was launched such that the number of threads per block is not a multiple of 32. (e.g. kernel\<\<\<1, 1\>\>\>() launches 1 block containing 1 thread. The warp for block 0 will have only 1 active thread.
2. If a thread in the warp exits.
3. If there is thread divergence (e.g. a subset of threads take a branch).

smsp\_\_thread\_inst\_executed.sum \<= smsp\_\_inst\_executed x MAX\_THREADS\_PER\_WARP.

A value less than this means one of the aforementioned cases occurred.

A warp may have 1 - ACTIVE\_THREADS predicated true threads per cycle. The NVIDIA GPU ISA supports per instruction guard predicates that allows individual threads to not participate in the instruction without the overhead of a divergent branch. The compiler will often use thread predication for short sequences of divergent code.

In Nsight Compute the Source View can show these counters values per SASS instruction or rolled-up to higher level language. At the SASS level each instruction can have a guard predicate @[!]P{#.T=true}.

@P0 IADD R0, R1, R2 // if P0 is true then the thread will write-back the result; otherwise, the result is not written back

The @P0 is the guard predicate. Each thread can have a separate true/false value. For more information on guard predicates see the PTX ISA section [Instruction Statements](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#instruction-statements).

The following metric relationships exist:  
smsp\_\_thread\_inst\_executed\_pred\_on.sum  
\<= smsp\_\_thread\_inst\_executed.sum  
\<= smsp\_\_inst\_executed x MAX\_THREADS\_PER\_WARP.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 12, 2021, 6:07pm UTC](https://forums.developer.nvidia.com/t/inst-executed-and-thread-inst-executed/154021/5 "2021-10-12T18:07:05Z")

</div>


