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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:34:21+00:00 2026-05-31T10:34:21+00:00

I have to extract sections of an array and set the chunk to another

  • 0

I have to extract sections of an array and set the chunk to another array.

For instance, I have a 2d array (in 1d format) like A[32 X 32]; there is another array B[64 X 64] and I would want to copy an 8X8 chunk of B, starting from (0,8) of B and place it in (8,8) of A.

At present, I would probably use something like the kernel below, for getting a portion of data when offsets are passed. A similar one could also be used to setting chunks to a larger array.

__global__ void get_chunk (double *data, double *sub, int xstart, int ystart, int rows, int cols, int subset)
 {
    int i,j;
    i = blockIdx.x * blockDim.x + threadIdx.x;

    for (j = 0; j < subset; j++)
            sub[i*subset+j] = data[i*cols + (xstart*cols + ystart)+j];

 }

I think the same could be done using a variant of cudamemCpy* (perhaps cudamemCpyArray(…)), but I am not sure how to do it. I need some code samples, or some directions on how it could be done.

PS I had the exact same question in nvidia forums, got no reply so trying here. http://forums.nvidia.com/index.php?showtopic=223386

Thank you.

  • 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-31T10:34:22+00:00Added an answer on May 31, 2026 at 10:34 am

    There is no need for a kernel if you just want to copy data from one array to another on the device.

    If you have your device pointers with your source data and your allocated target pointer in host code:

    Pseudocode:

    //source and target device pointers
    double * source_d, target_d;
    
    //get offseted source pointer
    double * offTarget_d + offset * sizeof(double);
    
    //copy n elements from offseted source data to target device pointer
    cudaMemcpy(offTarget_d, source_d, n * sizeof(double), cudaMemcpyDeviceToDevice);
    

    It was not clear if you just want to copy a range of a 1D array or if you want to copy a range of each row in a 2D array into the target row of another 2D array

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

Sidebar

Related Questions

I have a list and I want to extract to another list the data
I'm using Selenium for work and I have extract some data from //ul, unfortunately
I have to extract defined variable and function names from a js code passed
I have to extract columns from a text file explained in this post: Extracting
I've a requirement where I have to extract metrics from different Java projects (configured
Have a simple form (only extract fields here) but for some reason the JQserilization
I have been trying to extract data from a database and fill in a
I have found two ways to extract matches in Python: 1. def extract_matches(regexp, text):
I have HTML that I need to extract a part number from, the HTML
I have a task to import/transform and extract zipped binary files that contain both

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.