Compute.NET icon indicating copy to clipboard operation
Compute.NET copied to clipboard

How to use SpBlas

Open AviAvni opened this issue 7 years ago • 2 comments

I'm trying to use the SpBlas API but get error

static void Main(string[] args)
{
    double[] values_A = { 10, 11, 12, 13, 15, 14, 16, 17, 18, 19 };
    int[] columns_A = { 0, 1, 2, 3, 0, 4, 1, 2, 3, 4 };
    int[] rowIndex_A1 = { 0, 2, 4, 6, 8, 10 };
    int[] rowIndex_A2 = { 2, 4, 6, 8, 10 };

    double[] values_B = { 5, 6, 7, 8, 9 };
    int[] columns_B = { 0, 1, 2, 3, 4 };
    int[] rowIndex_B1 = { 0, 1, 2, 3, 4, 5 };
    int[] rowIndex_B2 = { 1, 2, 3, 4, 5 };

    var a = new SparseMatrix();
    var b = new SparseMatrix();

    var res = SpBlas.MklSparseDCreateCsr(a, SparseIndexBaseT.SPARSE_INDEX_BASE_ZERO, 5, 5, ref rowIndex_A1[0], ref rowIndex_A2[0], ref columns_A[0], ref values_A[0]);
    res = SpBlas.MklSparseDCreateCsr(b, SparseIndexBaseT.SPARSE_INDEX_BASE_ZERO, 5, 5, ref rowIndex_B1[0], ref rowIndex_B2[0], ref columns_B[0], ref values_B[0]);

    var c = new SparseMatrix();
    res = SpBlas.MklSparseSpmm(SparseOperationT.SPARSE_OPERATION_NON_TRANSPOSE, a, b, c); // res is IntelMKL.LP64.SparseStatusT.SPARSE_STATUS_NOT_SUPPORTED
    res = SpBlas.MklSparseDSetValue(a, 1, 2, 10); // Exception: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

}

What is wrong here?

AviAvni avatar Dec 24 '18 13:12 AviAvni

Hi sorry for taking so long to respond. I'm going to look at this issue today.

allisterb avatar Dec 28 '18 10:12 allisterb

@allisterb any updates?

AviAvni avatar Jan 06 '19 13:01 AviAvni