Recent posts
https://software.intel.com/en-us/recent/275484
enmkldcsrbsr gives core dump when trying to fill all arrays
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/536624
<p>Hi</p>
<p> </p>
<p>I am using the mkldcsrbsr routine. I ma using MKL version 10.3 (i have tried with version 11.0 as well). It seems i can call the routine perfectly for the job type = -1. I get the number of blocks correctly but when i call the routine again to fill all the arrays i get a coredump.</p>
<p> </p>
<p>Here is the code i am using</p>
<p>rowsAbsr = new int[N_A+1];<br />
job[0]=0;//CSR to BSR<br />
job[1]=0;// zero based CSR<br />
job[2]=0;//zero based bsr<br />
job[3]=0;<br />
job[4]=0;<br />
job[5]=-1;//<br />
mkl_dcsrbsr(job, &N_A, &m, &ldabsr, nnzsAcsr, colsAcsr, rowsAcsr, nnzsAbsr, colsAbsr, rowsAbsr, &info);<br />
cout<<"The conversion to BSR for matrix A is "<<info<<"."<<endl;<br />
cout<<"The request for number of blocks of BSR for matrix A is "<<rowsAbsr[0]<<"."<<endl;<br />
sizecolsabsr=rowsAbsr[0];<br />
colsAbsr = new int[rowsAbsr[0]];<br />
nnzsAbsr = new double[m*m*(rowsAbsr[0])];<br />
ldabsr=m*m*(rowsAbsr[0]);<br />
cout<<"ldabsr is calculated as "<<ldabsr<<"."<<endl;<br />
job[0]=0;//CSR to BSR<br />
job[1]=0;// zero based CSR<br />
job[2]=0;//zero based bsr<br />
job[5]=0;// only row and column arrays for bsr are filled<br />
mkl_dcsrbsr(job, &N_A, &m, &ldabsr, nnzsAcsr, colsAcsr, rowsAcsr, nnzsAbsr, colsAbsr, rowsAbsr, &info);<br />
cout<<"The conversion to BSR for matrix A is "<<info<<"."<<endl;<br />
job[0]=0;//CSR to BSR<br />
job[1]=0;// zero based CSR<br />
job[2]=0;//zero based bsr<br />
job[5]=1;// all arays are filled<br />
mkl_dcsrbsr(job, &N_A, &m, &ldabsr, nnzsAcsr, colsAcsr, rowsAcsr, nnzsAbsr, colsAbsr, rowsAbsr, &info);<br />
cout<<"The conversion to BSR for matrix A is "<<info<<"."<<endl;</p>
<p>I had my doubts on ldabsr but as per the documentation available online it seems i am doing the right thing. Could you be so kind to suggest if you spot any obvious error here?</p>
<p> </p>
<p>with kind regards</p>
<p>rohit</p>
<p> </p>
Mon, 01 Dec 14 05:47:13 -0800itabhiyanta536624Dense * Sparse matrix calculations, is there an easier way
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/534557
<p>I am porting code (C, so row major) which makes use of ?gemm, ?syrk and ?syr2k calls from dense matrices to sparse matrices, and would to know if there is a simpler way of calculating the various internal matrix products than the following:</p>
<p> </p>
<p><strong>?syrk</strong>: use <strong>?csrmultd</strong>. I assume since this method only allows 1 based indexing the resulting dense matrix is column major, but I would like confirmation.</p>
<p> </p>
<p><strong>?syr2k</strong>: use two <strong>?gemm</strong> calls here instead.</p>
<p> </p>
<p><strong>?gemm</strong>: This case gets fairly complicated, and it would be extremely nice if someone can tell me if there are methods / options I am overlooking which would simplify this. A and D are the dense result and multiplicand matrices, S['] is a sparse matrix which may be transposed.</p>
<p>A = S['] * D + A<br />
- Use mkl_dcsrmm directly (using zero based indexing)</p>
<p>A = S['] * D' + A<br />
Either<br />
- Transpose D -> Dt<br />
=> A = S['] * Dt + A<br />
- use mkl_dcsrmm (using zero based indexing)<br />
Or<br />
- Convert S to one based indexing, forces mkl_dcsrmm to implicitly use col major C arrays (D' -> Dt)<br />
- Calculate temp. matrix Tt = S['] * Dt via mkl_dcsrmm<br />
- T' (row major) = Tt (col. major)<br />
- calculate A = T' + A;</p>
<p>
A = D * S['] + A<br />
- Transpose equation:<br />
-> A' = (D * S['])' + A' = S[!'] * D' + A'<br />
Either:<br />
- Convert S to one based indexing, forces mkl_dcsrmm to implicitly use col major C arrays (A' -> At, D' -> Dt)<br />
=> At = S[!'] * Dt + At<br />
-> Use mkl_dcsrmm<br />
Or:<br />
- Transpose A' => At, D' => Dt<br />
=> At = S[!'] * Dt + At<br />
- Use mkl_dcsrmm (using zero based indexing)<br />
- Transpose At</p>
<p>
A = D' * S['] + A<br />
-> Transpose equation:<br />
-> A' = (D' * S['])' + A' = S[!'] * D + A'<br />
Either:<br />
- Transpose A' => At<br />
=> At = S[!'] * D + At<br />
-> Use mkl_dcsrmm (using zero based indexing)<br />
-> Transpose At => A'<br />
Or:<br />
-> Calculate temp. matrix T = S['] * D via mkl_dcsrmm<br />
-> Calculate A = T' + A</p>
<p>
In theory I could always store my sparse matrix as one based, and if I need to treat it as zero based add dummy rows / columns to the dense matrices to catch the additional row/column created when multiplying, which means converting between the indexing won't take any time.</p>
<p> </p>
<p>One final question: Could someone confirm that it is possible to use <strong>mkl_?omatadd</strong> to calculate A = A + B without using a temp matrix? The documentation doesn't state whether the memory is allowed to overlap between input and output if no transposition is being done.</p>
Tue, 28 Oct 14 11:04:00 -0700Henrik A.534557Help with Sparse matrix vector multiplication using MKL DIA routine
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/533454
<p>I am using the MKL library to perform the sparse matrix vector multiplication using diagonal format, When I use the MKL mkl_sdiagemv function I get a "MKL ERROR: Parameter 4 was incorrect on entry to MKL_SDIAGEMV. " error.</p>
<p> </p>
<pre class="brush:cpp;">void mm_read(char* filename, int *m, int *n, int *nnz, int **rowptrs, int **colinds, float **vals, float **adia, int **distance, int idiag, int ndiag) {
// open file
FILE* mmfile = fopen(filename, "r");
assert(mmfile != NULL && "Read matrix file.");
// read MatrixMarket header
int status;
MM_typecode matcode;
status = mm_read_banner(mmfile, &matcode);
assert(status == 0 && "Parsed banner.");
status = mm_read_mtx_crd_size(mmfile, m, n, nnz);
assert(status == 0 && "Parsed matrix m, n, and nnz.");
printf("- matrix is %d-by-%d with %d nnz.\n", *m, *n, *nnz);
int *coo_rows = (int*) malloc(*nnz * sizeof(int));
int *coo_cols = (int*) malloc(*nnz * sizeof(int));
float *coo_vals = (float*) malloc(*nnz * sizeof(float));
// read COO values
int i = 0;
for ( i = 0; i < *nnz; i++)
status = fscanf(mmfile, "%d %d %g\n",
&coo_rows[i], &coo_cols[i], &coo_vals[i]);
*rowptrs = (int*) malloc((*m+1)*sizeof(int));
*colinds = (int*) malloc(*nnz*sizeof(int));
*vals = (float*) malloc(*nnz*sizeof(int));
// convert to CSR matrix
int info;
int job[] = {
2, // job(1)=2 (coo->csr with sorting)
1, // job(2)=1 (one-based indexing for csr matrix)
1, // job(3)=1 (one-based indexing for coo matrix)
0, // empty
*nnz, // job(5)=nnz (sets nnz for csr matrix)
0 // job(6)=0 (all output arrays filled)
};
mkl_scsrcoo( job, m, *vals, *colinds, *rowptrs, nnz, coo_vals, coo_rows, coo_cols, &info);
assert(info == 0 && "Converted COO->CSR");
// DIA matrix dimensions and values
ndiag = 4;
idiag = 3;
*adia = (float*) malloc(*nnz * idiag * sizeof(int));
*distance = (int* ) malloc(idiag * sizeof(int));
int job1[] = {
0, // job(0)=2
1, // job(1)=1
1, // job(2)=1
2, // empty3
*nnz, // empty4
10, // job(5)=nnz
};
mkl_scsrdia (job1, m, *vals, *colinds, *rowptrs, *adia, &ndiag, *distance, &idiag, *vals, *colinds, *rowptrs, &info);
assert(info == 0 && "Converted CSR->DIA");
// free COO matrix
free(coo_rows);
free(coo_cols);
free(coo_vals); }
float * randvec(int n) {
float *v = (float*) malloc(n * sizeof(float));
int i = 0;
for (i = 0; i < n; i++)
v[i] = rand() / (float) RAND_MAX;
return v;
}
int main(int argc, char* argv[]) {
// require filename for matrix to test
if (argc != 2) {
fprintf(stderr, "Usage: %s MATRIX.mm\n", argv[0]);
exit(1);
}
int m, n, nnz;
int *rowptrs, *colinds;
float *vals;
float *adia;
int *distance;
int idiag, ndiag;
// read matrix from file
mm_read(argv[1], &m, &n, &nnz, &rowptrs, &colinds, &vals, &adia, &distance, &idiag, &ndiag);
// allocate vectors for computation
float *v = randvec(n);
float *cpu_answer = (float*) malloc(m*sizeof(float));
struct timeval start, end;
printf (" Running Intel(R) MKL from 1 to %i threads \n\n", mkl_get_max_threads());
mkl_sdiagemv ((char*)"N", &m, adia, &idiag, distance, &ndiag, v, cpu_answer);
// release memory
free(rowptrs);
free(colinds);
free(vals);
free(cpu_answer);
free(v);
free(adia);
free(distance);
return 0; }</pre><p> </p>
Mon, 13 Oct 14 09:34:30 -0700Hazem A.533454Temporary arrays in Sparse Matrix Vector Multiply Format Prototype Package
https://software.intel.com/en-us/forums/intel-many-integrated-core/topic/515902
<p>Considering "The Intel® Math Kernel Library Sparse Matrix Vector Multiply Format Prototype Package", I have two questions:</p>
<p>1) The use of a temporary array for each thread may not pay off when the number of threads increases, especially when Xeon Phi is considered. Is this problem efficiently solved in the package? In which call are memory allocated for the temporary arrays?<strong> </strong>In sparseCreateESBMatrix(), sparseDcsr2esb() or sparseDesbmv() function?</p>
<p>2) How is the reduction of temporary arrays performed on Xeon Phi? Is there any architecture-specific way? As far as I know, it is not mentioned in the paper describing the package.</p>
Thu, 29 May 14 06:21:38 -0700kadir515902SSOR preconditioner using RCI
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/494663
<p>Hey Guys,</p>
<p>I have a problem with impelementing SSOR precondtioner using RCI and hope you can help me with that.</p>
<p>I have written a cg solver using RCI for a symmetric matrix that is stored in CSR format 3 array version. I have also implemented the jacobi preconditioner and it works fine. Now I want to implement SSOR but unfortunately I am lost somehow. There is an example of SSOR in MKL example directory, but in that example the SSOR is implemented in a loop which I don't know why!</p>
<p>Here is the SSOR that I am aware of.</p>
<p>Let's say M is the preconditioner which works as follows:</p>
<p>M rho = r (eq.1)</p>
<p>where r is the current residual ( stored in &tmp[2n] in RCI) and rho is the modified residual (shall be stored in &tmp[3n] in RCI)</p>
<p>M is defined as follow [SAAD 2002]</p>
<p>M = 1/(w(2-w)) (D+wL) D^-1 (D+wU)</p>
<p>where</p>
<p>w = relaxation parameter 0<w<2</p>
<p>U = is the upper part of the matrix A</p>
<p>L = the lower part of the matrix A</p>
<p>D = diagonal of the matrix A</p>
<p>so A = L+D+U and since A is symmetric L= U'</p>
<p>To solve the eq. 1 the following is suggested </p>
<p>Q = 1/(w(2-w)) (D+wL) D^-1</p>
<p>G = (D+wU)</p>
<p>1. Solve Q z = r</p>
<p>2. Solve G rho = z</p>
<p>To perform the above steps we need to triangular solvers. Now my question, what function from mkl should I use to this end? Is it necessary to build Q and G explicitly or the mkl functions can do so?</p>
<p>I would be happy if somebody can give me some hints here.</p>
<p>With best regards.</p>
<p>Meysam</p>
Tue, 26 Nov 13 06:36:23 -0800Meysam J.494663Sparse matrix-multiple vectors products
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/365430
<p>Hello,</p>
<p>I would like to compute Y^T = AX^T where A is sparse, and Y and X are dense matrices (which results from the concatenation of multiple vectors in row-major order). I've seen that you released an interface to Feast on the last update. When ijob = 30, this is what one needs to compute when using row-major order, and I was wondering if the implentation of such a procedure is available in the MKL.</p>
<p>Thank you.</p>
Mon, 04 Feb 13 05:13:48 -0800qweasd q.365430segv mkl_dcscmv from multithreaded applications
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/344909
<p>dear support,</p>
</p>
<p>i having a segv from calling mkl_dcscmv from my multithreaded applications. the same code works well if i can it from single thread. here is the message i got from gdb, any other info i can provide to help you find out the problem,</p>
</p>
<p>Program received signal SIGSEGV, Segmentation fault.<br />[Switching to Thread 0x2aac4dad3940 (LWP 13096)]<br />0x0000000000551236 in mkl_spblas_lp64_mc3_dcsr0tg__c__mvout_par ()<br />(gdb) where<br />#0 0x0000000000551236 in mkl_spblas_lp64_mc3_dcsr0tg__c__mvout_par ()<br />#1 0x00000000004fd30b in mkl_spblas_lp64_dcsr0tg__c__mvout_omp ()<br />#2 0x00000000004fbcce in mkl_spblas_lp64_mkl_dcscmv ()</p>
</p>
Wed, 05 Dec 12 20:40:19 -0800benjamin.gu@gmail.com344909Problem with mkl_dcsrmultcsr
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/336409
<p>Hello,</p>
<p>I don't get why in the attached code, if line 36 I set transa to 't', then I get a segmentation fault. The matrix A is symmetric, so there shouldn't be any other changes to do to make this work ? In its Fortran version, dcsr_multiplication.f, there is no problem when I switch trans line 82.</p>
<p>Thanks in advance for any help.</p>
Sat, 10 Nov 12 07:02:17 -0800qweasd q.336409Problem with sparse BLAS Level 2 function mkl_scsrgemv()
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/281605
<p>Hi!When programming with mkl sparse BLAS level 2 fucntion to implement a matrix-vector mulitplication, I met a trouble in function mlk_?csrgemv(). A simplified and clear code is given below, in which the same problem happened.!-----------------------------------------------program mainimplicit nonereal, dimension(12) :: val = (/-1, 1,-1, & 1,-1, 1, & 1,-1, 1, & -1, 1,-1 /) integer, dimension(12) :: column = (/1,2,3, 4,5,6, 7,8,9, 1,4,7/) integer, dimension(5) :: rowIndex= (/1,4,7, 10,13/) real, dimension(9) :: v = 1.0 real, dimension(9) :: res = 0 character :: transa = 'n' integer :: row_num = 9 call mkl_scsrgemv(transa, row_num, val, rowIndex, column, v, res) write(*,*) "result = " write(*,*) res stopend program!------------------------------------------Error info is: Unhandled exception at 0x0117d008 in SparseBLAS.exe: 0xC0000005: Access violation reading location 0xff25e07c.It shoud be pointed out that the matrix is not a square matrix of the dimension m*m.But another non square sparse matrix,val = (/-1,1,1,-1,1,-1,-1,1/)column = (/1,2,3,4,5,6,2,4/)rowIndex = (/1,3,5,7,9/)worked successfully.My question is, what is wrong with the code? Can the nonsquare matrix vector multiplication be implemented with CSR(3 array variation) data structure? And How?(Platform: Intel Pentium T4200, VS2008, MKL 10.3)Expecting for your help and Thanks a lot.</p>
Thu, 13 Oct 11 19:37:17 -0700David830Wu281605dense-sparse matrice multiplication
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/284332
<p>Hi all,I want to multiply a dens matrix A into a sparse matrix B, that is saved in the CSC format, as c=AxB. I cannot use<b>mkl_scscmm()</b> becsue it computes BxA. (i.e. the sparse matrix must be the left one)Could you let me know which sparse routine I can use for this purpose?Thanks</p>
Mon, 11 Apr 11 17:40:44 -0700Vahid Jalili284332