0
我可以从C#调用英特尔MKL cblas_dgem,请参阅下面的代码:C#调用英特尔MKL cblas_dgemm_batch
[DllImport("custom_mkl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = false)]
internal static extern void cblas_dgemm(
int Order, int TransA, int TransB, MKL_INT M, MKL_INT N, MKL_INT K,
double alpha, [In] double[,] A, MKL_INT lda, [In] double[,] B, MKL_INT ldb,
double beta, [In, Out] double[,] C, MKL_INT ldc);
和
void cblas_dgemm (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa, const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n, const MKL_INT k, const double alpha, const double *a, const MKL_INT lda, const double *b, const MKL_INT ldb, const double beta, double *c, const MKL_INT ldc);
但我不能够调用cblas_dgemm_batch从C#,看下面的代码:
[DllImport("custom_mkl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = false)] // not working
internal static extern void cblas_dgemm_batch(
int Layout, [In] int[] transa_array, [In] int[] transb_array, [In] MKL_INT[] m_array, [In] MKL_INT[] n_array, [In] MKL_INT[] k_array,
[In] double[] alpha_array, [In] double[][,] a_array, [In] MKL_INT[] lda_array, [In] double[][,] b_array, [In] MKL_INT[] ldb_array,
[In] double[] beta_array, [In, Out] double[][,] c_array, [In] MKL_INT[] ldc_array, MKL_INT group_count, [In] MKL_INT[] group_size);
和
void cblas_dgemm_batch (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE* transa_array, const CBLAS_TRANSPOSE* transb_array, const MKL_INT* m_array, const MKL_INT* n_array, const MKL_INT* k_array, const double* alpha_array, const double **a_array, const MKL_INT* lda_array, const double **b_array, const MKL_INT* ldb_array, const double* beta_array, double **c_array, const MKL_INT* ldc_array, const MKL_INT group_count, const MKL_INT* group_size);
我收到以下错误信息:
- System.Runtime.InteropServices.MarshalDirectiveException
- 不能元帅参数#8“:对于嵌套数组没有封送处理支持。
我可以理解,问题是嵌套的数组参数。该参数应该是指向数组的指针数组。但是,我怎样才能从C#调用cblas_dgemm_batch?
查看此链接:https://social.msdn.microsoft.com/Forums/vstudio/en-US/d13392f0-3b87-4908-b04e-f0bcf834409f/cannot-marshal-parameter-2-there-is-没有封送处理支持换嵌套阵列?论坛= csharpgeneral – Isma