fp-pidbench.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // Copyright (C) 2021 ARM Limited.
  3. // Original author: Mark Brown <broonie@kernel.org>
  4. //
  5. // Trivial syscall overhead benchmark.
  6. //
  7. // This is implemented in asm to ensure that we don't have any issues with
  8. // system libraries using instructions that disrupt the test.
  9. #include <asm/unistd.h>
  10. #include "assembler.h"
  11. .arch_extension sve
  12. .macro test_loop per_loop
  13. mov x10, x20
  14. mov x8, #__NR_getpid
  15. mrs x11, CNTVCT_EL0
  16. 1:
  17. \per_loop
  18. svc #0
  19. sub x10, x10, #1
  20. cbnz x10, 1b
  21. mrs x12, CNTVCT_EL0
  22. sub x0, x12, x11
  23. bl putdec
  24. puts "\n"
  25. .endm
  26. // Main program entry point
  27. .globl _start
  28. function _start
  29. puts "Iterations per test: "
  30. mov x20, #10000
  31. lsl x20, x20, #8
  32. mov x0, x20
  33. bl putdec
  34. puts "\n"
  35. // Test having never used SVE
  36. puts "No SVE: "
  37. test_loop
  38. // Check for SVE support - should use hwcap but that's hard in asm
  39. mrs x0, ID_AA64PFR0_EL1
  40. ubfx x0, x0, #32, #4
  41. cbnz x0, 1f
  42. puts "System does not support SVE\n"
  43. b out
  44. 1:
  45. // Execute a SVE instruction
  46. puts "SVE VL: "
  47. rdvl x0, #8
  48. bl putdec
  49. puts "\n"
  50. puts "SVE used once: "
  51. test_loop
  52. // Use SVE per syscall
  53. puts "SVE used per syscall: "
  54. test_loop "rdvl x0, #8"
  55. // And we're done
  56. out:
  57. mov x0, #0
  58. mov x8, #__NR_exit
  59. svc #0