Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

Mkl produce "segmentation fault" in ubuntu

$
0
0

Hi,

code:

#include "iostream"
        #include "stdio.h"
#include <vector>

#include "mkl_service.h"
#include "mkl_pardiso.h"
#include "mkl_types.h"
#include "mkl_dss.h"
#include "mkl_types.h"
#include "mkl_spblas.h"

using namespace std;
using std::vector;

//-----------------------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------------------
void solveSparse_MKL()
{
    _DOUBLE_PRECISION_t rhs[9] = { 0,0.333333,0.666667,0.111111,0.444444,0.777778,0.222222,0.555556,0.888889 };

    MKL_INT nnz = 23;
    MKL_INT nRows = 9;
    MKL_INT nCols = 9;
    MKL_INT nRhs = 1;
    MKL_INT rhs_len = 9;

    double acoo[] = { -0.0537308, -0.0512116, 1.10494, -4.17055, -1.73111, 6.95287, -7.78207, 0, 10.5132, -1.73111, -0.865586, 3.65043, -5.3765, -2.14414, 13.5568, -8.98329, 0, 19.9095, -1.30956, 4.04067, -2.5529, 10.239, 12.5362 };
    MKL_INT rowind[] = { 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,8,8,9 };
    MKL_INT colind[] = { 4, 2, 1, 5, 3, 2, 6, 4, 3, 7, 5, 4, 8, 6, 5, 9, 7, 6, 8, 7, 9, 8, 9 };

    MKL_INT info;
    MKL_INT job[8] = { 2, // COO to CSR
        1, // 1 based indexing in CSR rows
        1, // 1 based indexing in CSR cols
        0, //
        nnz, // number of the non-zero elements
        0, // job indicator
        0,
        0
    };

    MKL_INT* i_csr = new MKL_INT[nCols + 1]; // m+1
    MKL_INT* j_csr = new MKL_INT[nnz];
    double* a_csr = new double[nnz];

    mkl_dcsrcoo(job, &nCols, a_csr, j_csr, i_csr, &nnz, acoo, rowind, colind, &info);

    _DOUBLE_PRECISION_t* solValues = new _DOUBLE_PRECISION_t[rhs_len];

    // Allocate storage for the solver handle and the right-hand side.
    _MKL_DSS_HANDLE_t handle = 0;
    _INTEGER_t error;
    MKL_INT opt = MKL_DSS_DEFAULTS;
    MKL_INT sym = MKL_DSS_SYMMETRIC;
    MKL_INT type = MKL_DSS_POSITIVE_DEFINITE;
    // ---------------------
    // Initialize the solver
    // ---------------------
    error = dss_create(handle, opt);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);
    // -------------------------------------------
    // Define the non-zero structure of the matrix
    // -------------------------------------------
    error = dss_define_structure(handle, sym, i_csr, nRows, nCols, j_csr, nnz);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);
    // ------------------
    // Reorder the matrix
    // ------------------
    error = dss_reorder(handle, opt, 0);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);
    // ------------------
    // Factor the matrix
    // ------------------
    error = dss_factor_real(handle, type, a_csr);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);
    // ------------------------
    // Get the solution vector  
    // ------------------------
    error = dss_solve_real(handle, opt, rhs, nRhs, solValues);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);

    cout << "------------------------------"<< endl;
    cout << "solution "<< endl;
    cout << "------------------------------"<< endl;
    for (int j = 0; j < rhs_len; ++j)
    {
        cout << solValues[j] << endl;
    }
    // --------------------------
    // Deallocate solver storage  
    // --------------------------
    error = dss_delete(handle, opt);
    if (error != MKL_DSS_SUCCESS)
        printf("Solver returned error code %d\n", error);

    delete[] a_csr;
    delete[] i_csr;
    delete[] j_csr;
    delete[] solValues;
}

//-----------------------------------------------------------------------------------------------------
// https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
//-----------------------------------------------------------------------------------------------------
int main(void)
{

MKLVersion Version;

mkl_get_version(&Version);

    solveSparse_MKL();
    getchar();
    return 0;
}
// c:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\mkl\examples\examples_core_c.zip\

 

Results while run:

Major version: 2017
Minor version: 0
Update version: 2
Product status: Product
Build: 20170126
Platform: Intel(R) 64 architecture
Processor optimization: Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) enabled processors
================================================================

Segmentation fault

Os Details:

 

I have also posted this question before in

https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/...

 

 

Regards

CIBIN


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>