# \_\_threadfence\_block vs. \_\_syncthreads

**URL:** <https://forums.developer.nvidia.com/t/threadfence-block-vs-syncthreads/13481>\
**Category:** CUDA Programming and Performance\
**Created:** [November 27, 2009, 8:36am UTC](https://forums.developer.nvidia.com/t/threadfence-block-vs-syncthreads/13481 "2009-11-27T08:36:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ichabod](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ichabod](https://forums.developer.nvidia.com/u/Ichabod)\
**Post date:** [November 27, 2009, 8:36am UTC](https://forums.developer.nvidia.com/t/threadfence-block-vs-syncthreads/13481/1 "2009-11-27T08:36:50Z")

</div>

Hello,

yes, I know, that \_\_threadfence\_block() doesn’t sync instead of \_\_syncthreads… but… what’s it really for? The example program for \_\_threadfence makes sense, but does anyone know a reasonable application for \_\_threadfence\_block()?

Another question: Does a \_\_syncthreads() barrier superseeds additional usage of \_\_threadfence\_block(), or do I have to use both to ensure that some changes of shared memory reach the other threads of the block before continuing?

---

<div class="post-metadata">

**Author:** ![CapJo](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@CapJo](https://forums.developer.nvidia.com/u/CapJo)\
**Post date:** [November 27, 2009, 12:11pm UTC](https://forums.developer.nvidia.com/t/threadfence-block-vs-syncthreads/13481/2 "2009-11-27T12:11:44Z")

</div>

> [@](#):
>
> Hello,
> 
> yes, I know, that \_\_threadfence\_block() doesn’t sync instead of \_\_syncthreads… but… what’s it really for? The example program for \_\_threadfence makes sense, but does anyone know a reasonable application for \_\_threadfence\_block()?
> 
> Another question: Does a \_\_syncthreads() barrier superseeds additional usage of \_\_threadfence\_block(), or do I have to use both to ensure that some changes of shared memory reach the other threads of the block before continuing?

\_\_syncthreads is enougth to guarantee that all threads within a block reached the this barrier and that all memory writes are visible to all threads.

\_\_threadfence(-block()) is rarely used (compared to \_\_syncthreads), but there is at least one example in the sdk.
