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.

cpuinfo_help.h 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * \file dnn/test/arm_common/cpuinfo_help.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied.
  11. */
  12. #pragma once
  13. #include <mutex>
  14. #include <vector>
  15. #include "src/common/utils.h"
  16. #if MGB_ENABLE_CPUINFO
  17. #include "cpuinfo.h"
  18. extern const struct cpuinfo_core** cpuinfo_linux_cpu_to_core_map;
  19. class CpuInfoTmpReplace {
  20. public:
  21. CpuInfoTmpReplace(enum cpuinfo_uarch arch) {
  22. m_cpuinfo_lock.lock();
  23. for (uint32_t i = 0; i < cpuinfo_get_cores_count(); ++i) {
  24. m_arch_bak_vec.push_back(cpuinfo_linux_cpu_to_core_map[i]->uarch);
  25. ((struct cpuinfo_core**)cpuinfo_linux_cpu_to_core_map)[i]->uarch =
  26. arch;
  27. }
  28. }
  29. ~CpuInfoTmpReplace() {
  30. if (m_arch_bak_vec.size() > 0) {
  31. for (uint32_t i = 0; i < cpuinfo_get_cores_count(); ++i) {
  32. ((struct cpuinfo_core**)cpuinfo_linux_cpu_to_core_map)[i]
  33. ->uarch = m_arch_bak_vec[i];
  34. }
  35. }
  36. m_cpuinfo_lock.unlock();
  37. }
  38. private:
  39. static std::mutex m_cpuinfo_lock;
  40. std::vector<cpuinfo_uarch> m_arch_bak_vec;
  41. };
  42. #endif
  43. // vim: syntax=cpp.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台