ViennaCL aims at compatibility with as many other libraries as possible. This is on the one hand achieved by using generic implementations of the individual algorithms, and on the other hand by providing the necessary wrappers.
The interfaces to third-party libraries provided with ViennaCL are explained in the following subsections. Please feel free to suggest additional libraries for which an interface should be shipped with ViennaCL.
Since it is unlikely that all third-party libraries for which ViennaCL provides interfaces are installed on the target machine, the wrappers are disabled by default. To selectively enable the wrappers, the appropriate preprocessor constants VIENNACL_WITH_XXXX
have to be defined prior to any #include
statements for ViennaCL headers. This can for example be assured by passing the preprocessor constant directly when launching the compiler. With GCC
this is for instance achieved by the -D
switch.
Since all types in ViennaCL have the same interface as their counterparts in Boost.uBLAS, most code written for ViennaCL objects remains valid when using Boost.uBLAS objects.
The above code is valid for either the ViennaCL namespace declarations, or the Boost.uBLAS namespace. Note that the iterative solvers are not part of Boost.uBLAS and therefore the explicit namespace specification is required. More examples for the exchangability of Boost.uBLAS and ViennaCL can be found in the tutorials in the examples/tutorials/
folder.
VIENNACL_WITH_UBLAS
must be defined prior to any other ViennaCL include statements. This is essential for enabling the respective wrappers.iterative-ublas.cpp
for a complete example on iterative solvers using Boost.uBLAS types.To copy data from Armadillo [1] objects (version 5.x) to ViennaCL, the copy()
-functions are used just as for Boost.uBLAS and STL types:
In addition, the STL-compliant iterator-version of viennacl::copy()
taking three arguments can be used for copying vector data. Here, all types prefixed with arma
are Armadillo types, the prefix vcl
indicates ViennaCL objects. Similarly, the transfer from ViennaCL back to Armadillo is accomplished by
The iterative solvers in ViennaCL can also be used directly with Armadillo objects:
VIENNACL_WITH_ARMADILLO
must be defined prior to any other ViennaCL include statements. This is essential for enabling the respective wrappers.iterative-armadillo.cpp
and armadillo-with-viennacl.cpp
for complete examples.To copy data from Eigen [11] objects (version 3.x.y) to ViennaCL, the copy()
-functions are used just as for Boost.uBLAS and STL types:
In addition, the STL-compliant iterator-version of viennacl::copy()
taking three arguments can be used for copying vector data. Here, all types prefixed with eigen
are Eigen types, the prefix vcl
indicates ViennaCL objects. Similarly, the transfer from ViennaCL back to Eigen
is accomplished by
The iterative solvers in ViennaCL can also be used directly with Eigen objects:
VIENNACL_WITH_EIGEN
must be defined prior to any other ViennaCL include statements. This is essential for enabling the respective wrappers.iterative-eigen.cpp
and eigen-with-viennacl.cpp
for complete examples.The following lines demonstate how ViennaCL types are filled with data from MTL [22] objects:
In addition, the STL-compliant iterator-version of viennacl::copy()
taking three arguments can be used for copying vector data. Here, all types prefixed with mtl4
are MTL types, the prefix vcl
indicates ViennaCL objects. Similarly, the transfer from ViennaCL back to MTL is accomplished by
Even though MTL provides its own set of iterative solvers, the iterative solvers in ViennaCL can also be used:
Our internal tests have shown that the execution time of MTL solvers is equal to ViennaCL solvers when using MTL types.
VIENNACL_WITH_MTL4
must be defined prior to any other ViennaCL include statements. This is essential for enabling the respective wrappers.iterative-mtl4.cpp
and mtl4-with-viennacl.cpp
for complete examples.