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.cpp 862 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "test/cpu/fixture.h"
  2. #include "test/common/memory_manager.h"
  3. #include "test/common/random_state.h"
  4. #include "test/common/utils.h"
  5. namespace megdnn {
  6. namespace test {
  7. void CPU::SetUp() {
  8. RandomState::reset();
  9. m_handle = create_cpu_handle(0);
  10. }
  11. void CPU::TearDown() {
  12. m_handle.reset();
  13. MemoryManagerHolder::instance()->clear();
  14. }
  15. void CPU_MULTI_THREADS::SetUp() {
  16. RandomState::reset();
  17. #if MEGDNN_ENABLE_MULTI_THREADS
  18. TaskExecutorConfig config;
  19. size_t nr_threads = std::min<size_t>(get_cpu_count(), 2);
  20. config.nr_thread = nr_threads;
  21. m_handle = create_cpu_handle(0, true, &config);
  22. #else
  23. m_handle = create_cpu_handle(0);
  24. #endif
  25. }
  26. void CPU_MULTI_THREADS::TearDown() {
  27. m_handle.reset();
  28. MemoryManagerHolder::instance()->clear();
  29. }
  30. } // namespace test
  31. } // namespace megdnn
  32. // vim: syntax=cpp.doxygen