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.

parse_cnbin.cmake 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # This code is licensed under the MIT License. See the FindBANG.cmake script
  2. # for the text of the license.
  3. # The MIT License
  4. #
  5. # License for the specific language governing rights and limitations under
  6. # Permission is hereby granted, free of charge, to any person obtaining a
  7. # copy of this software and associated documentation files (the "Software"),
  8. # to deal in the Software without restriction, including without limitation
  9. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. # and/or sell copies of the Software, and to permit persons to whom the
  11. # Software is furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included
  14. # in all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. # DEALINGS IN THE SOFTWARE.
  23. #
  24. #######################################################################
  25. # Parses a .cnbin file produced by cncc and reports statistics about the file.
  26. file(READ ${input_file} file_text)
  27. if (NOT "${file_text}" STREQUAL "")
  28. string(REPLACE ";" "\\;" file_text ${file_text})
  29. string(REPLACE "\ncode" ";code" file_text ${file_text})
  30. list(LENGTH file_text len)
  31. foreach(line ${file_text})
  32. # Only look at "code { }" blocks.
  33. if(line MATCHES "^code")
  34. # Break into individual lines.
  35. string(REGEX REPLACE "\n" ";" line ${line})
  36. foreach(entry ${line})
  37. # Extract kernel names.
  38. if (${entry} MATCHES "[^g]name = ([^ ]+)")
  39. set(entry "${CMAKE_MATCH_1}")
  40. # Check to see if the kernel name starts with "_"
  41. set(skip FALSE)
  42. # if (${entry} MATCHES "^_")
  43. # Skip the rest of this block.
  44. # message("Skipping ${entry}")
  45. # set(skip TRUE)
  46. # else ()
  47. message("Kernel: ${entry}")
  48. # endif ()
  49. endif()
  50. # Skip the rest of the block if necessary
  51. if(NOT skip)
  52. # Registers
  53. if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
  54. set(entry "${CMAKE_MATCH_3}")
  55. message("Registers: ${entry}")
  56. endif()
  57. # Local memory
  58. if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
  59. set(entry "${CMAKE_MATCH_3}")
  60. message("Local: ${entry}")
  61. endif()
  62. # Shared memory
  63. if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
  64. set(entry "${CMAKE_MATCH_3}")
  65. message("Shared: ${entry}")
  66. endif()
  67. if (${entry} MATCHES "^}")
  68. message("")
  69. endif()
  70. endif()
  71. endforeach()
  72. endif()
  73. endforeach()
  74. else()
  75. # message("FOUND NO DEPENDS")
  76. endif()

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