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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:47:20+00:00 2026-06-11T22:47:20+00:00

I tried a method so that the data transfer from Host to Device will

  • 0

I tried a method so that the data transfer from Host to Device will not be used. Normally, we assign values to the elements in the Host array using a loop and transfer it to the Device. This works fine for me on 1D and 2D arrays. The new method i tried is, to give the values to the array elements in the kernel. I succeeded for 1D arrays. But, for 2D array, the result is 0. My device can support (512,512) threads per block. The output values are coming fine upto Length=22 but displays ‘0’ for Length=23 [22<sqrt(512)<23]. As per [22<sqrt(512)<23], i can see that only 22x22 threads are being used. Whats the problem?? Why is this happening?

The Code:

    const int Length=23;

Main Function:

    int A[Length],B[Length],C[Length],D[Length],*Ad,*Bd;
    int size=Length*sizeof(int);
    cudaMalloc((void**)&Ad,size);
    cudaMalloc((void**)&Bd,size);
    dim3 dimGrid(1,1);
    dim3 dimBlock(Length,Length);
    FuncG<<<dimGrid,dimBlock>>>(Ad,Bd);
    cudaMemcpy(C,Ad,size,cudaMemcpyDeviceToHost);
    cudaMemcpy(D,Bd,size,cudaMemcpyDeviceToHost);
    for(int i=0;i<Length;i++){
        printf("%d  %d\n",C[i],D[i]);
    }
    return 0;

Kernel Function:

__global__ void FuncG(int *Ad,int *Bd){
    int tx=threadIdx.x;
    int ty=threadIdx.y;
    Ad[tx]=tx;
    Bd[ty]=ty;
}
  • 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-11T22:47:21+00:00Added an answer on June 11, 2026 at 10:47 pm

    Your device can only support 512 threads per block. The maximum dimensions of the first two thread block dimensions are 512. A 22×22 block (484 threads) is a legal block size, but a 23×23 block (529 threads) is not.

    You are getting 0 output because the kernel is never running. If you check for it, you will find the kernel launch is failing with an invalid execution configuration error. The canonical way to check for a launch failure of this kind is something like:

    FuncG<<<dimGrid,dimBlock>>>(Ad,Bd);
    if (cudaPeekAtLastError() != cudaSuccess) {
        // handle error.....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that retrieves data from a json serialized string and writes
I have a WCF method that accepts arbitrary binary data which the service will
I tried to solve problems from Project Euler. I know my method would work
I'm trying to declare an enum type based on data that I'm retrieving from
Right now I'm building a small app that imports data from a spreadsheet and
I have two tables that I would like to get data and from by
I am writing a cronjob which would transfer data from one table, process it
I am trying to setup a UITableView that displays the data from the Documents
I first time tried to subClassed an NSDate to give it 2 methods that
I have a method(say method1) that writes to database(sqlserver)and another method(say method2) that tries

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.