Added typed (BLAS-like) API code examples.

Details:
- Added new example code to examples/tapi demonstrating how to use the
  BLIS typed API. These code examples directly mirror the corresponding
  example code files in examples/oapi. This setup provides a convenient
  opportunity for newcomers to BLIS to compare and contrast the typed
  and object APIs when they are used to perform the same tasks.
- Minor cleanups to examples/oapi.
This commit is contained in:
Field G. Van Zee
2018-07-03 18:27:29 -05:00
parent 3f387ca35e
commit b45ea92fc6
19 changed files with 1896 additions and 28 deletions

View File

@@ -43,11 +43,13 @@ int main( int argc, char** argv )
dim_t m, n;
inc_t rs, cs;
//
// This file demonstrates the basics of creating objects in BLIS,
// inspecting their basic properties, and printing matrix objects.
//
//
// Example 1: Create an object containing a 4x3 matrix of double-
// precision real elements stored in column-major order.
@@ -69,6 +71,7 @@ int main( int argc, char** argv )
rs = 1; cs = 6;
bli_obj_create( dt, m, n, rs, cs, &a2 );
//
// Example 2: Create an object containing a 4x3 matrix of double-
// precision real elements stored in row-major order.
@@ -87,6 +90,7 @@ int main( int argc, char** argv )
rs = 8; cs = 1;
bli_obj_create( dt, m, n, rs, cs, &a4 );
//
// Example 3: Create objects using other floating-point datatypes.
//
@@ -98,6 +102,7 @@ int main( int argc, char** argv )
bli_obj_create( BLIS_SCOMPLEX, m, n, rs, cs, &a6 );
bli_obj_create( BLIS_DCOMPLEX, m, n, rs, cs, &a7 );
//
// Example 4: Create objects using default (column) storage so that
// we avoid having to specify rs and cs manually.
@@ -112,6 +117,7 @@ int main( int argc, char** argv )
// in doubt, query the value!
bli_obj_create( BLIS_FLOAT, 3, 5, 0, 0, &a8 );
//
// Example 5: Inspect object fields after creation to expose
// possible alignment/padding.
@@ -128,6 +134,7 @@ int main( int argc, char** argv )
printf( "row stride: %d\n", ( int )bli_obj_row_stride( &a8 ) );
printf( "col stride: %d\n", ( int )bli_obj_col_stride( &a8 ) );
//
// Example 6: Inspect object fields after creation of other floating-
// point datatypes.
@@ -162,6 +169,7 @@ int main( int argc, char** argv )
printf( "row stride: %d\n", ( int )bli_obj_row_stride( &a11 ) );
printf( "col stride: %d\n", ( int )bli_obj_col_stride( &a11 ) );
//
// Example 7: Initialize an object's elements to random values and then
// print the matrix.
@@ -181,6 +189,7 @@ int main( int argc, char** argv )
// elements of type 'float'.
bli_printm( "matrix 'a9' contents:", &a9, "%4.1f", "" );
//
// Example 8: Randomize and then print from an object containing a complex
// matrix.
@@ -193,13 +202,14 @@ int main( int argc, char** argv )
bli_randm( &a11 );
bli_printm( "matrix 'a11' contents (complex):", &a11, "%4.1f", "" );
//
// Example 9: Create, randomize, and print vector objects.
//
printf( "\n#\n# -- Example 9 --\n#\n\n" );
// Now let's create two vector object--a row vector and a column vector.
// Now let's create two vector objects--a row vector and a column vector.
// (A vector object is like a matrix object, except that it has at least
// one unit dimension (equal to one).
bli_obj_create( BLIS_DOUBLE, 4, 1, 0, 0, &v1 );