|
BeBOP Optimized Sparse Kernel Interface Library
1.0.1h
|
This module defines the public interface, i.e., part of the library implementation intended for use by end-users and documented in detail at the following URL: http://bebop.cs.berkeley.edu/oski/oski-interface.pdf . More...
Data Structures | |
| struct | oski_permstruct_t |
| Generic row/column permutation structure. More... | |
Modules | |
| Error codes and error handling. | |
| Set explicit workload hints. | |
| Kernels (matrix type-independent implementations). | |
| Single- and multivector view creation. | |
Vector views are wrappers around user-declared dense array matrix representations. | |
Files | |
| file | oski.h |
Single header file that includes all the module headers that end-users should need. | |
Defines | |
| #define | INVALID_MAT ((oski_matrix_t)NULL) |
| Invalid (NULL) matrix handle. | |
| #define | INVALID_VEC ((oski_vecview_t)NULL) |
| Invalid (NULL) vector view handle. | |
| #define | OSKI_CHECK_COPYMODE(x) IS_VAL_IN_RANGE(x, COPY_INPUTMAT, SHARE_INPUTMAT) |
| Returns 1 <==> the specified copy mode x is legal. | |
Typedefs | |
| typedef oski_permstruct_t * | oski_perm_t |
| Permutation handle. | |
Enumerations | |
| enum | oski_copymode_t { COPY_INPUTMAT, SHARE_INPUTMAT } |
| Input matrix copy modes. More... | |
| enum | oski_storage_t { LAYOUT_COLMAJ, LAYOUT_ROWMAJ } |
| Dense multiple-vector storage layout. More... | |
| enum | oski_matop_t { OP_NORMAL, OP_CONJ, OP_TRANS, OP_CONJ_TRANS } |
| Matrix transpose options. More... | |
| enum | oski_ataop_t { OP_AT_A, OP_AH_A, OP_A_AT, OP_A_AH } |
Transpose options for matrix-transpose-times-matrix ( ) kernel. More... | |
| enum | oski_inmatprop_t { INMATPROP_NULL = -1, MAT_GENERAL = 0, MAT_TRI_UPPER, MAT_TRI_LOWER, MAT_SYMM_UPPER, MAT_SYMM_LOWER, MAT_SYMM_FULL, MAT_HERM_UPPER, MAT_HERM_LOWER, MAT_HERM_FULL, MAT_DIAG_EXPLICIT, MAT_UNIT_DIAG_IMPLICIT, INDEX_ONE_BASED, INDEX_ZERO_BASED, INDEX_UNSORTED, INDEX_SORTED, INDEX_REPEATED, INDEX_UNIQUE, INMATPROP_MAX } |
| Input matrix properties. More... | |
Functions | |
| oski_value_t | oski_GetMatEntry (const oski_matrix_t A_tunable, oski_index_t row, oski_index_t col) |
| Returns the value of a matrix element. | |
| int | oski_SetMatEntry (oski_matrix_t A_tunable, oski_index_t row, oski_index_t col, oski_value_t new_val) |
| Changes the value of the specified matrix element. | |
| int | oski_GetMatClique (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, oski_vecview_t vals) |
| Returns a block of values, defined by a clique, from a matrix. | |
| int | oski_SetMatClique (oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, const oski_vecview_t vals) |
| Changes a block of values, defined by a clique, in a matrix. | |
| int | oski_GetMatDiagValues (const oski_matrix_t A_tunable, oski_index_t diag_num, oski_vecview_t vals) |
Extract the diagonal from , that is, all entries such that . | |
| int | oski_SetMatDiagValues (oski_matrix_t A_tunable, oski_index_t diag_num, const oski_vecview_t vals) |
Sets the values along diagonal from , that is, all entries such that . | |
| oski_matrix_t | oski_CreateMatCSR (oski_index_t *Aptr, oski_index_t *Aind, oski_value_t *Aval, oski_index_t num_rows, oski_index_t num_cols, oski_copymode_t mode, int k,...) |
| Creates and returns a valid tunable matrix object from a compressed sparse row (CSR) representation. | |
| oski_matrix_t | oski_CreateMatCSC (oski_index_t *Aptr, oski_index_t *Aind, oski_value_t *Aval, oski_index_t num_rows, oski_index_t num_cols, oski_copymode_t mode, int k,...) |
| Creates and returns a valid tunable matrix object from a compressed sparse column (CSC) representation. | |
| oski_matrix_t | oski_CopyMat (const oski_matrix_t A_tunable) |
| Creates a copy of a matrix object. | |
| int | oski_DestroyMat (oski_matrix_t A_tunable) |
| Frees object memory associated with a given matrix object. | |
| int | oski_IsMatPermuted (const oski_matrix_t A_tunable) |
| Checks whether a matrix has been tuned by reordering. | |
| const_oski_matrix_t | oski_ViewPermutedMat (const oski_matrix_t A_tunable) |
Given a matrix , possibly reordered during tuning to the form , returns a read-only object corresponding to . | |
| const_oski_perm_t | oski_ViewPermutedMatRowPerm (const oski_matrix_t A_tunable) |
Given a matrix , possible reordered during tuning to the form , returns a read-only object corresponding to . | |
| const_oski_perm_t | oski_ViewPermutedMatColPerm (const oski_matrix_t A_tunable) |
Given a matrix , possible reordered during tuning to the form , returns a read-only object corresponding to (and NOT ). | |
| int | oski_PermuteVecView (const oski_perm_t P, oski_matop_t opP, oski_vecview_t x_view) |
Permute a vector view object, i.e., computes , where . | |
| int | oski_TuneMat (oski_matrix_t A_tunable) |
| Tune the matrix object using all hints and implicit profiling data. | |
| char * | oski_GetMatTransforms (const oski_matrix_t A_tunable) |
| Returns a string representation of the data structure transformations that were applied to the given matrix during tuning. | |
| int | oski_ApplyMatTransforms (const oski_matrix_t A_tunable, const char *xforms) |
| Replace the current data structure for a given matrix object with a new data structure specified by a given string. | |
| oski_vecview_t | oski_CreateVecView (oski_value_t *x, oski_index_t length, oski_index_t inc) |
Creates a valid view on a single dense column vector . | |
| int | oski_DestroyVecView (oski_vecview_t x) |
| Destroy an existing vector view. | |
| oski_vecview_t | oski_CopyVecView (const oski_vecview_t x) |
| Creates a copy of the given (multi)vector view. | |
This module defines the public interface, i.e., part of the library implementation intended for use by end-users and documented in detail at the following URL: http://bebop.cs.berkeley.edu/oski/oski-interface.pdf .
Our implementation requires users also to call oski_Init() before calling any of the routines in the public interface. Users may optionally call oski_Close() when the library is no longer needed by an application to free internal data structures.
| enum oski_ataop_t |
Transpose options for matrix-transpose-times-matrix (
) kernel.
| enum oski_copymode_t |
Input matrix copy modes.
On matrix handle creation, the library copies the user's input matrix arrays in one of two modes:
| enum oski_inmatprop_t |
Input matrix properties.
Properties are divided into subcategories:
Properties within a given subcategory are mutually exclusive, with default values as marked.
| enum oski_matop_t |
Matrix transpose options.
The user may apply the transpose or conjugate transpose of a matrix
.
| enum oski_storage_t |
Dense multiple-vector storage layout.
On creation of a dense multiple-vector (i.e., dense matrix), the layout parameter specifies how the data is stored. Let
be a logical
matrix stored in a dense physical array X with stride
. Then,
is stored in physical array element X[
], where
. This layout is the Fortran default for statically declared 2-D arrays, and is also the usual BLAS convention.
is stored in physical array element X[
], where
. This layout is the C default for statically declared 2-D arrays.Following the dense BLAS convention, we sometimes also refer to the stride parameter
as the leading dimension.
| int oski_ApplyMatTransforms | ( | oski_matrix_t | A_tunable, |
| const char * | xforms | ||
| ) |
Replace the current data structure for a given matrix object with a new data structure specified by a given string.
| [in] | A_tunable | A valid matrix object. |
| [in] | xforms | A valid OSKI-Lua program describing the transformation to apply to the matrix. |
References CloseLua(), CreateLuaMatObj(), ERR_LOAD_MOD, ERR_OLUA_NORET, oski_matstruct_t::input_mat, INVALID_ID, MACRO_TO_STRING, oski_matlua_t::mat, OLUA_INMAT, OpenLua(), oski_HandleError, oski_PrintDebugMessage(), oski_matstruct_t::props, oski_matspecific_t::repr, RunLua(), and oski_matspecific_t::type_id.
| oski_matrix_t oski_CopyMat | ( | const oski_matrix_t | A_tunable | ) |
Creates a copy of a matrix object.
Creates a copy of a matrix object.
According to these steps, A_copy does not have any of A_tunable's workload hints or implicit workload gathered from implicit profiling.
| [in] | A_tunable | Handle to a valid matrix . |
, or INVALID_MAT on error. References CopyMatSpecific(), ERR_OUT_OF_MEMORY, oski_matstruct_t::input_mat, INVALID_MAT, oski_CopyMem, oski_DuplicateString(), OSKI_ERR, oski_PrintDebugMessage(), oski_matstruct_t::props, oski_matstruct_t::structhints, oski_matstruct_t::time_stream, oski_matstruct_t::tuned_mat, and oski_matstruct_t::tuned_xforms.
| oski_vecview_t oski_CopyVecView | ( | const oski_vecview_t | x | ) |
Creates a copy of the given (multi)vector view.
| [in] | x | (Multi)vector view to duplicate. |
References INVALID_VEC, oski_vecstruct_t::num_cols, oski_vecstruct_t::num_rows, oski_vecstruct_t::orient, oski_vecstruct_t::stride, and oski_vecstruct_t::val.
| oski_matrix_t oski_CreateMatCSC | ( | oski_index_t * | Aptr, |
| oski_index_t * | Aind, | ||
| oski_value_t * | Aval, | ||
| oski_index_t | num_rows, | ||
| oski_index_t | num_cols, | ||
| oski_copymode_t | mode, | ||
| int | k, | ||
| ... | |||
| ) |
Creates and returns a valid tunable matrix object from a compressed sparse column (CSC) representation.
| [in] | num_rows | |
| [in] | num_cols | |
| [in] | Aptr | CSC row pointers. |
| [in] | Aind | CSC column indices. |
| [in] | Aval | CSC non-zero values. |
| [in] | k | Number of explicitly specified semantic properties of (Aptr, Aind, Aval). |
| oski_matrix_t oski_CreateMatCSR | ( | oski_index_t * | Aptr, |
| oski_index_t * | Aind, | ||
| oski_value_t * | Aval, | ||
| oski_index_t | num_rows, | ||
| oski_index_t | num_cols, | ||
| oski_copymode_t | mode, | ||
| int | k, | ||
| ... | |||
| ) |
Creates and returns a valid tunable matrix object from a compressed sparse row (CSR) representation.
| [in] | num_rows | |
| [in] | num_cols | |
| [in] | Aptr | CSR row pointers. |
| [in] | Aind | CSR column indices. |
| [in] | Aval | CSR non-zero values. |
| [in] | k | Number of explicitly specified semantic properties of (Aptr, Aind, Aval). |
| oski_vecview_t oski_CreateVecView | ( | oski_value_t * | x, |
| oski_index_t | length, | ||
| oski_index_t | inc | ||
| ) |
Creates a valid view on a single dense column vector
.
| [in] | x | Vector data. |
| [in] | length | Logical vector length, >= 0. |
| [in] | inc | Physical stride between consecutive elements. inc must be >= 1. |
References CreateMultiVecView_NoError(), INVALID_VEC, LAYOUT_ROWMAJ, OSKI_ERR_NULL_ARG, and OSKI_ERR_SMALL_ARG.
| int oski_DestroyMat | ( | oski_matrix_t | A_tunable | ) |
Frees object memory associated with a given matrix object.
| [in,out] | A_tunable | A valid matrix handle. |
References oski_PrintDebugMessage().
| int oski_DestroyVecView | ( | oski_vecview_t | x | ) |
Destroy an existing vector view.
| [in,out] | x | (Multi)vector view to free. |
References oski_Free.
| int oski_GetMatClique | ( | const oski_matrix_t | A_tunable, |
| const oski_index_t * | rows, | ||
| oski_index_t | num_rows, | ||
| const oski_index_t * | cols, | ||
| oski_index_t | num_cols, | ||
| oski_vecview_t | vals | ||
| ) |
Returns a block of values, defined by a clique, from a matrix.
Returns a block of values, defined by a clique, from a matrix.
References CheckCliqueArgs(), ERR_NOT_IMPLEMENTED, GetClique(), GetCliqueDefault(), oski_matstruct_t::input_mat, MACRO_TO_STRING, oski_matstruct_t::props, and oski_matstruct_t::tuned_mat.
| int oski_GetMatDiagValues | ( | const oski_matrix_t | A_tunable, |
| oski_index_t | diag_num, | ||
| oski_vecview_t | diag_vals | ||
| ) |
Extract the diagonal
from
, that is, all entries
such that
.
Extract the diagonal
from
, that is, all entries
such that
.
References CheckDiagValuesArgs(), ERR_NOT_IMPLEMENTED, GetDiagValues(), GetDiagValuesDefault(), oski_matstruct_t::input_mat, MACRO_TO_STRING, oski_matstruct_t::props, and oski_matstruct_t::tuned_mat.
| oski_value_t oski_GetMatEntry | ( | const oski_matrix_t | A_tunable, |
| oski_index_t | row, | ||
| oski_index_t | col | ||
| ) |
Returns the value of a matrix element.
| [in] | A_tunable | The object representing an matrix . |
| [in] | row | Row index (1-based). |
| [in] | col | Column index (1-based). |
, or a NaN on error. References ERR_NOT_IMPLEMENTED, GetMatEntry(), oski_matstruct_t::input_mat, INVALID_ID, INVALID_MAT, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, OSKI_ERR_BAD_ENTRY, OSKI_ERR_BAD_MAT, OSKI_ERR_MATTYPEID_MEMBER, oski_matstruct_t::props, oski_matstruct_t::tuned_mat, oski_matspecific_t::type_id, and VAL_SET_ZERO.
| char* oski_GetMatTransforms | ( | const oski_matrix_t | A_tunable | ) |
Returns a string representation of the data structure transformations that were applied to the given matrix during tuning.
| [in] | A_tunable | Valid matrix handle. |
. References ERR_OUT_OF_MEMORY, INVALID_MAT, oski_DuplicateString(), OSKI_ERR, OSKI_ERR_BAD_MAT, and oski_matstruct_t::tuned_xforms.
| int oski_IsMatPermuted | ( | const oski_matrix_t | A_tunable | ) |
Checks whether a matrix has been tuned by reordering.
| [in] | A_tunable | Matrix to check. |
| int oski_PermuteVecView | ( | const oski_perm_t | P, |
| oski_matop_t | opP, | ||
| oski_vecview_t | x_view | ||
| ) |
Permute a vector view object, i.e., computes
, where
.
| [in] | P | Permutation matrix . |
| [in] | opP | Transpose option. |
| [in,out] | x_view | Vector view to permute. |
References CheckValidPerm(), oski_vecstruct_t::colinc, ERR_BAD_ARG, ERR_BAD_VECVIEW, ERR_DIM_MISMATCH, ERR_OUT_OF_MEMORY, oski_permstruct_t::length, oski_vecstruct_t::num_cols, oski_vecstruct_t::num_rows, OSKI_CHECK_MATOP, OSKI_ERR_BAD_MATOP, OSKI_ERR_BAD_VEC, oski_Free, oski_HandleError, oski_Malloc, oski_permstruct_t::perm, Permute(), oski_vecstruct_t::rowinc, and oski_vecstruct_t::val.
| int oski_SetMatClique | ( | const oski_matrix_t | A_tunable, |
| const oski_index_t * | rows, | ||
| oski_index_t | num_rows, | ||
| const oski_index_t * | cols, | ||
| oski_index_t | num_cols, | ||
| const oski_vecview_t | vals | ||
| ) |
Changes a block of values, defined by a clique, in a matrix.
Changes a block of values, defined by a clique, in a matrix.
References CheckCliqueArgs(), ERR_NOT_IMPLEMENTED, oski_matstruct_t::input_mat, MACRO_TO_STRING, oski_matstruct_t::props, SetClique(), SetCliqueDefault(), and oski_matstruct_t::tuned_mat.
| int oski_SetMatDiagValues | ( | const oski_matrix_t | A_tunable, |
| oski_index_t | diag_num, | ||
| const oski_vecview_t | diag_vals | ||
| ) |
Sets the values along diagonal
from
, that is, all entries
such that
.
Sets the values along diagonal
from
, that is, all entries
such that
.
References CheckDiagValuesArgs(), ERR_NOT_IMPLEMENTED, oski_matstruct_t::input_mat, MACRO_TO_STRING, oski_matstruct_t::props, SetDiagValues(), SetDiagValuesDefault(), and oski_matstruct_t::tuned_mat.
| int oski_SetMatEntry | ( | const oski_matrix_t | A_tunable, |
| oski_index_t | row, | ||
| oski_index_t | col, | ||
| oski_value_t | new_val | ||
| ) |
Changes the value of the specified matrix element.
| [in] | A_tunable | The object representing an matrix . |
| [in] | row | Row index (1-based). |
| [in] | col | Column index (1-based). |
| [in] | new_val | New value for element . |
to new_val and returns 0. If
specifies an invalid or structural zero element, then this routine returns an error code.If the matrix is symmetric (or Hermitian), then this routine also assigns
to the new value (or conjugated value) accordingly.
References ERR_BAD_ARG, ERR_BAD_ID, oski_matstruct_t::input_mat, INVALID_MAT, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, OSKI_ERR_BAD_ENTRY, OSKI_ERR_BAD_MAT, OSKI_ERR_NO_REPR, oski_matstruct_t::props, SetMatEntry(), and oski_matstruct_t::tuned_mat.
| int oski_TuneMat | ( | oski_matrix_t | A_tunable | ) |
Tune the matrix object using all hints and implicit profiling data.
Tune the matrix object using all hints and implicit profiling data.
WHILE
!IsTuned(A)
AND tuning_time_left > 0
AND i_heur <= NUM_HEURISTICS
DO
LET heur = GetHeuristic( i_heur );
LET results = NULL
IF GetTotalCostEstimate(heur, A) <= tuning_time_left THEN
LET t0 = GetTimer();
results = EvaluateHeuristic( heur, A );
// results == NULL if heuristic does not apply to A
LET elapsed_time = GetTimer() - t0;
tuning_time_left -= elapsed_time;
ENDIF
IF results THEN
LET t0 = GetTimer();
A_tuned = ApplyHeuristic( heur, results, A );
// convert A to new data structure
LET elapsed_time = GetTimer() - t0;
tuning_time_left -= elapsed_time;
A = ChooseFastest( A, A_tuned, A->trace );
ENDIF
i_heur = i_heur + 1;
DONE
The current implementation does not try to re-tune if already tuned.
Check that the new data structure really is faster than the old.
References ChooseFastest(), ComputeTuningBudget(), INVALID_ID, oski_matstruct_t::is_shared, oski_GetNumHeur(), oski_LookupHeurDescById(), oski_LookupHeurIdByNum(), oski_PrintDebugMessage(), oski_ReadElapsedTime(), oski_RestartTimer(), oski_StopTimer(), oski_matstruct_t::time_stream, oski_matstruct_t::timer, oski_matstruct_t::tuned_mat, TUNESTAT_AS_IS, TUNESTAT_NEW, and oski_matspecific_t::type_id.
| const_oski_matrix_t oski_ViewPermutedMat | ( | const oski_matrix_t | A_tunable | ) |
Given a matrix
, possibly reordered during tuning to the form
, returns a read-only object corresponding to
.
| [in] | A_tunable | Matrix to check. |
, or INVALID_MAT on error.| const_oski_perm_t oski_ViewPermutedMatColPerm | ( | const oski_matrix_t | A_tunable | ) |
Given a matrix
, possible reordered during tuning to the form
, returns a read-only object corresponding to
(and NOT
).
| const_oski_perm_t oski_ViewPermutedMatRowPerm | ( | const oski_matrix_t | A_tunable | ) |
Given a matrix
, possible reordered during tuning to the form
, returns a read-only object corresponding to
.
1.7.6.1