MKL CBlas 错误
我尝试使用英特尔 MKL 提供的 cblas 将两个矩阵(例如 A 和 B)的乘积转换为 C。 有什么原因会导致错误吗?
double * A, *B, *C;
A = (double *) calloc(20 * 200, sizeof (double));
B = (double *) calloc(200 * 200, sizeof (double));
C = (double *) calloc(20 * 200, sizeof (double));
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
20, 200, 200,
1.0, A, 20,
B, 200,
0.0, C, 20);
I try to get product of two matrix say A and B into C using cblas provided by intel MKL.
Is there any reason for this to be result in error?
double * A, *B, *C;
A = (double *) calloc(20 * 200, sizeof (double));
B = (double *) calloc(200 * 200, sizeof (double));
C = (double *) calloc(20 * 200, sizeof (double));
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
20, 200, 200,
1.0, A, 20,
B, 200,
0.0, C, 20);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仔细检查 cblas_dgemm 的所有参数。如果出现错误,该函数可能会读取超出数组范围的内容。对于不会触发故障的小尺寸,因为错误地址仍然会落在单个内存页内。 (但是数学会出错,你应该检查一下。)但是 200x200 矩阵是 2.5 MB 的数据,传递错误的大小肯定会触发段错误。
Double check all the parameters to cblas_dgemm. If you have a mistake, the function could be reading beyond the bounds of the array. For small sizes that won't trigger a fault, since the bad addresses will still fall inside a single memory page. (But the math will be wrong, you should check it.) But a 200x200 matrix is 2.5 megabytes of data, passing the wrong size will definitely trigger a segfault.