convert.c File Reference


Detailed Description

Conversion between CSR and SPARSITY-style BCSR (i.e., register blocking) format.

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <oski/config.h>
#include <oski/common.h>
#include <oski/modloader.h>
#include <oski/matrix.h>
#include <oski/CSR/format.h>
#include <oski/CSR/module.h>
#include <oski/BCSR/format.h>
#include <oski/BCSR/module.h>
#include <oski/xforms_internal.h>

Functions

static int ConvertFullBlocksFromCSR (const oski_index_t *ptr, const oski_index_t *ind, const oski_value_t *val, oski_index_t base, oski_index_t m, oski_index_t n, oski_index_t r, oski_index_t c, oski_index_t **p_bptr, oski_index_t **p_bind, oski_value_t **p_bval)
 Given an $m\times n$ CSR matrix $A$, convert the first $m-\mathrm{mod}(m,r)$ rows into $r\times c$ BCSR format.
static int ConvertFromCSR (oski_matBCSR_t *A, oski_index_t r, oski_index_t c, const oski_index_t *ptr, const oski_index_t *ind, const oski_value_t *val, oski_index_t m, oski_index_t n, oski_index_t base)
 Convert from full CSR to BCSR.
static int ExpandSymm (const oski_matCSR_t *mat, const oski_matcommon_t *props, oski_matCSR_t **p_mat_full)
void * oski_CreateMatReprFromCSR (const oski_matCSR_t *mat, const oski_matcommon_t *props,...)
 Method: Instantiate from an existing CSR representation.
static void CopyOne (const oski_matBCSR_t *A, oski_matCSR_t *B, oski_index_t i0)
static int ConvertToCSR (const oski_matBCSR_t *A, const oski_matcommon_t *props, oski_matCSR_t *B)
oski_matCSR_toski_ConvertMatReprToCSR (const void *mat, const oski_matcommon_t *props)
 Method: Convert to CSR format.
void * oski_CopyMatRepr (const void *mat, const oski_matcommon_t *props)
 Method: Duplicate a matrix representation.
void oski_DestroyMatRepr (void *mat)
 Method: Destroy matrix type-specific representation.
int oski_CreateLuaMatReprFromCSR (lua_State *L)
 Matrix-type specific method to convert from a CSR matrix, with arguments passed on the Lua stack.


Function Documentation

static int ConvertFromCSR oski_matBCSR_t A,
oski_index_t  r,
oski_index_t  c,
const oski_index_t *  ptr,
const oski_index_t *  ind,
const oski_value_t *  val,
oski_index_t  m,
oski_index_t  n,
oski_index_t  base
[static]
 

Convert from full CSR to BCSR.

Precondition:
None of A, mat, props are NULL

c <= n

static int ConvertFullBlocksFromCSR const oski_index_t *  ptr,
const oski_index_t *  ind,
const oski_value_t *  val,
oski_index_t  base,
oski_index_t  m,
oski_index_t  n,
oski_index_t  r,
oski_index_t  c,
oski_index_t **  p_bptr,
oski_index_t **  p_bind,
oski_value_t **  p_bval
[static]
 

Given an $m\times n$ CSR matrix $A$, convert the first $m-\mathrm{mod}(m,r)$ rows into $r\times c$ BCSR format.

If the converted matrix has $n_b$ blocks, this implementation executes in $O(\mbox{stored non-zeros}) = O(n_b\cdot r\cdot c)$ time, but requires $O(n\cdot r)$ auxiliary storage space to store a dense copy of one block row.

This long procedure is divided into two phases:

  1. Count the exact number of new blocks to create.
  2. Convert to block format, one block row at a time.

This routine assumes the CSR matrix uses full storage, but otherwise is flexible with regard to the following variations:

  • 0 or 1-based indexing
  • 'ptr[0]' does not have to start at 'base' (i.e., caller can pass a subset of rows of a larger matrix)
  • Column indices do not have to be sorted.

Parameters:
[in] ptr CSR row pointers.
[in] ind CSR column indices.
[in] val CSR explicitly stored values.
[in] base Index base (0-based or 1-based)
[in] m Logical number of matrix rows
[in] n Logical number of matrix columns
[in] r Desired row block size
[in] c Desired column block size
[in,out] p_bptr Used to return the BCSR block row pointers. Must not equal NULL.
[in,out] p_bind Used to return the BCSR block column indices. Must not equal NULL.
[in,out] p_bval Used to return the explicitly stored blocks. Must not equal NULL.
Note:
Block column indices are unsorted on output.
Returns:
On success, returns 0 and sets *p_bptr, *p_bind, and *p_bval to the BCSR representation. Otherwise, returns an error code and leaves p_bptr, p_bind, and p_bval unchanged. or an error code otherwise.


Generated on Wed Sep 19 16:41:21 2007 for BeBOP Optimized Sparse Kernel Interface Library by  doxygen 1.4.6