5.3.3 Exemplary Plugin Implementation

For the sake of clarity, an exemplary plugin implementation is provided, which not only depicts the utilization of the developed framework with respect to using already available implementations in plugins, but is also a reference for the subsequent investigation of the implementation details.

The plugin wraps a ViennaCL [1] iterative linear solver implementation, a high-performance reusable linear solver component supporting shared-memory computing platforms as well as accelerators (Section 5.1). Utilizing ViennaCL in this example additionally underlines the straightforward applicability of our framework with respect to utilizing already available implementations.

In the following, the full implementation of a simplistic ViennaCL-powered iterative solver plugin is given.

1// Plugin Name 
2#define PLUGIN_NAME ViennaCLLinSol 
3// Plugin Class Implementation 
4struct PLUGIN_NAME : public plugin { 
5INIT_VIENNAX_PLUGIN 
6// Initialization: Setup Sockets 
7void init() { 
8  create_sink  <Matrix>("A"); 
9  create_sink  <Vector>("b"); 
10  create_source<Vector>("x"); } 
11// Execution: Perform computation 
12bool execute(std::size_t call) { 
13  // Access socket data 
14  Matrix& A = access_sink  <Matrix>("A"); 
15  Vector& b = access_sink  <Vector>("b"); 
16  Vector& x = access_source<Vector>("x"); 
17  // Solve the system 
18  x = solve(A, b, bicgstab_tag()); 
19  return true; } }; 
20FINALIZE_VIENNAX_PLUGIN

The plugin’s name (Line 2), class definition (Lines 4), and required macros - automatically generating boilerplate code required for the plugin mechanism - are implemented (Lines 5, 20). The data dependencies are set up in the initialization part (Lines 7-10). Two input sockets (A, b) and one output socket (x) are created in ViennaX’s central socket database, relating to the linear system Ax  = b . The data associated with the sockets are accessed (Lines 14-16) and the system is solved by using ViennaCL’s biconjugate gradient stabilized linear solver [1] (Line 18). The result vector x is automatically available to other plugins via the outgoing data connection.