Merged
refactor(ccu): always build HComm runtime backend #388
每天都要吃馒头Add on 21 days ago
refactor(ccu): always build HComm runtime backend #388
Merged
Merged fromyuaner1057/asc-commccu-launch-migrationintocann/asc-commmaster
Total: 3 files changed+15-64
| @@ -145,16 +145,12 @@ find_ccu_libraries() | |||
| 145 | -DCANN_3RD_LIB_PATH="${PROJECT_ROOT}/third_party" \ | 145 | -DCANN_3RD_LIB_PATH="${PROJECT_ROOT}/third_party" \ |
| 146 | -DCMAKE_BUILD_TYPE=Release \ | 146 | -DCMAKE_BUILD_TYPE=Release \ |
| 147 | -DASCCOMM_BUILD_CCU=ON \ | 147 | -DASCCOMM_BUILD_CCU=ON \ |
| 148 | - -DASCCOMM_BUILD_CCU_RUNTIME=ON \ | 148 | + -DASCCOMM_BUILD_CCU_RUNTIME=ON |
| 149 | - -DASCCOMM_BUILD_CCU_RUNTIME_HCOMM_BACKEND=ON | ||
| 150 | 149 | ||
| 151 | cmake --build "${build_dir}" --target asccomm_ccu ccu_runtime | 150 | cmake --build "${build_dir}" --target asccomm_ccu ccu_runtime |
| 152 | [[ -f "${library}" ]] || fail "CCU library was not built: ${library}" | 151 | [[ -f "${library}" ]] || fail "CCU library was not built: ${library}" |
| 153 | [[ -f "${runtime_library}" ]] || \ | 152 | [[ -f "${runtime_library}" ]] || \ |
| 154 | fail "CCU runtime library was not built: ${runtime_library}" | 153 | fail "CCU runtime library was not built: ${runtime_library}" |
| 155 | - grep -q '^ASCCOMM_BUILD_CCU_RUNTIME_HCOMM_BACKEND:BOOL=ON$' \ | ||
| 156 | - "${build_dir}/CMakeCache.txt" || \ | ||
| 157 | - fail "CCU runtime was built without the HComm backend: ${runtime_library}" | ||
| 158 | CCU_LIBRARY="${library}" | 154 | CCU_LIBRARY="${library}" |
| 159 | CCU_RUNTIME_LIBRARY="${runtime_library}" | 155 | CCU_RUNTIME_LIBRARY="${runtime_library}" |
| 160 | } | 156 | } |
| @@ -10,12 +10,11 @@ | |||
| 10 | 10 | ||
| 11 | set(ASCCOMM_CCU_RUNTIME_ROOT ${CMAKE_CURRENT_LIST_DIR}) | 11 | set(ASCCOMM_CCU_RUNTIME_ROOT ${CMAKE_CURRENT_LIST_DIR}) |
| 12 | 12 | ||
| 13 | -option(ASCCOMM_BUILD_CCU_RUNTIME_HCOMM_BACKEND | ||
| 14 | - "Build the HComm-backed compiler-facing CCU runtime" OFF) | ||
| 15 | - | ||
| 16 | set(_ASCCOMM_CCU_RUNTIME_SOURCES | 13 | set(_ASCCOMM_CCU_RUNTIME_SOURCES |
| 17 | ccu_runtime.cpp | 14 | ccu_runtime.cpp |
| 18 | ccu_runtime_backend.cpp | 15 | ccu_runtime_backend.cpp |
| 16 | + ccu_aot_adapter.cpp | ||
| 17 | + ccu_runtime_hcomm_backend.cpp | ||
| 19 | ) | 18 | ) |
| 20 | 19 | ||
| 21 | add_library(ccu_runtime SHARED ${_ASCCOMM_CCU_RUNTIME_SOURCES}) | 20 | add_library(ccu_runtime SHARED ${_ASCCOMM_CCU_RUNTIME_SOURCES}) |
| @@ -43,24 +42,17 @@ set_target_properties(ccu_runtime PROPERTIES | |||
| 43 | set_property(TARGET ccu_runtime APPEND PROPERTY LINK_DEPENDS | 42 | set_property(TARGET ccu_runtime APPEND PROPERTY LINK_DEPENDS |
| 44 | ${ASCCOMM_CCU_RUNTIME_ROOT}/ccu_runtime.map) | 43 | ${ASCCOMM_CCU_RUNTIME_ROOT}/ccu_runtime.map) |
| 45 | 44 | ||
| 46 | -if(ASCCOMM_BUILD_CCU_RUNTIME_HCOMM_BACKEND) | 45 | +target_compile_definitions(ccu_runtime PRIVATE ASCCOMM_CCU_LOCAL_LOGGING) |
| 47 | - target_sources(ccu_runtime PRIVATE | 46 | +target_link_directories(ccu_runtime PRIVATE |
| 48 | - ccu_aot_adapter.cpp | 47 | + ${ASCEND_CANN_PACKAGE_PATH}/lib64 |
| 49 | - ccu_runtime_hcomm_backend.cpp) | 48 | + ${ASCCOMM_CANN_ARCH_DIR}/lib64) |
| 50 | - target_compile_definitions(ccu_runtime PRIVATE | 49 | +target_link_libraries(ccu_runtime PRIVATE |
| 51 | - CCU_TRANSLATOR_HAS_HCOMM_BACKEND | 50 | + $<$<TARGET_EXISTS:acl_rt_headers>:acl_rt_headers> |
| 52 | - ASCCOMM_CCU_LOCAL_LOGGING) | 51 | + $<$<TARGET_EXISTS:runtime_headers>:runtime_headers> |
| 53 | - target_link_directories(ccu_runtime PRIVATE | 52 | + acl_rt |
| 54 | - ${ASCEND_CANN_PACKAGE_PATH}/lib64 | 53 | + runtime |
| 55 | - ${ASCCOMM_CANN_ARCH_DIR}/lib64) | 54 | + c_sec |
| 56 | - target_link_libraries(ccu_runtime PRIVATE | 55 | + pthread) |
| 57 | - $<$<TARGET_EXISTS:acl_rt_headers>:acl_rt_headers> | ||
| 58 | - $<$<TARGET_EXISTS:runtime_headers>:runtime_headers> | ||
| 59 | - acl_rt | ||
| 60 | - runtime | ||
| 61 | - c_sec | ||
| 62 | - pthread) | ||
| 63 | -endif() | ||
| 64 | 56 | ||
| 65 | if("${PROJECT_SOURCE_DIR}" STREQUAL "${ASCCOMM_ROOT}") | 57 | if("${PROJECT_SOURCE_DIR}" STREQUAL "${ASCCOMM_ROOT}") |
| 66 | if(NOT INSTALL_LIBRARY_DIR) | 58 | if(NOT INSTALL_LIBRARY_DIR) |
| @@ -10,53 +10,16 @@ | |||
| 10 | 10 | ||
| 11 | #include "ccu_runtime_backend.h" | 11 | #include "ccu_runtime_backend.h" |
| 12 | 12 | ||
| 13 | -#if defined(CCU_TRANSLATOR_HAS_HCOMM_BACKEND) | ||
| 14 | #include "ccu_runtime_hcomm_backend.h" | 13 | #include "ccu_runtime_hcomm_backend.h" |
| 15 | -#endif | ||
| 16 | 14 | ||
| 17 | namespace ccu::runtime { | 15 | namespace ccu::runtime { |
| 18 | namespace { | 16 | namespace { |
| 19 | 17 | ||
| 20 | -#if !defined(CCU_TRANSLATOR_HAS_HCOMM_BACKEND) | ||
| 21 | -class UnavailableBackend final : public Backend { | ||
| 22 | -public: | ||
| 23 | - ccu_status_t contextCreate(void*, void**, uint32_t*, uint32_t*) noexcept override | ||
| 24 | - { | ||
| 25 | - return CCU_STATUS_RUNTIME_ERROR; | ||
| 26 | - } | ||
| 27 | - ccu_status_t contextDestroy(void*) noexcept override { return CCU_STATUS_RUNTIME_ERROR; } | ||
| 28 | - ccu_status_t externalEventVa(void*, uint32_t, void**, uint64_t*) noexcept override | ||
| 29 | - { | ||
| 30 | - return CCU_STATUS_RUNTIME_ERROR; | ||
| 31 | - } | ||
| 32 | - ccu_status_t externalXnVa(void*, uint32_t, void**, uint64_t*) noexcept override { return CCU_STATUS_RUNTIME_ERROR; } | ||
| 33 | - ccu_status_t launch( | ||
| 34 | - void*, const ccu_kernel_descriptor_t*, const ccu_rank_entry_t*, void*, HcomCcuSchd, const uint64_t*, uint32_t, | ||
| 35 | - const BackendExternalArg*, uint32_t, void**) noexcept override | ||
| 36 | - { | ||
| 37 | - return CCU_STATUS_RUNTIME_ERROR; | ||
| 38 | - } | ||
| 39 | - BackendSyncResult synchronize(void*, uint64_t, uint64_t) noexcept override | ||
| 40 | - { | ||
| 41 | - return {CCU_STATUS_RUNTIME_ERROR, CCU_ABORT_NONE, true}; | ||
| 42 | - } | ||
| 43 | - ccu_status_t launchDestroy(void*) noexcept override { return CCU_STATUS_RUNTIME_ERROR; } | ||
| 44 | -}; | ||
| 45 | -#endif | ||
| 46 | - | ||
| 47 | Backend* testingBackend = nullptr; | 18 | Backend* testingBackend = nullptr; |
| 48 | 19 | ||
| 49 | } // namespace | 20 | } // namespace |
| 50 | 21 | ||
| 51 | -Backend& systemBackend() noexcept | 22 | +Backend& systemBackend() noexcept { return testingBackend ? *testingBackend : hcommBackend(); } |
| 52 | -{ | ||
| 53 | -#if defined(CCU_TRANSLATOR_HAS_HCOMM_BACKEND) | ||
| 54 | - return testingBackend ? *testingBackend : hcommBackend(); | ||
| 55 | -#else | ||
| 56 | - static UnavailableBackend unavailableBackend; | ||
| 57 | - return testingBackend ? *testingBackend : unavailableBackend; | ||
| 58 | -#endif | ||
| 59 | -} | ||
| 60 | 23 | ||
| 61 | void setBackendForTesting(Backend* backend) noexcept { testingBackend = backend; } | 24 | void setBackendForTesting(Backend* backend) noexcept { testingBackend = backend; } |
| 62 | 25 | ||