Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4101742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:44:12+00:00 2026-05-20T20:44:12+00:00

The CUDA programming guide states that __syncthreads() is allowed in conditional code but only

  • 0

The CUDA programming guide states that

__syncthreads() is allowed in conditional code but only if the
conditional evaluates identically
across the entire thread block,
otherwise the code execution is likely
to hang or produce unintended side
effects.

So if I need to synchronize threads with a conditional branching across a block, some of which threads may or may not take the branch that includes the __syncthreads() call, does this mean that it won’t work?

I’m imagining that there might be all sorts of cases in which you might need to do this; for example, if you have a binary mask and need to apply a certain operation on pixels conditionally. Say, if (mask(x, y) != 0) then execute the code that includes __syncthreads(), otherwise do nothing. How would that be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:44:13+00:00Added an answer on May 20, 2026 at 8:44 pm

    If you need to go this route you could split the body into two phases:

    if (condition)
    {
        // code before sync
    }
    __syncthreads();
    if (condition) // or remember a flag or whatever
    {
        // code after sync
    }
    

    Alternatively you could use the condition to set a flag that disables certain operations, for example if you’re computing a delta update you could do the following:

    // *ALL* compute a delta update, those threads that would have failed the condition
    // simply compute garbage.
    // This can include syncthreads
    if (condition)
        // apply update
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Nvida CUDA C Programming Guide 4.0, section 3.2.5.5.4, it says that two commands
I have gone through Cuda programming guide but still not clear where does cuda
Is there a problem in this example code from the CUDA C Programming Guide?
in CUDA C Programming Guide, it is said that ... by design, a host
According to "CUDA C Programming Guide" , a constant memory access benefits only if
I am new to CUDA programming, and I am working on a problem that
I have been reading the programming guide for CUDA and OpenCL, and I cannot
I am brand new to CUDA programming. I have a CUDA subroutine that, hopefully,
The cuda profiler manual states that due to the more relaxed coalescing policy, the
According to the CUDA Programming Guide , Page 122, it is possible to dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.