You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

benchmark.h 865 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "megcore_cuda.h"
  3. #include "test/common/benchmarker.h"
  4. #include "test/common/rng.h"
  5. #include "test/cuda/timer.h"
  6. namespace megdnn {
  7. namespace test {
  8. template <typename Opr>
  9. class Benchmarker<Opr, CUTimer> : public BenchmarkerBase<Opr, CUTimer> {
  10. public:
  11. Benchmarker(Handle* handle)
  12. : BenchmarkerBase<Opr, CUTimer>{handle, CUTimer{m_stream, m_evt0, m_evt1}} {
  13. cudaEventCreate(&m_evt0);
  14. cudaEventCreate(&m_evt1);
  15. megcoreGetCUDAStream(handle->megcore_computing_handle(), &m_stream);
  16. };
  17. ~Benchmarker() {
  18. cudaEventDestroy(m_evt0);
  19. cudaEventDestroy(m_evt1);
  20. }
  21. private:
  22. cudaStream_t m_stream;
  23. cudaEvent_t m_evt0, m_evt1;
  24. };
  25. template <typename Opr>
  26. using CUBenchmarker = Benchmarker<Opr, CUTimer>;
  27. } // namespace test
  28. } // namespace megdnn
  29. // vim: syntax=cpp.doxygen