1add_subdirectory(perf EXCLUDE_FROM_ALL) 2include_directories("${CMAKE_BINARY_DIR}/minddata/dataset/engine/cache") 3set(MD_FLATBUFFER_OU "${CMAKE_BINARY_DIR}/minddata/dataset/engine/cache") 4set(FBS_FILES de_tensor.fbs) 5ms_build_flatbuffers(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR} generated_engine_files ${MD_FLATBUFFER_OU}) 6 7file(GLOB_RECURSE _CURRENT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc") 8set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD) 9 10if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 11 # Try to find numa header file and its library 12 FIND_PATH(NUMA_INCLUDE_DIR numa.h) 13 MESSAGE("Numa include dir is: ${NUMA_INCLUDE_DIR}") 14 15 FIND_LIBRARY(NUMA_LIBRARY NAMES libnuma.so) 16 MESSAGE("Numa library is: ${NUMA_LIBRARY}") 17 18 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NUMA DEFAULT_MSG 19 NUMA_INCLUDE_DIR 20 NUMA_LIBRARY 21 ) 22 if(NUMA_FOUND) 23 ADD_DEFINITIONS(-DNUMA_ENABLED) 24 MESSAGE("Numa package found") 25 else() 26 MESSAGE(FATAL_ERROR 27 "Numa package not found, try 'sudo yum install numactl-devel' or 'sudo apt-get install libnuma-dev'") 28 endif() 29endif() 30 31if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 32 ADD_DEFINITIONS(-DCACHE_LOCAL_CLIENT) 33endif() 34 35add_library(engine-cache-client OBJECT 36 cache_client.cc 37 cache_fbb.cc 38 cache_request.cc) 39 40if(CMAKE_SYSTEM_NAME MATCHES "Darwin") 41 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-abstract-non-virtual-dtor") 42else() 43 # add python lib dir to rpath 44 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-rpath,$ORIGIN:$ORIGIN/..:$ORIGIN/../lib") 45endif() 46 47if(ENABLE_CACHE) 48 ms_grpc_generate(CACHE_GRPC_SRCS CACHE_GRPC_HDRS cache_grpc.proto) 49 target_sources(engine-cache-client PUBLIC ${CACHE_GRPC_SRCS} 50 cache_grpc_client.cc 51 cache_ipc.cc) 52 53 add_library(engine-cache-server OBJECT 54 ${CACHE_GRPC_SRCS} 55 cache_grpc_server.cc 56 cache_arena.cc 57 cache_hw.cc 58 cache_numa.cc 59 cache_pool.cc 60 cache_service.cc 61 cache_server.cc 62 storage_manager.cc 63 storage_container.cc) 64 65 if(ENABLE_ASAN) 66 target_compile_options(engine-cache-server PRIVATE -fsanitize=address) 67 target_compile_options(engine-cache-server PRIVATE -fno-omit-frame-pointer) 68 target_compile_options(engine-cache-server PRIVATE -ggdb) 69 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") 70 endif() 71 72 add_executable(cache_server cache_main.cc) 73 if(ENABLE_GPU) 74 target_link_libraries(cache_server 75 engine-cache-server 76 _c_dataengine 77 _c_mindrecord 78 mindspore 79 mindspore::protobuf 80 mindspore_gvar 81 ${CUDNN_LIBRARY_PATH} 82 ${PYTHON_LIBRARIES} 83 ${SECUREC_LIBRARY} 84 pthread 85 -ldl 86 -Wl,--no-as-needed 87 mindspore::grpc++) 88 else() 89 target_link_libraries(cache_server 90 engine-cache-server 91 _c_dataengine 92 _c_mindrecord 93 mindspore 94 mindspore::protobuf 95 mindspore_gvar 96 ${PYTHON_LIBRARIES} 97 ${SECUREC_LIBRARY} 98 pthread 99 -ldl 100 -Wl,--no-as-needed 101 mindspore::grpc++ 102 -Wl,--as-needed) 103 endif() 104 105 if(USE_GLOG) 106 target_link_libraries(cache_server mindspore::glog) 107 endif() 108 109 if(NUMA_FOUND) 110 target_link_libraries(cache_server numa) 111 endif() 112 113 add_executable(cache_admin cache_admin.cc cache_admin_arg.cc) 114 target_link_libraries(cache_admin _c_dataengine _c_mindrecord ${PYTHON_LIBRARIES} pthread -ldl) 115 if(ENABLE_TDTQUE) 116 target_link_libraries(cache_admin 117 -Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib ${ACL_TDT_CHANNEL} -Wl,--end-group) 118 else() 119 target_link_libraries(cache_admin 120 -Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib -Wl,--end-group) 121 endif() 122 123 if(USE_GLOG) 124 target_link_libraries(cache_admin mindspore::glog) 125 endif() 126 127 add_dependencies(engine-cache-server generated_engine_files) 128 129 set_target_properties(cache_admin PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) 130 set_target_properties(cache_server PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) 131else() 132 ms_protobuf_generate(CACHE_PROTO_SRCS CACHE_PROTO_HDRS cache_grpc.proto) 133 target_sources(engine-cache-client PUBLIC ${CACHE_PROTO_SRCS}) 134endif() 135 136add_dependencies(engine-cache-client generated_engine_files) 137