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

So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed
I am doing research on CUDA programming. i have the option to buy a
Almost anywhere I read about programming with CUDA there is a mention of the
So I read a bit about CUDA and GPU programming. I noticed a few
I'm looking for computationally heavy tasks to implement with CUDA and wonder if neural
Is there a #define compiler (nvcc) macro of CUDA which I can use? (Like
What do you think the future of GPU as a CPU initiatives like CUDA
What are the best IDE's / IDE plugins / Tools, etc for programming with
I'm trying to find the documentation for all of the functions available for the
I have an interview coming up in a week's time for an entry level

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.