2

我正在开发一个程序,我需要在 SE 模式下使用 gem5 模拟调用 OpenBLAS 函数的程序。我的代码(在 C 中)如下

#include <cblas.h>
#include <stdio.h>

void main()
{
  int i=0;
  double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
  double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
  double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
  cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);

  for(i=0; i<9; i++)
    printf("%lf ", C[i]);
  printf("\n");
  printf("hello hihi\n");
}

这是 OpenBLAS 的一个例子。我很确定我已经使用以下 makefile 命令静态编译了这个文件

test_cblas_dgemm: test_cblas_dgemm.c
        @echo compiling $@
        @gcc -static -I $(INCLUDE) -L.  $< -o test_cblas_dgemm -lopenblas
        @cp test_cblas_dgemm ~/progs/

问题是我可以在我的 ubuntu 机器上运行可执行文件,但它在 gem5 SE 模式下遇到致命错误。模拟输出如下

**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
warn: readlink() called on '/proc/self/exe' may yield unexpected results in various settings.
      Returning '/home/hurui/progs/test_cblas_dgemm'
info: Increasing stack size by one page.
warn: ignoring syscall access(...)
fatal: syscall mbind (#237) unimplemented.
Memory Usage: 648616 KBytes

任何人都可以帮助我吗?谢谢。

4

2 回答 2

0

我相信如果不修补 gem5 就无法克服这个错误,因为在 SE 模式下,每个系统调用都必须显式实现,从源代码中可以猜到:

src/arch/arm/linux/process.cc:443:    /* 319 */ SyscallDesc("mbind", unimplementedFunc),                 

作为替代方案,您不能在完整的系统模拟中运行它吗?例如,我使用此 Buildroot 设置运行与您完全相同的测试程序,非常轻松地使其工作。

FS 往往更容易移植东西,因为系统更现实,对你能做什么的限制更少。

另一种选择是修补 BLAS 以删除系统调用,但您可能不想这样做,因为它会使您的运行不那么具有代表性,并且可能只会发现进一步的故障。

请同时写信给邮件列表以确认我告诉您的内容。

于 2018-03-14T13:14:02.970 回答
0

要解决此问题,请从 OpenBLAS 中删除 mbind 系统调用。这是唯一未实现的系统调用。在 OpenBLAS 目录的根目录中打开文件 common_linux.h 并替换:

return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags);

return 0;

并再次编译。这适用于我的 OpenBLAS 版本 0.3.18。

于 2021-11-08T07:18:20.113 回答