[petsc-dev] Petsc+ViennaCL usage

Mani Chandra mc0710 at gmail.com
Mon Jan 20 22:47:24 CST 2014


Hi Everyone,

I have a few questions regarding the usage of Viennacl in Petsc.

1) In the residual evaluation function:

PetscErrorCode ComputeResidual(TS ts,
                               PetscScalar t,
                               Vec X, Vec dX_dt,
                               Vec F, void *ptr)
{
    DM da;
    Vec localX;
    TSGetDM(ts, &da)
    DMGetLocalVector(da, &localX);

    DMGlobalToLocalBegin(da, X, INSERT_VALUES, localX);
    DMGlobalToLocalEnd(da, X, INSERT_VALUES, localX);

    viennacl::vector<PetscScalar> *x, *f;
    VecViennaCLGetArrayWrite(localX, &x);
    VecViennaCLGetArrayRead(F, &f);

    viennacl::ocl::enqueue(myKernel(*x, *f));
//Should it be viennacl::ocl::enqueue(myKernel(x, f))?

    VecViennaCLRestoreArrayWrite(localX, &x);
    VecViennaCLRestoreArrayRead(F, &f);
    DMRestoreLocalVector(da, &localX);
}

Will the residual evaluation occur on the GPU/accelerator depending on
where we choose the ViennaCL array computations to occur? As I understand,
if we simply use VecGetArray in the residual evaluation function, then the
residual evaluation is still done on the CPU even though the solves are
done on the GPU.

2) How does one choose on which device the ViennaCL array computations will
occur? I was looking for some flags like -viennacl cpu/gpu/accelerator but
could not find any in -help.

3) How can one pass compiler flags when building OpenCL kernels in ViennaCL?

Thanks,
Mani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140120/17b43cea/attachment.html>


More information about the petsc-dev mailing list