How to use the OpenCL linear solvers

From KratosWiki
Revision as of 09:48, 22 June 2010 by Rrossi (Talk | contribs)
Jump to: navigation, search

How to use the OpenCL Linear Solvers

Experimental support was added to the Kratos to use modern GPU (or many-core CPUs) basing on the OpenCL programming model.

In order to provide basic linear system solving capabilities, the Kratos uses the ViennaCL library, recently developed at Vienna TU by Ing. Karl Rupp and others. The library, which features a MIT like license, can be currently downloaded from the Kratos SVN.

Compiling the library

The installation of the library requires the presence of an OpenCL compiler on the system, and of driver support to run on GPUs. If no GPU is present, a fallback on the CPU is provided by the AMD stream implementation.

In order to install the driver (under ubuntu linux 10.04) follow the following steps:

  • Download and install the deb package (X86 or x86_64 depending on your system) from the link:

[1]

Post by "Nou". Install both "ati-opencl-runtime" and "ati-opencl-dev"

  • If you have a ATI high-end GPU, that you would like to use to accelerate the calculations, make sure you install the catalyst driver 10.4 or later versions
  • In order to use NVIDIA GPUs install the driver version 195 or later


Using the library

The interface to the iterative solver library is very similar to the standard one for the Kratos internal linear solvers:

for example a call to the BICGStabSolver the standard python interface is

  linear_solver =  BICGSTABSolver(1e-3, 5000)

can be replaced by

  from KratosOpenCLApplication import *
  precision = OpenCLPrecision.Single 
  solver_type = OpenCLSolverType.BiCGStab
  preconditioner_type = OpenCLPreconditionerType.NoPreconditioner
  fluid_solver.pressure_linear_solver = ViennaCLSolver(1e-3,5000,precision,solver_type,preconditioner_type)

the list of options that are currently available is:

  OpenCLPrecision.Single //to use single precision in the solution (available in most gpus)
  OpenCLPrecision.Double //requires hardware support
  OpenCLSolverType.CG
  OpenCLSolverType.BiCGStab
  OpenCLSolverType.GMRES
  OpenCLPreconditionerType.NoPreconditioner
  OpenCLPreconditionerType.ILU
Personal tools
Categories