Hi Phil,

 > Thanks Karl !
> This will allow serve us when we deal with multiple GPU ;)

I'm pretty happy with the model now, basically extending the concept of 
a 'context' in OpenCL beyond OpenCL boundaries: Create vectors as follows:

  viennacl::vector<T> x(42);   //vector in default context

  viennacl::context host_context(viennacl::MAIN_MEMORY);
  viennacl::vector<T> y(42, host_context); //vector in main RAM

  // vector in i-th OpenCL context, size will be specified later
  viennacl::context opencl_context(viennacl::ocl::get_context(i));
  viennacl::vector<T> z(opencl_context);

  viennacl::context cuda_context(viennacl::CUDA_MEMORY);
  viennacl::vector<T> w(42, cuda_context); //vector on CUDA device

and if you cant to migrate a vector to a different context, simply:

  viennacl::switch_memory_context(z, host_context);
  viennacl::switch_memory_context(w, opencl_context);

and all the internals are taken care of automatically (including 
conversions if e.g. int and cl_int don't have the same bit 
representation). Similarly for the various matrix types.

What does not yet work is something tricky like
  y = z + w;
where vectors reside in different contexts. I think it's reasonable to 
use the lvalue as the target context, but it may also create dangerous 
performance pitfalls if such implicit transfers happen silently...

Best regards,
Karli


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to