MicroBenchmarksF16.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #include "MicroBenchmarksF16.h"
  2. #include "Error.h"
  3. static void add_while_f16(
  4. const float16_t * pSrcA,
  5. const float16_t * pSrcB,
  6. float16_t * pDst,
  7. uint32_t blockSize)
  8. {
  9. uint32_t blkCnt;
  10. blkCnt = blockSize;
  11. while (blkCnt > 0U)
  12. {
  13. /* C = A + B */
  14. /* Add and store result in destination buffer. */
  15. *pDst++ = (*pSrcA++) + (*pSrcB++);
  16. /* Decrement loop counter */
  17. blkCnt--;
  18. }
  19. }
  20. static void add_for_f16(
  21. const float16_t * pSrcA,
  22. const float16_t * pSrcB,
  23. float16_t * pDst,
  24. uint32_t blockSize)
  25. {
  26. uint32_t blkCnt;
  27. int32_t i;
  28. blkCnt = blockSize;
  29. for(i=0; i<blkCnt; i++)
  30. {
  31. /* C = A + B */
  32. /* Add and store result in destination buffer. */
  33. *pDst++ = (*pSrcA++) + (*pSrcB++);
  34. }
  35. }
  36. static void add_array_f16(
  37. const float16_t * pSrcA,
  38. const float16_t * pSrcB,
  39. float16_t * pDst,
  40. uint32_t blockSize)
  41. {
  42. uint32_t blkCnt;
  43. int32_t i;
  44. blkCnt = blockSize;
  45. for(i=0; i<blkCnt; i++)
  46. {
  47. /* C = A + B */
  48. /* Add and store result in destination buffer. */
  49. pDst[i] = pSrcA[i] + pSrcB[i];
  50. }
  51. }
  52. void MicroBenchmarksF16::test_while_f16()
  53. {
  54. add_while_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
  55. }
  56. void MicroBenchmarksF16::test_for_f16()
  57. {
  58. add_for_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
  59. }
  60. void MicroBenchmarksF16::test_array_f16()
  61. {
  62. add_array_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
  63. }
  64. void MicroBenchmarksF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  65. {
  66. std::vector<Testing::param_t>::iterator it = params.begin();
  67. this->nbSamples = *it;
  68. input1.reload(MicroBenchmarksF16::INPUT1_F16_ID,mgr,this->nbSamples);
  69. input2.reload(MicroBenchmarksF16::INPUT2_F16_ID,mgr,this->nbSamples);
  70. output.create(this->nbSamples,MicroBenchmarksF16::OUT_SAMPLES_F16_ID,mgr);
  71. this->inp1=input1.ptr();
  72. this->inp2=input2.ptr();
  73. this->outp=output.ptr();
  74. }
  75. void MicroBenchmarksF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  76. {
  77. }