diff --git a/CMakeLists.txt b/CMakeLists.txt index 0824f804003..be4924c029a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_OSX_SYSROOT "") - set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Winconsistent-missing-override -Wuser-defined-warnings \ + set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Winconsistent-missing-override -Wno-user-defined-warnings \ -Wno-return-std-move -Wno-unused-private-field -Wno-unused-lambda-capture -Wno-sign-compare \ -Wno-overloaded-virtual -Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-pessimizing-move \ -Wno-inconsistent-missing-override -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2") diff --git a/cmake/change_rpath.cmake b/cmake/change_rpath.cmake new file mode 100644 index 00000000000..0b5c0fbb1af --- /dev/null +++ b/cmake/change_rpath.cmake @@ -0,0 +1,54 @@ +function(changerpath target_so target_name link_sos) + set(depend_so "") + foreach(link_so ${link_sos}) + set(some-file "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}.txt") + set(some-file1 "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}1.txt") + set(some-file2 "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}2.txt") + add_custom_command( + OUTPUT + ${some-file} + COMMAND + otool -L ${target_so} | tail -n +2 | grep ${link_so} | head -n1 > ${some-file} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build" + VERBATIM + ) + add_custom_command( + OUTPUT + ${some-file1} + COMMAND + cat ${some-file} | cut -d " " -f 1 | sed -E "s/^.//g" > ${some-file1} + DEPENDS + ${some-file} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build" + VERBATIM + ) + add_custom_command( + OUTPUT + ${some-file2} + COMMAND + awk -F "/" "{print $NF}" ${some-file1} > ${some-file2} + DEPENDS + ${some-file1} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build" + VERBATIM + ) + add_custom_target( + link_${target_name}_${link_so} ALL + COMMAND install_name_tool -change `cat ${some-file1}` @rpath/`cat ${some-file2}` ${target_so} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build" + DEPENDS ${target_so} ${some-file1} ${some-file2} + COMMENT "install tool name" + ) + add_custom_command( + TARGET link_${target_name}_${link_so} + POST_BUILD + COMMAND rm ${some-file} ${some-file1} ${some-file2} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build" + VERBATIM + ) + if(depend_so) + add_dependencies(link_${target_name}_${link_so} link_${target_name}_${depend_so}) + endif() + set(depend_so ${link_so}) + endforeach() +endfunction() diff --git a/cmake/external_libs/icu4c.cmake b/cmake/external_libs/icu4c.cmake index 2c5eee7ca1a..8578f54bf5c 100644 --- a/cmake/external_libs/icu4c.cmake +++ b/cmake/external_libs/icu4c.cmake @@ -28,7 +28,7 @@ else() URL ${REQ_URL} MD5 ${MD5} PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/icu4c/icu4c.patch01 - CONFIGURE_COMMAND ./icu4c/source/runConfigureICU MacOSX --enable-rpath --disable-tests + CONFIGURE_COMMAND ./icu4c/source/runConfigureICU MacOSX --disable-tests --disable-samples --disable-icuio --disable-extras ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json ) @@ -45,6 +45,12 @@ else() ) endif() include_directories(${icu4c_INC}) + if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + include(${CMAKE_SOURCE_DIR}/cmake/change_rpath.cmake) + changerpath($ ${LIB_ICU_COMMON} "libicuuc;libicudata") + changerpath($ ${LIB_ICU_DATA} "libicudata") + changerpath($ ${LIB_ICU_I18N} "libicuuc;libicudata;libicui18n") + endif() add_library(mindspore::icuuc ALIAS icu4c::${LIB_ICU_COMMON}) add_library(mindspore::icudata ALIAS icu4c::${LIB_ICU_DATA}) add_library(mindspore::icui18n ALIAS icu4c::${LIB_ICU_I18N}) diff --git a/cmake/options.cmake b/cmake/options.cmake index 06dcffdd468..60894f2c5fc 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -29,11 +29,6 @@ option(ENABLE_SYM_FILE "enable sym file" OFF) option(BUILD_DEV_MODE "MindSpore build nightly dev mode" OFF) option(ENABLE_FAST_HASH_TABLE "Enable use fast hash table instead of std ones" ON) - -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(ENABLE_DEBUGGER OFF) -endif() - if(NOT ENABLE_D AND NOT ENABLE_TESTCASES AND NOT ENABLE_ACL AND NOT ENABLE_GE) set(ENABLE_GLIBCXX ON) endif() @@ -143,7 +138,7 @@ endif() if(ENABLE_DEBUGGER OR ENABLE_TESTCASES) set(MS_BUILD_GRPC ON) endif() -if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") +if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") set(MS_BUILD_GRPC ON) endif() @@ -155,7 +150,7 @@ if(ENABLE_ACL AND NOT ENABLE_D) set(MODE_ASCEND_ACL ON) endif() -if(ENABLE_CPU AND NOT WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") +if(ENABLE_CPU AND NOT WIN32) add_compile_definitions(ENABLE_ARMOUR) endif() diff --git a/cmake/package_mac.cmake b/cmake/package_mac.cmake index e273925c7f7..6ae6cd179c7 100644 --- a/cmake/package_mac.cmake +++ b/cmake/package_mac.cmake @@ -40,9 +40,6 @@ set(INSTALL_BASE_DIR ".") set(INSTALL_BIN_DIR "bin") set(INSTALL_CFG_DIR "config") set(INSTALL_LIB_DIR "lib") - -message("offline debugger does not support macosx system temporarily") - # set package files install( TARGETS _c_expression @@ -50,6 +47,14 @@ install( COMPONENT mindspore ) +if(ENABLE_DEBUGGER) + install( + TARGETS _mindspore_offline_debug + DESTINATION ${INSTALL_BASE_DIR} + COMPONENT mindspore + ) +endif() + install( TARGETS mindspore_shared_lib DESTINATION ${INSTALL_LIB_DIR} @@ -71,6 +76,25 @@ if(USE_GLOG) ) endif() +install(FILES ${libevent_LIBPATH}/libevent-2.1.7.dylib + DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore) +install(FILES ${libevent_LIBPATH}/libevent_core-2.1.7.dylib + DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore) +install(FILES ${libevent_LIBPATH}/libevent_extra-2.1.7.dylib + DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore) +install(FILES ${libevent_LIBPATH}/libevent_openssl-2.1.7.dylib + DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore) +install(FILES ${libevent_LIBPATH}/libevent_pthreads-2.1.7.dylib + DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore) + +if(ENABLE_CPU AND NOT WIN32) + install( + TARGETS ps_cache + DESTINATION ${INSTALL_LIB_DIR} + COMPONENT mindspore + ) +endif() + if(MS_BUILD_GRPC) file(GLOB_RECURSE GRPC_LIB_LIST ${grpc_LIBPATH}/libmindspore* @@ -218,6 +242,14 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset) ) endif() +if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/offline_debug) + install( + DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/offline_debug + DESTINATION ${INSTALL_PY_DIR} + COMPONENT mindspore + ) +endif() + ## Public header files install( DIRECTORY ${CMAKE_SOURCE_DIR}/include diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index ebbd507ff96..2fb5c7aa108 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -374,9 +374,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows") target_link_libraries(mindspore mindspore_gvar) target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore mindspore_core -Wl,--no-whole-archive) elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") - target_link_libraries(mindspore mindspore::pybind11_module) - target_link_libraries(mindspore mindspore_gvar) - target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore mindspore_core -Wl,-noall_load) + target_link_libraries(mindspore proto_input mindspore::protobuf + mindspore::event mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json) + target_link_libraries(mindspore mindspore::event_core ps_cache) + target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore mindspore_core proto_input -Wl,-noall_load) + target_link_libraries(_c_expression PRIVATE mindspore::pybind11_module) + target_link_libraries(_c_expression PRIVATE mindspore_gvar) else() if(ENABLE_CPU AND NOT WIN32) target_link_libraries(mindspore proto_input mindspore::protobuf diff --git a/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt b/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt index 3dbe1a48665..67c1bace283 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt +++ b/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt @@ -44,7 +44,7 @@ if(ENABLE_CPU) endif() endif() -if(NOT ENABLE_CPU OR WIN32 OR APPLE) +if(NOT ENABLE_CPU OR WIN32) list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/apply_momentum_ps_kernel.cc") list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/embedding_look_up_proxy_kernel.cc") list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/embedding_look_up_ps_kernel.cc") diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.cc index 6fa72b8eff9..0c0a23c179d 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.cc @@ -96,7 +96,8 @@ void GetKeysKernel::BuildGetKeysReq(const std::shared_ptr &fbb) { MS_LOG(INFO) << "BuildGetKeysReq successfully."; } -bool GetKeysKernel::SavePublicKeyList(auto remote_public_key) { +bool GetKeysKernel::SavePublicKeyList( + const flatbuffers::Vector> *remote_public_key) { if (remote_public_key == nullptr) { MS_LOG(EXCEPTION) << "Input remote_pubic_key is nullptr."; } diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.h index 2d0cbc63e8c..8317273e3f3 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/fl/get_keys_kernel.h @@ -41,7 +41,8 @@ class GetKeysKernel : public CPUKernel { private: void BuildGetKeysReq(const std::shared_ptr &fbb); - bool SavePublicKeyList(auto remote_public_key); + bool SavePublicKeyList( + const flatbuffers::Vector> *remote_public_key); uint32_t rank_id_; uint32_t server_num_; diff --git a/mindspore/ccsrc/debug/CMakeLists.txt b/mindspore/ccsrc/debug/CMakeLists.txt index 1b057c8c6f6..a4c6a12ff9d 100644 --- a/mindspore/ccsrc/debug/CMakeLists.txt +++ b/mindspore/ccsrc/debug/CMakeLists.txt @@ -33,10 +33,6 @@ if("${ENABLE_HIDDEN}" STREQUAL "OFF") string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field") -endif() - if(ENABLE_DEBUGGER) list(APPEND _DEBUG_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/debugger/debugger.cc" @@ -56,7 +52,7 @@ if(NOT ENABLE_SECURITY) "${CMAKE_CURRENT_SOURCE_DIR}/data_dump/dump_utils.cc" "${CMAKE_CURRENT_SOURCE_DIR}/data_dump/npy_header.cc" ) - if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows") list(APPEND _DEBUG_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/common.cc" "${CMAKE_CURRENT_SOURCE_DIR}/data_dump/e2e_dump.cc" diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index ad55a530651..5e0d3f982b2 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -37,10 +37,19 @@ #include "nlohmann/json.hpp" #include "debug/debugger/tensor_summary.h" #include "utils/file_utils.h" -#include "linux/limits.h" +#include "climits" #ifdef ONLINE_DBG_MODE namespace mindspore { #endif + +namespace { +#ifdef __APPLE__ +constexpr int kStrErrorNone = 0; +#else +constexpr char *kStrErrorNone = nullptr; +#endif +} // namespace + DebugServices::DebugServices() { tensor_loader_ = std::make_shared(); } DebugServices::DebugServices(const DebugServices &other) { @@ -632,7 +641,7 @@ void DebugServices::ReadTensorFromNpy(const std::string &tensor_name, const std: const int kMaxFilenameLength = 128; char err_info[kMaxFilenameLength]; auto ret = strerror_r(errno, err_info, sizeof(err_info)); - if (ret != nullptr) { + if (ret != kStrErrorNone) { MS_LOG(ERROR) << " ErrInfo:" << ret; } return; @@ -1059,7 +1068,7 @@ void DebugServices::ReadGraphRunIter(std::string file_path, std::tuple> *result_list) { std::string time_stamp = ""; std::string type_name = ""; - uint64_t data_size = 0; + size_t data_size = 0; std::vector shape; std::vector *buffer = nullptr; if (found) { diff --git a/mindspore/ccsrc/debug/tensor_load.h b/mindspore/ccsrc/debug/tensor_load.h index 7ce1e5bc2ed..7d3bb616108 100644 --- a/mindspore/ccsrc/debug/tensor_load.h +++ b/mindspore/ccsrc/debug/tensor_load.h @@ -32,7 +32,11 @@ namespace mindspore { #endif class TensorLoader { public: +#ifndef __APPLE__ TensorLoader() : iter_num_(-1), mem_total_(0), mem_usage_(0) {} +#else + TensorLoader() : mem_total_(0), mem_usage_(0) {} +#endif ~TensorLoader() { EmptyTensor(); } @@ -227,7 +231,9 @@ class TensorLoader { // the pair is (device_id, iteration) std::map> tensor_list_map_; std::map> prev_tensor_list_map_; +#ifndef __APPLE__ uint32_t iter_num_; +#endif std::mutex lock_; std::mutex mem_lock_; uint64_t mem_total_; diff --git a/mindspore/ccsrc/fl/CMakeLists.txt b/mindspore/ccsrc/fl/CMakeLists.txt index 67c438f851a..fd40a754baa 100644 --- a/mindspore/ccsrc/fl/CMakeLists.txt +++ b/mindspore/ccsrc/fl/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB_RECURSE _FL_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc") -if(NOT ENABLE_CPU OR WIN32 OR APPLE) +if(NOT ENABLE_CPU OR WIN32) list(REMOVE_ITEM _FL_SRC_FILES "server/kernel/apply_momentum_kernel.cc") list(REMOVE_ITEM _FL_SRC_FILES "server/kernel/aggregation_kernel_factory.cc") list(REMOVE_ITEM _FL_SRC_FILES "server/kernel/dense_grad_accum_kernel.cc") @@ -49,6 +49,10 @@ if(NOT ENABLE_CPU OR WIN32 OR APPLE) list(REMOVE_ITEM _FL_SRC_FILES "armour/cipher/cipher_unmask.cc") endif() +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-pointer-compare") +endif() + list(LENGTH _FL_SRC_FILES fl_file_num) if(NOT fl_file_num EQUAL 0) set_property(SOURCE ${_FL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_FL) diff --git a/mindspore/ccsrc/fl/worker/fl_worker.cc b/mindspore/ccsrc/fl/worker/fl_worker.cc index fd821e3b10e..ae385b23251 100644 --- a/mindspore/ccsrc/fl/worker/fl_worker.cc +++ b/mindspore/ccsrc/fl/worker/fl_worker.cc @@ -104,10 +104,14 @@ bool FLWorker::SendToServer(uint32_t server_rank, const void *data, size_t size, std::this_thread::yield(); } +#ifdef __APPLE__ + std::shared_ptr message(new unsigned char[size], std::default_delete()); +#else std::shared_ptr message; std::unique_ptr message_addr = std::make_unique(size); MS_EXCEPTION_IF_NULL(message_addr); message = std::move(message_addr); +#endif MS_EXCEPTION_IF_NULL(message); uint64_t src_size = size; diff --git a/mindspore/ccsrc/minddata/dataset/CMakeLists.txt b/mindspore/ccsrc/minddata/dataset/CMakeLists.txt index 1238bd27d60..2d17d07c4e2 100644 --- a/mindspore/ccsrc/minddata/dataset/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/dataset/CMakeLists.txt @@ -74,9 +74,7 @@ add_subdirectory(core) add_subdirectory(kernels) add_subdirectory(engine) add_subdirectory(api) -if(NOT APPLE) - add_subdirectory(audio) -endif() +add_subdirectory(audio) add_subdirectory(text) add_subdirectory(callback) add_subdirectory(plugin) @@ -91,16 +89,12 @@ add_dependencies(engine-datasetops-source-sampler core) add_dependencies(engine-datasetops core) add_dependencies(engine-datasetops-mapop core) add_dependencies(engine-opt core) -if(NOT APPLE) - add_dependencies(engine-gnn core) -endif() +add_dependencies(engine-gnn core) add_dependencies(engine core) add_dependencies(callback core) -if(NOT APPLE) - add_dependencies(audio-kernels core) - add_dependencies(audio-ir core) - add_dependencies(audio-ir-kernels core) -endif() +add_dependencies(audio-kernels core) +add_dependencies(audio-ir core) +add_dependencies(audio-ir-kernels core) add_dependencies(text core) add_dependencies(text-kernels core) add_dependencies(text-ir core) @@ -161,10 +155,14 @@ set(submodules $ $ $ + $ $ $ $ $ + $ + $ + $ $ $ $ @@ -175,15 +173,6 @@ set(submodules $ ) -if(NOT APPLE) - set(submodules - ${submodules} - $ - $ - $ - $) -endif() - if(ENABLE_ACL) set(submodules ${submodules} @@ -223,61 +212,6 @@ endif() ################# Link with external libraries ######################## target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar) -set(targetso $) -set(target_tiny "libtinyxml") -set(target_icuuc "libicuuc") -set(target_icudata "libicudata") -set(target_icui18n "libicui18n") -function(changerpath targetso linkso) - set(some-file "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}.txt") - set(some-file1 "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}1.txt") - set(some-file2 "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}2.txt") - add_custom_command( - OUTPUT - ${some-file} - COMMAND - otool -L ${targetso} | grep ${linkso} > ${some-file} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset" - VERBATIM - ) - add_custom_command( - OUTPUT - ${some-file1} - COMMAND - cat ${some-file} | cut -d " " -f 1 | sed -E "s/^.//g" > ${some-file1} - DEPENDS - ${some-file} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset" - VERBATIM - ) - add_custom_command( - OUTPUT - ${some-file2} - COMMAND - awk -F "/" "{print $NF}" ${some-file1} > ${some-file2} - DEPENDS - ${some-file1} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset" - VERBATIM - ) - add_custom_target( - link_${linkso} ALL - COMMAND install_name_tool -change `cat ${some-file1}` @rpath/`cat ${some-file2}` ${targetso} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset" - DEPENDS ${targetso} ${some-file1} ${some-file2} - COMMENT "install tool name") -endfunction() - -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - changerpath(${targetso} ${target_tiny}) - changerpath(${targetso} ${target_icuuc}) - add_dependencies(link_${target_icuuc} link_${target_tiny}) - changerpath(${targetso} ${target_icudata}) - add_dependencies(link_${target_icudata} link_${target_icuuc}) - changerpath(${targetso} ${target_icui18n}) - add_dependencies(link_${target_icui18n} link_${target_icudata}) -endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") if(ENABLE_PYTHON) target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY}) @@ -320,9 +254,7 @@ else() if(${ENABLE_IBVERBS} STREQUAL "ON") target_link_libraries(_c_dataengine PRIVATE ibverbs rdmacm) endif() - if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") - target_link_libraries(_c_dataengine PRIVATE ps_cache) - endif() + target_link_libraries(_c_dataengine PRIVATE ps_cache) endif() endif() @@ -349,3 +281,9 @@ endif() if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") set_target_properties(_c_dataengine PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + include(${CMAKE_SOURCE_DIR}/cmake/change_rpath.cmake) + set(LINK_SOS libtinyxml libicuuc libicudata libicui18n) + changerpath($ _c_dataengine "${LINK_SOS}") +endif() \ No newline at end of file diff --git a/mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt b/mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt index 54ec3ce350d..3e0cb3d36df 100644 --- a/mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt @@ -1,55 +1,42 @@ file(GLOB_RECURSE _CURRENT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc") set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD) if(ENABLE_PYTHON) - set(API_PYTHON_SRC_FILES - python/bindings/dataset/audio/bindings.cc - python/bindings/dataset/audio/kernels/ir/bindings.cc - python/bindings/dataset/callback/bindings.cc - python/bindings/dataset/core/bindings.cc - python/bindings/dataset/engine/cache/bindings.cc - python/bindings/dataset/engine/datasetops/bindings.cc - python/bindings/dataset/engine/gnn/bindings.cc - python/bindings/dataset/engine/ir/consumer/bindings.cc - python/bindings/dataset/engine/ir/datasetops/bindings.cc - python/bindings/dataset/engine/ir/datasetops/source/bindings.cc - python/bindings/dataset/engine/ir/datasetops/source/samplers/bindings.cc - python/bindings/dataset/engine/ir/execute/bindings.cc - python/bindings/dataset/engine/ir/schema/bindings.cc - python/bindings/dataset/engine/perf/bindings.cc - python/bindings/dataset/kernels/bindings.cc - python/bindings/dataset/kernels/ir/bindings.cc - python/bindings/dataset/kernels/ir/image/bindings.cc - python/bindings/dataset/text/bindings.cc - python/bindings/dataset/text/kernels/ir/bindings.cc - python/bindings/mindrecord/include/bindings.cc - python/pybind_conversion.cc - python/pybind_register.cc - ) - if(APPLE) - list(REMOVE_ITEM API_PYTHON_SRC_FILES + add_library(APItoPython OBJECT python/bindings/dataset/audio/bindings.cc python/bindings/dataset/audio/kernels/ir/bindings.cc + python/bindings/dataset/callback/bindings.cc + python/bindings/dataset/core/bindings.cc + python/bindings/dataset/engine/cache/bindings.cc + python/bindings/dataset/engine/datasetops/bindings.cc python/bindings/dataset/engine/gnn/bindings.cc + python/bindings/dataset/engine/ir/consumer/bindings.cc + python/bindings/dataset/engine/ir/datasetops/bindings.cc + python/bindings/dataset/engine/ir/datasetops/source/bindings.cc + python/bindings/dataset/engine/ir/datasetops/source/samplers/bindings.cc + python/bindings/dataset/engine/ir/execute/bindings.cc + python/bindings/dataset/engine/ir/schema/bindings.cc + python/bindings/dataset/engine/perf/bindings.cc + python/bindings/dataset/kernels/bindings.cc + python/bindings/dataset/kernels/ir/bindings.cc + python/bindings/dataset/kernels/ir/image/bindings.cc + python/bindings/dataset/text/bindings.cc + python/bindings/dataset/text/kernels/ir/bindings.cc + python/bindings/mindrecord/include/bindings.cc + python/pybind_conversion.cc + python/pybind_register.cc ) - endif() - add_library(APItoPython OBJECT ${API_PYTHON_SRC_FILES}) target_include_directories(APItoPython PRIVATE ${pybind11_INCLUDE_DIRS}) endif() -set(API_CPP_SRC_FILES - audio.cc - config.cc - data_helper.cc - datasets.cc - execute.cc - iterator.cc - transforms.cc - samplers.cc - text.cc - vision.cc - ) - -if(APPLE) - list(REMOVE_ITEM API_CPP_SRC_FILES audio.cc) -endif() -add_library(cpp-API OBJECT ${API_CPP_SRC_FILES}) \ No newline at end of file +add_library(cpp-API OBJECT + audio.cc + config.cc + data_helper.cc + datasets.cc + execute.cc + iterator.cc + transforms.cc + samplers.cc + text.cc + vision.cc + ) diff --git a/mindspore/ccsrc/minddata/dataset/audio/kernels/audio_utils.h b/mindspore/ccsrc/minddata/dataset/audio/kernels/audio_utils.h index 1cd206ef0fe..b076980d32a 100644 --- a/mindspore/ccsrc/minddata/dataset/audio/kernels/audio_utils.h +++ b/mindspore/ccsrc/minddata/dataset/audio/kernels/audio_utils.h @@ -937,7 +937,7 @@ Status Flanger(const std::shared_ptr input, std::shared_ptr *out cur_channel_phase[j] = static_cast(j * lfo_length * channel_phase + 0.5); // through the current channel phase and lfo arrays to get the delay auto iter_lfo = lfo->begin(); - delay_tensor[j] = *(iter_lfo + (lfo_pos + cur_channel_phase[j]) % lfo_length); + delay_tensor[j] = *(iter_lfo + static_cast((lfo_pos + cur_channel_phase[j]) % lfo_length)); // the frac delay is obtained by using the frac function frac_delay[j] = delay_tensor[j] - static_cast(delay_tensor[j]); delay_tensor[j] = floor(delay_tensor[j]); diff --git a/mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt b/mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt index 5bc5ce87afe..73e1d820e89 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt @@ -1,8 +1,6 @@ add_subdirectory(datasetops) add_subdirectory(opt) -if(NOT APPLE) - add_subdirectory(gnn) -endif() +add_subdirectory(gnn) add_subdirectory(ir) message("ENABLE_SECURITY = ${ENABLE_SECURITY}") @@ -49,12 +47,10 @@ add_dependencies(engine engine-datasetops engine-datasetops-source engine-opt + engine-gnn engine-cache-client engine-datasetops-mapop ) -if(NOT APPLE) - add_dependencies(engine engine-gnn) -endif() if(NOT ENABLE_SECURITY) add_dependencies(engine engine-perf) diff --git a/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt b/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt index 2489fba5c09..b470fae5d54 100644 --- a/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/mindrecord/CMakeLists.txt @@ -48,4 +48,6 @@ else() endif() endif() -set_target_properties(_c_mindrecord PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) +if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + set_target_properties(_c_mindrecord PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) +endif() diff --git a/mindspore/ccsrc/pipeline/jit/action.cc b/mindspore/ccsrc/pipeline/jit/action.cc index 5f561ea543a..b6b25067620 100644 --- a/mindspore/ccsrc/pipeline/jit/action.cc +++ b/mindspore/ccsrc/pipeline/jit/action.cc @@ -46,7 +46,7 @@ #include "frontend/optimizer/py_pass_manager.h" #include "utils/ms_context.h" #include "vm/transform.h" -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/parameter_server.h" #include "ps/scheduler.h" #include "ps/worker.h" @@ -623,7 +623,7 @@ bool OptInlineAction(const ResourcePtr &res) { bool GeOptimizeAction(const ResourcePtr &res) { return OptimizeAction(res, kGePasses); } bool VmOptimizeAction(const ResourcePtr &res) { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_ps_mode()) { kVmPasses.push_back({"server_communication_op_fusion", ps::Util::FuseServerCommOps}); } @@ -823,7 +823,7 @@ bool ExecuteAction(const ResourcePtr &res) { return true; } -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) bool StartPSWorkerAction(const ResourcePtr &) { ps::Worker::GetInstance().Run(); return true; @@ -1163,7 +1163,7 @@ std::vector VmPipeline() { (void)actions.emplace_back(std::make_pair("eliminate_forward_cnode", EliminateForwardCNode)); (void)actions.emplace_back(std::make_pair("validate", ValidateAction)); -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_worker()) { std::string server_mode = ps::PSContext::instance()->server_mode(); if (server_mode == ps::kServerModeFL || server_mode == ps::kServerModeHybrid) { @@ -1201,7 +1201,7 @@ std::vector MindIRPipeline() { (void)actions.emplace_back(std::make_pair("execute", ExecuteAction)); return actions; } -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) std::vector ServerPipeline() { auto actions = CommonPipeline(); (void)actions.emplace_back(std::make_pair("optimize", VmOptimizeAction)); diff --git a/mindspore/ccsrc/pipeline/jit/init.cc b/mindspore/ccsrc/pipeline/jit/init.cc index 80dee72c9b4..1a0aa753698 100644 --- a/mindspore/ccsrc/pipeline/jit/init.cc +++ b/mindspore/ccsrc/pipeline/jit/init.cc @@ -36,7 +36,7 @@ #else #include "runtime/device/gpu/distribution/collective_fake_init.h" #endif -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/util.h" #endif #include "ps/ps_context.h" diff --git a/mindspore/ccsrc/pipeline/jit/pass.cc b/mindspore/ccsrc/pipeline/jit/pass.cc index 336b81f5e3e..3e56634a78f 100644 --- a/mindspore/ccsrc/pipeline/jit/pass.cc +++ b/mindspore/ccsrc/pipeline/jit/pass.cc @@ -49,7 +49,7 @@ #include "frontend/optimizer/irpass/gradient_eliminate.h" #include "frontend/optimizer/irpass/parameter_eliminate.h" #include "frontend/optimizer/irpass/updatestate_eliminate.h" -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/util.h" #include "ps/ps_context.h" #endif @@ -218,7 +218,7 @@ namespace { bool ReAutoMonadWrapper(const FuncGraphPtr &root, const opt::OptimizerPtr &) { return ReAutoMonad(root); } bool parallel_mode() { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_server() || ps::PSContext::instance()->is_scheduler()) { return false; } @@ -603,7 +603,7 @@ bool SliceRecomputeActivationPass(const ResourcePtr &res) { bool AddCacheEmbeddingPass(const ResourcePtr &res) { MS_EXCEPTION_IF_NULL(res); -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_ps_mode()) { return true; } diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index ce2f2e21282..32a3e55d6c2 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -66,7 +66,7 @@ #endif #endif -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/constants.h" #include "ps/util.h" #include "ps/worker.h" @@ -881,7 +881,7 @@ std::vector GetPipeline(const ResourcePtr &resource, const std::stri std::string backend = MsContext::GetInstance()->backend_policy(); -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) const std::string &server_mode = ps::PSContext::instance()->server_mode(); if ((server_mode == ps::kServerModeFL || server_mode == ps::kServerModeHybrid) && ps::PSContext::instance()->is_server()) { @@ -1442,7 +1442,7 @@ bool InitExecDataset(const std::string &queue_name, int64_t iter_num, int64_t ba bool InitExecDatasetVm(const std::string &queue_name, int64_t size, int64_t batch_size, const std::vector &types, const std::vector> &shapes, const std::vector &input_indexes, bool need_run) { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if ((ps::PSContext::instance()->is_ps_mode()) && (!ps::PSContext::instance()->is_worker())) { return true; } @@ -1661,7 +1661,7 @@ void FinalizeBackend() { void ClearResAtexit() { MS_LOG(DEBUG) << "Pipeline clear all resource"; RecordExitStatus(); -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_ps_mode() && ps::PSContext::instance()->is_worker()) { if (ps::PsDataPrefetch::GetInstance().cache_enable()) { ps::ps_cache_instance.Finalize(); diff --git a/mindspore/ccsrc/ps/CMakeLists.txt b/mindspore/ccsrc/ps/CMakeLists.txt index 796723f13f1..f8868d8f5df 100644 --- a/mindspore/ccsrc/ps/CMakeLists.txt +++ b/mindspore/ccsrc/ps/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB_RECURSE _PS_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc") -if(NOT ENABLE_CPU OR WIN32 OR APPLE) +if(NOT ENABLE_CPU OR WIN32) list(REMOVE_ITEM _PS_SRC_FILES "optimizer_info_builder.cc") list(REMOVE_ITEM _PS_SRC_FILES "optimizer_info.cc") list(REMOVE_ITEM _PS_SRC_FILES "scheduler.cc") diff --git a/mindspore/ccsrc/ps/constants.h b/mindspore/ccsrc/ps/constants.h index 2591cf131e1..0091ca8cc2e 100644 --- a/mindspore/ccsrc/ps/constants.h +++ b/mindspore/ccsrc/ps/constants.h @@ -192,9 +192,13 @@ const std::map kCiphers = {{"ECDHE-RSA-AES128-GCM-SHA256", {"!PSK", 27}, {"kEDH+AESGCM", 28}}; +#ifdef __APPLE__ +using DataPtr = std::shared_ptr; +#else using DataPtr = std::shared_ptr; +#endif using VectorPtr = std::shared_ptr>; -using Key = uint64_t; +using Key = size_t; using Keys = std::vector; using Values = std::vector; using ValuesPtr = std::shared_ptr; diff --git a/mindspore/ccsrc/ps/core/abstract_node.cc b/mindspore/ccsrc/ps/core/abstract_node.cc index 832b7da7357..00093010b35 100644 --- a/mindspore/ccsrc/ps/core/abstract_node.cc +++ b/mindspore/ccsrc/ps/core/abstract_node.cc @@ -956,7 +956,11 @@ void AbstractNode::ProcessSendData(const std::shared_ptr &conn, c MS_EXCEPTION_IF_NULL(conn); MS_EXCEPTION_IF_NULL(meta); MS_EXCEPTION_IF_NULL(data); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[size], std::default_delete()); +#else std::shared_ptr res(new unsigned char[size]); +#endif if (size > 0) { size_t dest_size = size; size_t src_size = size; diff --git a/mindspore/ccsrc/ps/core/abstract_node.h b/mindspore/ccsrc/ps/core/abstract_node.h index 78a04960c46..f771f9b70e8 100644 --- a/mindspore/ccsrc/ps/core/abstract_node.h +++ b/mindspore/ccsrc/ps/core/abstract_node.h @@ -61,7 +61,11 @@ class AbstractNode : public Node { const std::shared_ptr &meta, const Protos &protos, const void *data, size_t size); +#ifdef __APPLE__ + using DataPtr = std::shared_ptr; +#else using DataPtr = std::shared_ptr; +#endif using VectorPtr = std::shared_ptr>; using RequestHandler = std::function &conn, const std::shared_ptr &meta, diff --git a/mindspore/ccsrc/ps/core/communicator/tcp_communicator.h b/mindspore/ccsrc/ps/core/communicator/tcp_communicator.h index f81c57d37b0..d5d4a07e772 100644 --- a/mindspore/ccsrc/ps/core/communicator/tcp_communicator.h +++ b/mindspore/ccsrc/ps/core/communicator/tcp_communicator.h @@ -84,7 +84,11 @@ class TcpCommunicator : public CommunicatorBase { bool SendPbRequest(const T &pb_msg, const uint32_t &rank_id, TcpUserCommand command, std::shared_ptr> *output = nullptr) { const std::string &msg_str = pb_msg.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr msg(new unsigned char[msg_str.size()], std::default_delete()); +#else std::shared_ptr msg(new unsigned char[msg_str.size()]); +#endif MS_ERROR_IF_NULL_W_RET_VAL(msg, false); size_t dest_size = msg_str.size(); size_t src_size = msg_str.size(); diff --git a/mindspore/ccsrc/ps/core/scheduler_recovery.h b/mindspore/ccsrc/ps/core/scheduler_recovery.h index 88492d49c9c..08488ffa094 100644 --- a/mindspore/ccsrc/ps/core/scheduler_recovery.h +++ b/mindspore/ccsrc/ps/core/scheduler_recovery.h @@ -49,7 +49,7 @@ class SchedulerRecovery : public RecoveryBase { private: // The node_ will only be instantiated with worker/server node. - SchedulerNode *const node_; + SchedulerNode *const node_ = nullptr; }; } // namespace core } // namespace ps diff --git a/mindspore/ccsrc/ps/ps_cache/CMakeLists.txt b/mindspore/ccsrc/ps/ps_cache/CMakeLists.txt index ebc8d36a51a..0cc8f6e034f 100644 --- a/mindspore/ccsrc/ps/ps_cache/CMakeLists.txt +++ b/mindspore/ccsrc/ps/ps_cache/CMakeLists.txt @@ -1,7 +1,6 @@ -if(ENABLE_CPU AND NOT WIN32 AND NOT APPLE) +if(ENABLE_CPU AND NOT WIN32) file(GLOB_RECURSE _PS_CACHE_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "ps_data/*.cc") set_property(SOURCE ${_PS_CACHE_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_PS) add_library(ps_cache SHARED ${_PS_CACHE_SRC_FILES}) + target_link_libraries(ps_cache mindspore::pybind11_module) endif() - - diff --git a/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc b/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc index 4bbcd462852..85293684458 100644 --- a/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc +++ b/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc @@ -231,9 +231,14 @@ void PsCacheManager::AllocMemForHashTable() { device_address.addr = addr; auto &host_address = item.second.host_address; +#ifdef __APPLE__ + host_address = + std::shared_ptr(new float[host_vocab_cache_size_ * embedding_size], std::default_delete()); +#else std::unique_ptr host_hash_table_addr = std::make_unique(host_vocab_cache_size_ * embedding_size); MS_EXCEPTION_IF_NULL(host_hash_table_addr); host_address = std::move(host_hash_table_addr); +#endif MS_EXCEPTION_IF_NULL(host_address); max_embedding_size = (embedding_size > max_embedding_size) ? embedding_size : max_embedding_size; diff --git a/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.h b/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.h index 27ae9fc8ccc..5290c96ee73 100644 --- a/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.h +++ b/mindspore/ccsrc/ps/ps_cache/ps_cache_manager.h @@ -49,7 +49,11 @@ struct HashTableInfo { size_t embedding_size{0}; size_t vocab_size{0}; Address device_address{nullptr, 0}; +#ifdef __APPLE__ + std::shared_ptr host_address{nullptr}; +#else std::shared_ptr host_address{nullptr}; +#endif ParamInitInfo param_init_info_; }; diff --git a/mindspore/ccsrc/ps/ps_context.cc b/mindspore/ccsrc/ps/ps_context.cc index 8f9df67e29f..1b92625b6f2 100644 --- a/mindspore/ccsrc/ps/ps_context.cc +++ b/mindspore/ccsrc/ps/ps_context.cc @@ -18,7 +18,7 @@ #include "utils/log_adapter.h" #include "utils/ms_utils.h" #include "backend/kernel_compiler/kernel.h" -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/ps_cache/ps_cache_manager.h" #include "ps/ps_cache/ps_data/ps_data_prefetch.h" #endif @@ -88,7 +88,7 @@ void PSContext::Reset() { is_worker_ = false; is_pserver_ = false; is_sched_ = false; -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PsDataPrefetch::GetInstance().cache_enable()) { ps_cache_instance.Finalize(); set_cache_enable(false); @@ -144,44 +144,44 @@ uint32_t PSContext::ps_rank_id() const { return rank_id_; } void PSContext::InsertHashTableSize(const std::string ¶m_name, size_t cache_vocab_size, size_t embedding_size, size_t vocab_size) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.InsertHashTableSize(param_name, cache_vocab_size, embedding_size, vocab_size); #endif } void PSContext::ReInsertHashTableSize(const std::string &new_param_name, const std::string &cur_param_name, size_t cache_vocab_size, size_t embedding_size) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.ReInsertHashTableSize(new_param_name, cur_param_name, cache_vocab_size, embedding_size); #endif } void PSContext::InsertWeightInitInfo(const std::string ¶m_name, size_t global_seed, size_t op_seed) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.InsertWeightInitInfo(param_name, global_seed, op_seed); #endif } void PSContext::InsertAccumuInitInfo(const std::string ¶m_name, float init_val) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.InsertAccumuInitInfo(param_name, init_val); #endif } void PSContext::CloneHashTable(const std::string &dest_param_name, const std::string &src_param_name) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.CloneHashTable(dest_param_name, src_param_name); #endif } void PSContext::set_cache_enable(bool cache_enable) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) PsDataPrefetch::GetInstance().set_cache_enable(cache_enable); #endif } void PSContext::set_rank_id(uint32_t rank_id) const { -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) ps_cache_instance.set_rank_id(rank_id); #endif } diff --git a/mindspore/ccsrc/ps/worker.cc b/mindspore/ccsrc/ps/worker.cc index 1c107a88b7e..d04080d2b01 100644 --- a/mindspore/ccsrc/ps/worker.cc +++ b/mindspore/ccsrc/ps/worker.cc @@ -227,7 +227,11 @@ bool Worker::InitPSEmbeddingTable(const size_t &key, const std::vector & std::string kv_data = embedding_table_meta.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -293,8 +297,11 @@ bool Worker::DoPSEmbeddingLookup(const Key &key, const std::vector &lookup_ if (messages.at(i).first) { rank_ids.push_back(i); std::string kv_data = messages.at(i).second.SerializeAsString(); - +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -382,7 +389,11 @@ bool Worker::UpdateEmbeddingTable(const std::vector &keys, const std::vecto rank_ids.push_back(i); std::string kv_data = messages.at(i).second.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -403,7 +414,11 @@ void Worker::Finalize() { kvs.add_keys(0); kvs.add_values(0.0f); std::string kv_data = kvs.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -644,7 +659,11 @@ void Worker::PushData(const std::vector &keys, const std::vector &va SendForPush(cmd, kvs, worker_init_embedding_partitioner_, {}); } else { std::string kv_data = kvs.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -950,7 +969,11 @@ void Worker::SendForPush(int cmd, const KVMessage &send, const KVPartitioner &pa rank_ids.push_back(i); std::string kv_data = messages.at(i).second.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { @@ -977,7 +1000,11 @@ void Worker::SendForPull(int cmd, const KVMessage &send, const KVPartitioner &pa rank_ids.push_back(i); std::string kv_data = messages.at(i).second.SerializeAsString(); +#ifdef __APPLE__ + std::shared_ptr res(new unsigned char[kv_data.length()], std::default_delete()); +#else std::shared_ptr res(new unsigned char[kv_data.length()]); +#endif size_t dest_size = kv_data.length(); int ret = memcpy_s(res.get(), dest_size, kv_data.data(), kv_data.length()); if (ret != 0) { diff --git a/mindspore/ccsrc/runtime/device/kernel_runtime.cc b/mindspore/ccsrc/runtime/device/kernel_runtime.cc index 69de9d34d05..eee718876b4 100644 --- a/mindspore/ccsrc/runtime/device/kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/kernel_runtime.cc @@ -33,7 +33,7 @@ #include "frontend/parallel/context.h" #include "debug/env_config_parser.h" #include "pipeline/pynative/pynative_profiling.h" -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/ps_cache/ps_cache_manager.h" #endif @@ -576,7 +576,7 @@ void KernelRuntime::AssignStaticMemoryInput(const session::KernelGraph &graph) { } add_need_alloc_nodes(input_node); } -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) bool ps_cache_check = false; #endif for (auto &item : need_alloc_nodes) { @@ -590,7 +590,7 @@ void KernelRuntime::AssignStaticMemoryInput(const session::KernelGraph &graph) { continue; } DeviceAddressPtr device_address = nullptr; -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) const std::string ¶m_name = item->fullname_with_scope(); if (ps::ps_cache_instance.IsHashTable(param_name)) { MS_LOG(INFO) << "Parameter(" << param_name << ")" @@ -1598,7 +1598,7 @@ void KernelRuntime::ClearGraphRuntimeResource(uint32_t graph_id) { MS_LOG(INFO) << "Clear graph:" << graph_id << " runtime resource"; } -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) void KernelRuntime::GetFirstPSEmbeddingCache(const session::KernelGraph &graph, AnfNodePtr *const first_cache_input_index, size_t *const first_cache_size) { diff --git a/mindspore/ccsrc/runtime/device/kernel_runtime.h b/mindspore/ccsrc/runtime/device/kernel_runtime.h index 957ef05cd5d..e2714c984b4 100644 --- a/mindspore/ccsrc/runtime/device/kernel_runtime.h +++ b/mindspore/ccsrc/runtime/device/kernel_runtime.h @@ -173,7 +173,7 @@ class KernelRuntime { void RunOpAssignOutputNodeMemory(const ValuePtr &pre_output_value, const session::KernelGraph &graph); void AssignValueNodeTensor(const ValueNodePtr &value_node, const ValuePtr &node_value, size_t output_idx); DeviceAddressPtr PreAssignCNodeMemory(const AnfNodePtr &anf_node, size_t index) const; -#if ((defined ENABLE_CPU) && (!defined _WIN32) && (!defined(__APPLE__))) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) void GetFirstPSEmbeddingCache(const session::KernelGraph &graph, AnfNodePtr *const first_cache_input_index, size_t *const first_cache_size); void CheckIfSupportPSEmbeddingCache(const session::KernelGraph &graph); diff --git a/mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc b/mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc index 5b932519925..5dfe3741c0e 100644 --- a/mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc +++ b/mindspore/ccsrc/runtime/device/kernel_runtime_manager.cc @@ -16,7 +16,7 @@ #include "runtime/device/kernel_runtime_manager.h" #include "utils/log_adapter.h" -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) #include "ps/ps_cache/ps_cache_manager.h" #endif #include "backend/session/pynative_task_manager.h" @@ -26,7 +26,7 @@ namespace device { void KernelRuntimeManager::ClearRuntimeResource() { // Just remove PyNative tasks before runtime resource release. session::PynativeTaskManager::GetInstance().Reset(); -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_worker() && ps::PsDataPrefetch::GetInstance().cache_enable()) { ps::ps_cache_instance.SyncEmbeddingTable(); } @@ -132,7 +132,7 @@ void KernelRuntimeManager::ReleaseKernelRuntime(const std::string &device_name, if (runtime == nullptr) { return; } -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_worker() && ps::PsDataPrefetch::GetInstance().cache_enable()) { ps::ps_cache_instance.SyncEmbeddingTable(); } diff --git a/mindspore/ccsrc/runtime/framework/actor/super_kernel_actor.cc b/mindspore/ccsrc/runtime/framework/actor/super_kernel_actor.cc index 024b9d59b7b..7c3da194d37 100644 --- a/mindspore/ccsrc/runtime/framework/actor/super_kernel_actor.cc +++ b/mindspore/ccsrc/runtime/framework/actor/super_kernel_actor.cc @@ -67,7 +67,7 @@ void SuperKernelActor::Run(OpContext *const context) { MS_LOG(INFO) << "Super kernel actor(" << GetAID().Name() << ") launches graph: " << std::to_string(graph_->graph_id()); if (!CopyInputData(context)) { - std::string error_info = "Copy the input data failed, graph id: " + graph_->graph_id(); + std::string error_info = "Copy the input data failed, graph id: " + std::to_string(graph_->graph_id()); SET_OPCONTEXT_FAIL_RET_WITH_ERROR((*context), error_info); } diff --git a/mindspore/ccsrc/vm/transform.cc b/mindspore/ccsrc/vm/transform.cc index a5b7511acf8..54eb336a0d2 100644 --- a/mindspore/ccsrc/vm/transform.cc +++ b/mindspore/ccsrc/vm/transform.cc @@ -632,7 +632,7 @@ void SetMindRTEnable() { return; #endif -#if ((defined ENABLE_CPU) && (!defined _WIN32) && !defined(__APPLE__)) +#if ((defined ENABLE_CPU) && (!defined _WIN32)) if (ps::PSContext::instance()->is_ps_mode()) { return; } diff --git a/mindspore/dataset/__init__.py b/mindspore/dataset/__init__.py index 9bb4d6a71a2..5cd7640e219 100644 --- a/mindspore/dataset/__init__.py +++ b/mindspore/dataset/__init__.py @@ -31,15 +31,13 @@ Common imported modules in corresponding API examples are as follows: from mindspore.dataset.transforms import c_transforms """ -import platform from .core import config from .engine import * from .engine.cache_client import DatasetCache from .engine.datasets import * +from .engine.graphdata import GraphData from .engine.samplers import * from .engine.serializer_deserializer import compare, deserialize, serialize, show -if platform.system().lower() != "darwin": - from .engine.graphdata import GraphData __all__ = [] __all__.extend(engine.__all__) diff --git a/mindspore/dataset/engine/__init__.py b/mindspore/dataset/engine/__init__.py index 67fff2bc0c8..ac104f232df 100644 --- a/mindspore/dataset/engine/__init__.py +++ b/mindspore/dataset/engine/__init__.py @@ -22,23 +22,19 @@ high performance and parse data precisely. It also provides the following operations for users to preprocess data: shuffle, batch, repeat, map, and zip. """ -import platform from ..callback import DSCallback, WaitedDSCallback from ..core import config from .cache_client import DatasetCache from .datasets import * +from .graphdata import GraphData, SamplingStrategy, OutputFormat from .iterators import * from .samplers import * from .serializer_deserializer import compare, deserialize, serialize, show -if platform.system().lower() != "darwin": - from .graphdata import GraphData, SamplingStrategy, OutputFormat __all__ = ["CelebADataset", "Cifar100Dataset", "Cifar10Dataset", "CLUEDataset", "CocoDataset", "CSVDataset", - "GeneratorDataset", "ImageFolderDataset", "ManifestDataset", "MindDataset", "MnistDataset", + "GeneratorDataset", "GraphData", "ImageFolderDataset", "ManifestDataset", "MindDataset", "MnistDataset", "NumpySlicesDataset", "PaddedDataset", "TextFileDataset", "TFRecordDataset", "VOCDataset", "DistributedSampler", "PKSampler", "RandomSampler", "SequentialSampler", "SubsetRandomSampler", "WeightedRandomSampler", "SubsetSampler", "DatasetCache", "DSCallback", "Schema", "WaitedDSCallback", "compare", "deserialize", "serialize", "show", "zip"] -if platform.system().lower() != "darwin": - __all__.append("GraphData") diff --git a/third_party/patch/grpc/grpc.patch001 b/third_party/patch/grpc/grpc.patch001 index 608c5a54124..febcea97e72 100644 --- a/third_party/patch/grpc/grpc.patch001 +++ b/third_party/patch/grpc/grpc.patch001 @@ -1,15 +1,21 @@ diff -Npur grpc/..rej grpc-patch/..rej --- grpc/..rej 1970-01-01 08:00:00.000000000 +0800 +++ grpc-patch/..rej 2021-04-22 21:00:17.343178600 +0800 -@@ -0,0 +1,22 @@ +@@ -0,0 +1,28 @@ +--- CMakeLists.txt 2020-02-27 03:12:33.000000000 +0800 ++++ CMakeLists.txt 2021-04-07 21:27:12.317207600 +0800 -+@@ -12992,7 +12992,7 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP ++@@ -12992,7 +12992,13 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP + add_executable(grpc_cpp_plugin + src/compiler/cpp_plugin.cc + ) +- -++set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) +++if(CMAKE_SYSTEM_NAME MATCHES "Darwin") +++ set(CMAKE_MACOSX_RPATH 1) +++ set(CMAKE_INSTALL_RPATH "@executable_path/../lib") +++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}") +++else() +++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) +++endif() + target_include_directories(grpc_cpp_plugin + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} @@ -27,15 +33,21 @@ diff -Npur grpc/..rej grpc-patch/..rej diff -Npur grpc/.rej grpc-patch/.rej --- grpc/.rej 1970-01-01 08:00:00.000000000 +0800 +++ grpc-patch/.rej 2021-04-22 21:03:38.192349100 +0800 -@@ -0,0 +1,22 @@ +@@ -0,0 +1,28 @@ +--- grpc/CMakeLists.txt 2020-02-27 03:12:33.000000000 +0800 ++++ grpc-patch/CMakeLists.txt 2021-04-07 21:27:12.317207600 +0800 -+@@ -12992,7 +12992,7 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP ++@@ -12992,7 +12992,13 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP + add_executable(grpc_cpp_plugin + src/compiler/cpp_plugin.cc + ) +- -++set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) +++if(CMAKE_SYSTEM_NAME MATCHES "Darwin") +++ set(CMAKE_MACOSX_RPATH 1) +++ set(CMAKE_INSTALL_RPATH "@executable_path/../lib") +++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}") +++else() +++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) +++endif() + target_include_directories(grpc_cpp_plugin + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} @@ -107,12 +119,18 @@ diff -Npur grpc/CMakeLists.txt grpc-patch/CMakeLists.txt if(WIN32 AND MSVC) set_target_properties(upb PROPERTIES COMPILE_PDB_NAME "upb" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" -@@ -12992,7 +13004,7 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP +@@ -12992,7 +13004,13 @@ if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRP add_executable(grpc_cpp_plugin src/compiler/cpp_plugin.cc ) - -+set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) ++if(CMAKE_SYSTEM_NAME MATCHES "Darwin") ++ set(CMAKE_MACOSX_RPATH 1) ++ set(CMAKE_INSTALL_RPATH "@executable_path/../lib") ++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}") ++else() ++ set_target_properties(grpc_cpp_plugin PROPERTIES INSTALL_RPATH $ORIGIN/../lib) ++endif() target_include_directories(grpc_cpp_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/third_party/patch/libevent/libevent.patch001 b/third_party/patch/libevent/libevent.patch001 index 7686d8eba31..ad8a3105de9 100644 --- a/third_party/patch/libevent/libevent.patch001 +++ b/third_party/patch/libevent/libevent.patch001 @@ -10,3 +10,8 @@ diff -Npur libevent/CMakeLists.txt libevent-modify/CMakeLists.txt endif() if (NOT EVENT__DISABLE_THREAD_SUPPORT) +diff -Npur libevent/cmake/AddEventLibrary.cmake libevent-modify/cmake/AddEventLibrary.cmake +--- libevent/cmake/AddEventLibrary.cmake 2020-07-05 20:02:46.000000000 +0800 ++++ libevent-modify/cmake/AddEventLibrary.cmake 2021-04-19 16:36:57.982307500 +0800 +@@ -153,1 +153,0 @@ +- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"