basicmath.c 1.7 KB

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