[petsc-dev] ViennaCL-bindings in next

Karl Rupp rupp at mcs.anl.gov
Thu Mar 21 18:50:29 CDT 2013


the interface to ViennaCL [1] has just been merged to 'next', enabling 
PETSc to use OpenCL-enabled devices (most notably Intel's Xeon Phi and 
GPUs from AMD in addition to the existing NVIDIA bindings). I tested it 
with Vector-, Matrix-, and KSP- examples.

The new bindings are enabled by the configure flags

The OpenCL headers can be obtained on the Khronos webpage [2] and are 
often available via package managers, e.g.
$> sudo apt-get install opencl-headers
$> sudo yam install opencl-headers
In such case, the OpenCL include directory is typically /usr/include
(BuildSystem may not detect these headers correctly on Mac OS, I'm 
working on this). The OpenCL library comes with your graphics driver and 
is usually located at /usr/lib/. There is no separate compiler as for 
CUDA needed!


- What is the performance difference between OpenCL and CUDA for GPUs?
My experience is that for large problem sizes they are equivalent for 
almost all linear algebra kernels. For small problem sizes (kernel 
execution less than 1ms), CUDA is currently superior because of lower 

- Which solvers can I use with the ViennaCL-bindings?
The same as with CUSP. Most notably the usual CG, BiCGS, GMRES.

- Which preconditioners are provided in the ViennaCL-bindings?
Currently none. You can, however, use all the standard CPU-based 
preconditioners in PETSc together with ViennaCL matrices and vectors.

- Which command line options do I need to use?
Use -vec_type viennacl -mat_type aijviennacl
On Intel's Xeon Phi you also need to pass -viennacl_device_accelerator.
(If you read this email in an archive: Check the manual for current flags).

Best regards,

[1] http://viennacl.sourceforge.net/
[2] http://www.khronos.org/registry/cl/

More information about the petsc-dev mailing list