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 6721933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:23:16+00:00 2026-05-26T09:23:16+00:00

Sorry for bad title. I could not come up with anything better. Every example

  • 0

Sorry for bad title. I could not come up with anything better.

Every example I have seen of CUDA programs has predefined data that is ready to be parallelized.
A common example is the sum of two matrices where the two matrices are already filled. But what about programs that generates new tasks. How do I model this in CUDA? How do I pass a result so other threads can begin working on it.

For example:
Say I run a kernel on one job. This job generates 10 new independant jobs. Each of them generates 10 new independant job and so on. This seems like a task that is highly parallel because each job is independant. The problem is I don’t know how to model this in CUDA.
I have tried doing it in CUDA where I used a while loop in a kernel to keep polling if a thread could begin computation. Each thread was assigned a job. But that did not work. It seemed to ignore the while loop.

Code example:

On host:
fill ready array with 0
ready[0] = 1;

On device:
__global__ void kernel(int *ready, int *result)
{
    int tid = threadIdx.x;
    if(tid < N)
    {
        int condition = ready[tid];
        while(condition != 1)
        {
            condition = ready[tid];
        }

        result[tid] = 3;// later do real computation

        //children jobs is now ready to work
        int childIndex = tid * 10;
        if(childIndex < (N-10))
        {
            ready[childIndex + 1] = 1; ready[childIndex + 2] = 1;
            ready[childIndex + 3] = 1; ready[childIndex + 4] = 1;
            ready[childIndex + 5] = 1; ready[childIndex + 6] = 1;
            ready[childIndex + 7] = 1; ready[childIndex + 8] = 1;
            ready[childIndex + 9] = 1; ready[childIndex +10] = 1;
        }
    }
}
  • 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-26T09:23:16+00:00Added an answer on May 26, 2026 at 9:23 am

    You will want to use multiple kernel calls. Once a kernel job has finished and generated the work units for its children, the children can be executed in another kernel. You don’t want to poll with a while loop inside a cuda kernel anyways, even if it worked you would get terrible performance.

    I would google the CUDA parallel reduction example. Shows how to decompose into multiple kernels. The only difference is instead of doing less work between kernels you will be doing more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At first sorry for my really bad title! If you have a better title
First, sorry for bad title, couldn't come up with something more descriptive. I have
Sorry for the really bad title, but I couldn't come up with a better
Sorry for the bad title, but I couldn't think of a better one. I'm
Sorry for the bad title (couldn't think of a better way to describe it)
Sorry for the bad question title. Let's say that I have DateRange class that
Sorry for the bad title, if you can think of a better one, let
Sorry for the bad title, but I have no idea how to put this
hi sorry for the bad title but I'm not 100% sure what I need
Sorry for the bad title wording! I have the JS: $(.add).click(function(event) { cid=event.target.id; alert(add

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.