Respondido Partial Memory Uploads?

  • segunda-feira, 13 de agosto de 2012 06:36
     
      Contém Código

    Let's say I create an array.

    concurrency::array<int> ar(1024);

    I then fill it with data.

    int count = 0;
    for(int n = 0; n < /* ... */; ++n)
    {
        ar_av[++count] = /*...*/;    
    }

    Now let's say that count < ar.extent.size(), thus I am not using the entire array ar.

    If I do the following:

    concurrency::parallel_for_each(concurrency::extent<1>(count), [&](const concurrency::index<1>& idx)
    {
         /* ... */
    }
    Is there a way to hint that not the entire array "ar" needs to be uploaded to the accelerator?


    • Editado Dragon89 segunda-feira, 13 de agosto de 2012 08:51
    •  

Todas as Respostas

  • segunda-feira, 13 de agosto de 2012 07:49
     
     

    VS 2012's C++ AMP is implemented on top of D3D 11.  In D3D 11, to execute a command (e.g. a dispatch) on GPU, all resouces needed by the command (e.g. buffers) will be swapped into the GPU memory if not there already. It's at per resource granularity (driver may or may not have some optimization for this, which could not be depended on). It means even the kernel to be dispatched only touches some portion of the resouce (even a single element), the whole resource will be swapped in.

    Thanks,

    Weirong

  • segunda-feira, 13 de agosto de 2012 08:50
     
     

    I understand.

    How about if I first write my data to a staging array, is it possible to copy a sub range of the data to a smallar device array, i.e. copy between arrays with different extent?


    • Editado Dragon89 segunda-feira, 13 de agosto de 2012 08:51
    •  
  • segunda-feira, 13 de agosto de 2012 16:24
     
     Respondido

    Copy a section of an array (or the whole array) between a section of another array (or the whole array), could be achieved by first creating sections -- which yields array_view.  Then you can copy between array_view/array and array_view/array. For "section", please read:

    http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/10/handling-subsections-of-data-in-c-amp.aspx

    http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/14/section-example-in-c-amp.aspx

    Thanks,

    Weirong

    • Marcado como Resposta Dragon89 segunda-feira, 13 de agosto de 2012 16:35
    •