test_openblas.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import os
  2. import infra.basetest
  3. class TestOpenBLAS(infra.basetest.BRTest):
  4. config = \
  5. """
  6. BR2_aarch64=y
  7. BR2_TOOLCHAIN_EXTERNAL=y
  8. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  9. BR2_LINUX_KERNEL=y
  10. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  11. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.27"
  12. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  13. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  14. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  15. BR2_TARGET_ROOTFS_CPIO=y
  16. BR2_TARGET_ROOTFS_CPIO_GZIP=y
  17. # BR2_TARGET_ROOTFS_TAR is not set
  18. BR2_PACKAGE_OPENBLAS=y
  19. BR2_PACKAGE_OPENBLAS_INSTALL_TESTS=y
  20. """
  21. def test_run(self):
  22. img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
  23. kern = os.path.join(self.builddir, "images", "Image")
  24. self.emulator.boot(arch="aarch64",
  25. kernel=kern,
  26. kernel_cmdline=["console=ttyAMA0"],
  27. options=["-M", "virt", "-cpu", "cortex-a57", "-smp", "2", "-m", "512M", "-initrd", img])
  28. self.emulator.login()
  29. test_prefix = "/usr/libexec/openblas/tests"
  30. # BLAS data types:
  31. blas_data_types = [
  32. "s", # Single precision (32bit) float
  33. "d", # Double precision (64bit) double
  34. "c", # Single precision (32bit) complex
  35. "z" # Double precision (64bit) complex
  36. ]
  37. # BLAS routine levels:
  38. # Level 1: Vector operations,
  39. # Level 2: Matrix-Vector operations,
  40. # Level 3: Matrix-Matrix operations.
  41. for blas_level in range(1, 4):
  42. for blas_data_type in blas_data_types:
  43. test_name = f"x{blas_data_type}cblat{blas_level}"
  44. cmd = test_prefix + "/" + test_name
  45. if blas_level > 1:
  46. cmd += f" < {test_prefix}/{blas_data_type}in{blas_level}"
  47. self.assertRunOk(cmd, timeout=30)