【发布时间】:2018-02-21 21:03:09
【问题描述】:
我可以从 C# 调用 Intel MKL cblas_dgem,参见以下代码:
[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);
但我无法从 C# 调用 cblas_dgemm_batch,请参见以下代码:
[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?
【问题讨论】:
标签: c# matrix-multiplication intel-mkl