basicmath.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. for (c1 = 5; c1 < 15; c1 += 0.5)
  36. {
  37. for (d1 = -1; d1 > -11; d1--)
  38. {
  39. SolveCubic(a1, b1, c1, d1, &solutions, x);
  40. sum += x[0];
  41. // portDISABLE_INTERRUPTS();
  42. // printf("Solutions:");
  43. // portENABLE_INTERRUPTS();
  44. // for (i = 0; i < solutions; i++)
  45. // {
  46. // portDISABLE_INTERRUPTS();
  47. // printf(" %f", x[i]);
  48. // portENABLE_INTERRUPTS();
  49. // }
  50. // portDISABLE_INTERRUPTS();
  51. // printf("\r\n");
  52. // portENABLE_INTERRUPTS();
  53. // for(int j=0; j<1000000; j++) { __asm__(" nop"); }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. portDISABLE_INTERRUPTS();
  60. // printf("Sum: %f\r\n", sum);
  61. printf("(OUT) Sum: %d\r\n", (int)sum);
  62. portENABLE_INTERRUPTS();
  63. // #if( imcDEBUG_ITM_MESSAGES == 1 )
  64. // imcLOG_BENCHMARK_END();
  65. // #endif
  66. // exit(0);
  67. // }
  68. }