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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:23:44+00:00 2026-06-15T18:23:44+00:00

Say I have a source of CPU side data that looks like this: vector<

  • 0

Say I have a source of CPU side data that looks like this:

vector< vector<int> > cpuBlobOData;

Assume every row vector inside has the same size (a jagged 2d vector that isn’t jagged).

I want to copy this to single block of GPU memory, inside an array. Is there a way to do this row by row? Something like this:

array<int, 2> gpuArray(cpuBlobOData.size(), numColumns);
for(size_t i=0; i<cpuBlobOData.size(); ++i)
{
    auto cpuRow = cpuBlobOData[i];
    concurrency::copy(cpuRow.begin(), cpuRow.end(), &gpuArray[i]);
}

I know this doesn’t compile, it shows what I am trying to do. Is there something that accomplishes this? The only solution I could find was to copy the cpu vector into a 1D vector, and map that to an array_view, or copy it into an array.

That works, but it is wasteful, and for some algorithms, the continuous 1D vector may not fit into the remaining memory space.

Any advice is welcome, as I am struggling to figure out AMP.

  • 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-15T18:23:45+00:00Added an answer on June 15, 2026 at 6:23 pm

    Yes, you can copy it row by row. Your solution is almost there, just remove ‘&’ from the gpuArray in the line with concurrency::copy:

    array<int, 2> gpuArray(cpuBlobOData.size(), numColumns);
    for(size_t i=0; i<cpuBlobOData.size(); ++i)
    {
        auto cpuRow = cpuBlobOData[i];
        concurrency::copy(cpuRow.begin(), cpuRow.end(), gpuArray[i]);
    }
    

    What happens is that array<int,2> accessed with subscript operator returns an array_view<int,1> that represents a row ‘i’, this is called “projection”. For more details please check out a blog post that covers C++ AMP projections in details.

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

Sidebar

Related Questions

Say I have a dataframe source <- data.frame(ID=c(1,2), COUNT=c(3,4)) that looks like this: ID
say you have a source file named sum.c that looks like this: #include sum.h
Lets say I have an enumerable source, that looks like this: IEnumerable<string> source =
For the sake of this question, let's say I have an Excel data source
Say I have a source document like this: <element> <subelement xmlns:someprefix=mynamespace/> </element> The xmlns:someprefix
Lets say have this immutable record type: public class Record { public Record(int x,
Let's say we have an image like so (source: curiousexpeditions.org ) Let's say we've
I have referenced one DLL (I have source code of this) say Dll_A in
Say I have a source folder with a bunch of files in it like
Say I have a class like this: public class MyClass { public string Name;

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.