- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Trying to access clapack_dgelss from C# and failing. I am using 10.3 Beta version.
When I call this function nothing happens. All output parameters remain at the same values they had before the call. Absolutely nothing. Perhaps I am not calling correctly into the MKL library? I don't know
Attached is a Visual Studio (2005) solution with a very simple example. Note: the sample also calls cblas_dgemm and it works ok. Please copy the redistributables of 10.3 Beta to Bin\\Debug prior to running.
Please advise,
Thanks,
Roy.
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi Roy,
There are 4 errors in your code.
1.Skipped first argument: int matrix_order
2. Extra INFO argument: c-lapack interface justreturnsINFO as function value
3.If you use WORK array, use _work version of interface: clapack_dgelss_work
4. Use LWORK = -1 to calculate the optimal size of the array work
Below are minimal changes for successful work.
Thanks,
Vladimir
$ diff Program.cs-orig Program.cs
226c226
< int LWORK = 1;
---
> int LWORK = -1;
233c233
< CMKL.dgelss(m_numRows, // M - The number of rows in the A matrix
---
> info = CMKL.dgelss(m_numRows, // M - The number of rows in the A matrix
244,245c244,245
< LWORK, // LWORK - The dimension of the array WORK
< info); // = 0: successful exit
---
> LWORK // LWORK - The dimension of the array WORK
> ); // = 0: successful exit
297c297
< public static void dgelss(int M, int N, int NRHS,
---
> public static int dgelss(int M, int N, int NRHS,
302c302
< int LWORK, [Out] int INFO)
---
> int LWORK)
304c304
< CMKLNative.clapack_dgelss(M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK, WORK, LWORK, INFO);
---
> return CMKLNative.clapack_dgelss_work(1,M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK, WORK, LWORK);
340c340
< internal static extern void clapack_dgelss(
---
> internal static extern int clapack_dgelss_work( int matrix_order,
352,353c352,353
< int LWORK, // The dimension of the array WORK
< [Out] int INFO); // = 0: successful exit
---
> int LWORK // The dimension of the array WORK
> ); // = 0: successful exit
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy,
The beta version has inconsistent C-LAPACK and CBLAS constants. You can find in the MKL/include/mkl_clapack.h header file following values:
#define CLAPACK_ROW_MAJOR 0
#define CLAPACK_COL_MAJOR 1
#define CLAPACK_WORK_MEMORY_ERROR -1010
#define CLAPACK_TRANSPOSE_MEMORY_ERROR -1011
#define CLAPACK_ORDER_ERROR -1012
So -1012 means wrong matrix_order value. Use please 0 instead of CMKL.ORDER.RowMajor.
Also use ref int iRANK for C-declared pointers to scalars: clapack_int* rank => ref int rank.
Below are minimal changes for successful work.
Thanks,
Vladimir
$ diff Program.cs Program.cs-orig
238c238
< 0, // The matrix order - whether the two-dimensional arrays are row-major (CLAPACK_ROW_MAJOR) or column-major (CLAPACK_COL_MAJOR).
---
> CMKL.ORDER.RowMajor, // The matrix order - whether the two-dimensional arrays are row-major (CLAPACK_ROW_MAJOR) or column-major (CLAPACK_COL_MAJOR).
302c302
< return CMKLNative.clapack_dgelss(matrix_order, M, N, NRHS, A, lda, B, ldb, S, RCOND, ref iRANK);
---
> return CMKLNative.clapack_dgelss(matrix_order, M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK);
356c356
< ref int iRANK); // The effective rank of A, i.e., the number of singular values which are greater than RCOND*S(1)
---
> [Out] int iRANK); // The effective rank of A, i.e., the number of singular values which are greater than RCOND*S(1)
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy, your actual data are
A X B
------ --- ---
1 2 3 1 17
4 5 6 * 2 = 38
7 8 10 4 63
As you use row-major order you should set ldb=1. just replace:
B.Length, // ldb - The leading dimension of the array B
with 1. After that I have:
0.99999999999998823
2.0000000000000044
4.0000000000000044
Also lda should be m_numColumns.
-Vladimir
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- m -INTEGER. The number of rows of the matrixA(m0).
- n -INTEGER. The number of columns of the matrixA(n0).
- lda -INTEGER. The first dimension ofa; at least max(1,m).
- ldb -INTEGER. The first dimension ofb; must be at least max(1,m,n).
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy, thank you for the comments.
Please look at the announcement http://software.intel.com/en-us/articles/c-interface-for-lapack/
You can find there more details in the C interface to LAPACK technical paper, in particular:
LAPACK routines use a stride corresponding to the FORTRAN leading dimension (LDA) with all 2D arrays. We must do the same. For RowMajor matrices, elements within a row are assumed to be contiguous and elements from one row to the next are assumed to be a stride/leading dimension apart.
-Vladimir
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Amazingly, we need to reopen this issue.
We are extremely frustrated!!!
We have upgraded from 10.3 beta to the official 10.3 release version.
Immediately thereafter, our application stopped working. Going back to the sample we sent you (Test_DGELSS.zip) we see an error "Unable to find an entry point named 'clapack_dgelss' in DLL 'mkl_rt'." when we try to call clapack_dgelss.
We also noticed on the 10.3 release notes that the C interface had changed (http://software.intel.com/en-us/articles/c-interface-for-lapack/). Is that related?
Please Help ASAP.
Thanks,
Roy.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Yes, interface names have been changed.
Please use 10.3 LAPACKE_dgelss instead of 10.3 beta clapack_dgelss.
Thanks,
Vladimir
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Roy,
Sorry, forgot to say that matrix_order constants have been changed also to the more natural values.
Please replace CMKL.CLAPACK_ORDER.RowMajor with CMKL.ORDER.RowMajor.
Thanks,
Vladimir
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable