basicmath.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "benchmarks/basicmath/snipmath.h"
  2. #include "cmsis_os.h"
  3. #include "ImC/imc_kernel.h"
  4. #include "ImC/imc_extension.h"
  5. // #include "imc.h"
  6. #include <stdio.h>
  7. void vBasicMath()
  8. {
  9. double a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0;
  10. double a2 = 1.0, b2 = -4.5, c2 = 17.0, d2 = -30.0;
  11. double a3 = 1.0, b3 = -3.5, c3 = 22.0, d3 = -31.0;
  12. double a4 = 1.0, b4 = -13.7, c4 = 1.0, d4 = -35.0;
  13. double x[3];
  14. double X;
  15. int solutions;
  16. int i;
  17. unsigned long l = 0x3fed0169L;
  18. struct int_sqrt q;
  19. double sum = 0;
  20. // portDISABLE_INTERRUPTS();
  21. // printf("Sum: %f\r\n", sum);
  22. // portENABLE_INTERRUPTS();
  23. // while (1)
  24. // {
  25. // int IMC_REPEAT = 2;
  26. int IMC_REPEAT = imcBENCH_REPEAT_COUNT;
  27. for(int imc_repeat=0; imc_repeat<IMC_REPEAT; imc_repeat++) {
  28. sum = 0;
  29. /* Now solve some random equations */
  30. for (a1 = 1; a1 < 3; a1++)
  31. {
  32. // imcREQUEST_CHECKPOINT();
  33. for (b1 = 10; b1 > 0; b1--)
  34. {
  35. IMC_UNROLL(2)
  36. for (c1 = 5; c1 < 15; c1 += 0.5)
  37. {
  38. IMC_UNROLL(10)
  39. for (d1 = -1; d1 > -11; d1--)
  40. {
  41. SolveCubic(a1, b1, c1, d1, &solutions, x);
  42. sum += x[0];
  43. // portDISABLE_INTERRUPTS();
  44. // printf("Solutions:");
  45. // portENABLE_INTERRUPTS();
  46. // for (i = 0; i < solutions; i++)
  47. // {
  48. // portDISABLE_INTERRUPTS();
  49. // printf(" %f", x[i]);
  50. // portENABLE_INTERRUPTS();
  51. // }
  52. // portDISABLE_INTERRUPTS();
  53. // printf("\r\n");
  54. // portENABLE_INTERRUPTS();
  55. // for(int j=0; j<1000000; j++) { __asm__(" nop"); }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. portDISABLE_INTERRUPTS();
  62. // printf("Sum: %f\r\n", sum);
  63. printf("(OUT) Sum: %d\r\n", (int)sum);
  64. portENABLE_INTERRUPTS();
  65. // #if( imcDEBUG_ITM_MESSAGES == 1 )
  66. // imcLOG_BENCHMARK_END();
  67. // #endif
  68. // exit(0);
  69. // }
  70. }