basicmath.c 1.8 KB

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