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.

CMakeLists.txt 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. include_directories("..")
  2. file(GLOB_RECURSE SOURCES common/*.cpp naive/*.cpp dispatcher/*.cpp)
  3. file(GLOB SOURCES_ *.cpp)
  4. list(APPEND SOURCES ${SOURCES_})
  5. if(NOT ${MGE_ARCH} STREQUAL "naive")
  6. file(GLOB_RECURSE SOURCES_ fallback/*.cpp)
  7. list(APPEND SOURCES ${SOURCES_})
  8. file(GLOB_RECURSE SOURCES_ cpu/*.cpp)
  9. list(APPEND SOURCES ${SOURCES_})
  10. if(${MGE_ARCH} STREQUAL "fallback")
  11. message(WARNING "build only with fallback")
  12. elseif(${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386")
  13. file(GLOB_RECURSE SOURCES_ x86/*.cpp)
  14. list(APPEND SOURCES ${SOURCES_})
  15. endif()
  16. endif()
  17. if(MGE_WITH_CUDA)
  18. file(GLOB_RECURSE SOURCES_ cuda/*.cpp)
  19. list(APPEND SOURCES ${SOURCES_})
  20. file(GLOB_RECURSE CUSOURCES cuda/*.cu)
  21. list(APPEND SOURCES ${CUSOURCES})
  22. endif()
  23. if(MGE_WITH_CAMBRICON)
  24. file(GLOB_RECURSE SOURCES_ cambricon/*.cpp)
  25. list(APPEND SOURCES ${SOURCES_})
  26. endif()
  27. if(MGE_WITH_ATLAS)
  28. file(GLOB_RECURSE SOURCES_ atlas/*.cpp)
  29. list(APPEND SOURCES ${SOURCES_})
  30. endif()
  31. if (MGE_WITH_ROCM)
  32. file (GLOB_RECURSE SOURCES_ rocm/*.cpp)
  33. list (APPEND SOURCES ${SOURCES_})
  34. endif()
  35. add_executable(megdnn_test ${SOURCES})
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
  37. target_link_libraries(megdnn_test gtest)
  38. target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS})
  39. if (MGE_WITH_CUDA)
  40. target_link_libraries(megdnn_test cutlass)
  41. endif()
  42. target_include_directories(megdnn_test
  43. PRIVATE
  44. ${PROJECT_SOURCE_DIR}/third_party/midout/src
  45. )
  46. if(APPLE OR ANDROID)
  47. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  48. else()
  49. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
  50. endif()
  51. if(MGE_ENABLE_COVERAGE)
  52. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
  53. endif()
  54. if (MEG_WITH_ROCM)
  55. target_link_libraries (megdnn_test ${MGE_ROCM_LIBS})
  56. endif ()
  57. if(UNIX)
  58. if(APPLE OR ANDROID)
  59. target_link_libraries(megdnn_test dl)
  60. else()
  61. target_link_libraries(megdnn_test dl rt)
  62. endif()
  63. endif()

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