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

  • Home
  • SEARCH
  • 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 8861897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:35:46+00:00 2026-06-14T15:35:46+00:00

I have something I don’t understand about CUDA. I understand that there are ‘virtual’

  • 0

I have something I don’t understand about CUDA. I understand that there are ‘virtual’ variables called threads.

When programming the kernel the thread variables are running automatically , and the kernel is running over and over again for every thread. (Correct so far?)

Now if I program something like this:

for (int i = 0 ; i<100; i++){
....
}

Is it run over and over again for every thread? Or just once?

  • 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-06-14T15:35:48+00:00Added an answer on June 14, 2026 at 3:35 pm

    Every code you put in the kernel function (prefixed by __global__) would be executed by all concurrent threads (which the mass of threads is specified at the kernel launch time). In the body of kernel, you can differentiate the computation of threads according to their global identifier or local identifier:

    for 1D (potentially your case):

    local identifier: int tid = threadIdx.x

    global identifier: int tid = blockIdx.x*blockDim.x + threadIdx.x

    Further clarifications:

    If you have this kernel:

        __global__ void dummy(int *out){
          for(int i=0; i<100; i++){
            ...
          }
        }
    

    and you want to launch 4096 concurrent threads, you should organize the threads into thread-blocks (to exploit locality and tackle hardware limitations). If you break 4096 threads into thread-block of 256-thread, you can run this mass of threads to execute the dummy function by:

    dummy<<<4096/256, 256>>>(output_array);
    

    The dummy function will be executed by 4096 threads, one for each, serially or in-parallel depending on the hardware (real GPU). You should suppose all threads are running in parallel. You can differentiate the computation of threads using thread identifier (globally) as described above.

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

Sidebar

Related Questions

I'm beginning and there is something that I don't understand with pointers. I have
There is something I don't understand in Java's regular expressions. I have the following
There's something I don't understand about Scala's collection.mutable.Seq . It describes the interface for
I'm new to Blackberry development and have come across something I don't understand. I
I'm really sorry to have to ask this, but I clearly don't understand something
I don't quite understand the difference between Task.Wait and await . I have something
I must have done something but don't know what. I was happily programming away
I need to do something I don't even know if is possible.. We have
I am trying to do something I don't know if it's doable. I have
I have this code, I know I'm missing something but don't know what. It

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.