# How does "cudaStreamPerThread" variable behave without "--default-stream per-thread" compilation option?

**URL:** <https://forums.developer.nvidia.com/t/how-does-cudastreamperthread-variable-behave-without-default-stream-per-thread-compilation-option/273236>\
**Category:** CUDA Programming and Performance\
**Created:** [November 17, 2023, 2:10pm UTC](https://forums.developer.nvidia.com/t/how-does-cudastreamperthread-variable-behave-without-default-stream-per-thread-compilation-option/273236 "2023-11-17T14:10:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![garko12345](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@garko12345](https://forums.developer.nvidia.com/u/garko12345)\
**Post date:** [November 17, 2023, 2:10pm UTC](https://forums.developer.nvidia.com/t/how-does-cudastreamperthread-variable-behave-without-default-stream-per-thread-compilation-option/273236/1 "2023-11-17T14:10:40Z")

</div>

Hi, I understand (almost) everything about CUDA streams and “–default-stream per-thread” compilation option and use it regularly in my application.

But sometimes I would like to have “legacy” behavior and build without this option. Since I’m using “cudaStreamPerThread” CUDA variable, I don’t get correct results.

I wasn’t able to find the documentation where this behavior is explained. Is it undefined behaviour? Should I not use “cudaStreamPerThread” in legacy build?

---

<div class="post-metadata">

**Author:** ![striker159](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@striker159](https://forums.developer.nvidia.com/u/striker159)\
**Post date:** [November 17, 2023, 3:18pm UTC](https://forums.developer.nvidia.com/t/how-does-cudastreamperthread-variable-behave-without-default-stream-per-thread-compilation-option/273236/2 "2023-11-17T15:18:01Z")

</div>

`cudaStreamPerThread` will always be a different stream from the legacy stream, no matter if `–default-stream per-thread` is set or not
