<div dir="ltr">Hi Karl,<div><br></div><div>A couple more questions:</div><div><br></div><div>1) In ViennaCL, queue.finish() seems to be called only if we enable the flags VIENNACL_DEBUG_ALL or VIENNACL_DEBUG_KERNEL. How do I ensure that my custom kernel finishes when the debug mode is not enabled? Should I be doing one of the following:</div>
<div><div>    </div><div><div>viennacl::ocl::command_queue queue = viennacl::ocl::current_context().get_queue();<br></div></div></div><div><div>viennacl::ocl::enqueue(kernel(*vars, *dvars_dt, *Fvars));</div></div><div>queue.finish();</div>
<div><br></div><div>or</div><div><br></div><div><div>viennacl::ocl::enqueue(kernel(*vars, *dvars_dt, *Fvars));</div></div><div><div>viennacl::backend::finish();</div></div><div><br></div><div>2) My platform 0 has only a GPU. So when I launch my custom kernel inside the residual function it indeed does evaluate on the GPU. In particular, suppose my residual function (for seq case) is like this:</div>
<div><div><br></div><div>PetscErrorCode ComputeResidual(TS ts,</div><div>                               PetscScalar t,</div><div>                               Vec X, Vec dX_dt,</div><div>                               Vec F, void *ptr)</div>
<div>{</div><div>    VecViennaCLGetArrayRead(X, &x);<br></div><div>    VecViennaCLGetArrayWrite(F, &f);</div><div><br></div><div>    viennacl::ocl::enqueue(myKernel(*x, *f));</div><div>// Put something here to finish the kernel.</div>
<div><br></div><div>    VecViennaCLRestoreArrayRead(X, &x);</div><div>    VecViennaCLRestoreArrayWrite(F, &f);</div><div>}</div></div><div><br></div><div>and I execute as given below:</div><div><br></div><div>./program </div>
<div><br></div><div>then the code inside the ComputeResidual function runs inside the GPU but everything else runs on the CPU, right? (since I did not specify -dm_vec_type viennacl  -dm_mat_type aijviennacl). Now suppose I execute as given below:</div>
<div><br></div><div>./program -dm_vec_type viennacl -dm_mat_type aijviennacl</div><div><br></div><div>then every vector operation occurs using the viennacl code in vecviennacl.cxx. And since my default platform is 0 (only having a NVIDIA GPU), I thought everything will run on the GPU. However with the ViennaCL debug mode, I get the following messages for the vector operations:</div>
<div><br></div><div><div>ViennaCL: Starting 1D-kernel 'assign_cpu'...</div><div>ViennaCL: Global work size: '16384'...</div><div>ViennaCL: Local work size: '128'...</div><div>ViennaCL: Kernel assign_cpu finished!</div>
</div><div><br></div><div>How is it possible that part of the ViennaCL code is using my CPU (which is on a completely different platform, #1) and the custom kernel is launched on my GPU (platform #0).</div><div><br></div>
<div>Cheers,</div><div>Mani</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 22, 2014 at 3:43 PM, Karl Rupp <span dir="ltr"><<a href="mailto:rupp@mcs.anl.gov" target="_blank">rupp@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Mani,<div class="im"><br>
<br>
> Thanks Karl. Is there anyway I can get the build info?<br>
<br></div>
For the moment only in case of an error...<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, my system is such that I have the GPU on one platform (0) and the<br>
CPU on another (1). When I try using -viennalcl_device_cpu, it still<br>
uses the GPU cause I think that it defaults to the first platform it<br>
finds which only has the GPU. Is there some way to toggle between the<br>
platforms or do you suggest that I manually pass in the contexts into<br>
viennacl?<br>
</blockquote>
<br></div>
Ah, so you have two OpenCL platforms available on your machine. Call<br>
  viennacl::ocl::set_context_<u></u>platform_index(0, platform_index_here);<br>
at the beginning of your program in order to specify the default platform index. In your case this should be<br>
  viennacl::ocl::set_context_<u></u>platform_index(0, 1);<br>
(cf. <a href="http://viennacl.sourceforge.net/viennacl-manual-current.pdf" target="_blank">http://viennacl.sourceforge.<u></u>net/viennacl-manual-current.<u></u>pdf</a>)<br>
I'll also make this configurable directly through PETSc in the next update of the ViennaCL bindings.<br>
<br>
Best regards,<br>
Karli<br>
<br>
</blockquote></div><br></div>