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.

fixture.h 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include <gtest/gtest.h>
  3. #include "megdnn/handle.h"
  4. #include "test/common/utils.h"
  5. #include <memory>
  6. namespace megdnn {
  7. namespace test {
  8. class CPU : public ::testing::Test {
  9. public:
  10. void SetUp() override;
  11. void TearDown() override;
  12. Handle* handle() { return m_handle.get(); }
  13. protected:
  14. std::unique_ptr<Handle> m_handle;
  15. };
  16. class CPU_MULTI_THREADS : public ::testing::Test {
  17. public:
  18. void SetUp() override;
  19. void TearDown() override;
  20. Handle* handle() { return m_handle.get(); }
  21. protected:
  22. std::unique_ptr<Handle> m_handle;
  23. };
  24. class CPU_BENCHMARK_MULTI_THREADS : public ::testing::Test {
  25. Handle* handle() {
  26. if (!m_handle) {
  27. m_handle = create_cpu_handle(0, true, &m_thread_config);
  28. }
  29. return m_handle.get();
  30. }
  31. void set_thread_config(TaskExecutorConfig&& thread_config) {
  32. set_thread_config(thread_config);
  33. }
  34. void set_thread_config(TaskExecutorConfig& thread_config) {
  35. m_thread_config = thread_config;
  36. m_handle.reset(create_cpu_handle(0, true, &m_thread_config).get());
  37. }
  38. TaskExecutorConfig get_thread_config() { return m_thread_config; }
  39. protected:
  40. TaskExecutorConfig m_thread_config;
  41. std::unique_ptr<Handle> m_handle;
  42. };
  43. } // namespace test
  44. } // namespace megdnn
  45. // vim: syntax=cpp.doxygen