forked from mindspore-Ecosystem/mindspore
!41433 support for msvc
Merge pull request !41433 from qiuzhongya/qiuzhongya_msvc1
This commit is contained in:
commit
5afcbb0205
|
@ -446,3 +446,28 @@ function(mindspore_add_pkg pkg_name)
|
|||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(src_separate_compile)
|
||||
set(options)
|
||||
set(oneValueArgs OBJECT_NAME OBJECT_SIZE)
|
||||
set(multiValueArgs SRC_LIST)
|
||||
cmake_parse_arguments(STUDENT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
list(LENGTH STUDENT_SRC_LIST SRC_LIST_SIZE)
|
||||
|
||||
set(SEPARATE_SIZE 100)
|
||||
set(SEPARATE_INDEX 0)
|
||||
set(OBJECT_COUNT 0)
|
||||
math(EXPR SRC_LIST_MAX_INDEX "${SRC_LIST_SIZE} - 1")
|
||||
while(${SRC_LIST_SIZE} GREATER ${SEPARATE_INDEX})
|
||||
math(EXPR SEPARATE_END "${SEPARATE_INDEX} + ${SEPARATE_SIZE} - 1")
|
||||
if(${SEPARATE_END} GREATER ${SRC_LIST_MAX_INDEX})
|
||||
math(EXPR SEPARATE_SIZE "${SRC_LIST_SIZE} - ${SEPARATE_INDEX}")
|
||||
endif()
|
||||
list(SUBLIST STUDENT_SRC_LIST ${SEPARATE_INDEX} ${SEPARATE_SIZE} new_sub_list)
|
||||
math(EXPR OBJECT_COUNT "${OBJECT_COUNT} + 1")
|
||||
math(EXPR SEPARATE_INDEX "${SEPARATE_INDEX} + ${SEPARATE_SIZE}")
|
||||
add_library(${STUDENT_OBJECT_NAME}_${OBJECT_COUNT} OBJECT ${new_sub_list})
|
||||
endwhile()
|
||||
set(${STUDENT_OBJECT_SIZE} "${OBJECT_COUNT}" PARENT_SCOPE)
|
||||
message("${STUDENT_OBJECT_SIZE} object count is ${OBJECT_COUNT}")
|
||||
endfunction()
|
|
@ -389,7 +389,6 @@ set(BACKEND_SUB_COMP
|
|||
plugin/device/cpu/hal/device
|
||||
plugin/device/cpu/hal/hardware
|
||||
plugin/device/cpu/hal/profiler
|
||||
plugin/device/cpu/kernel
|
||||
plugin/device/cpu/optimizer
|
||||
)
|
||||
|
||||
|
@ -405,6 +404,18 @@ foreach(_comp ${BACKEND_SUB_COMP})
|
|||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CPU_KERNEL_OBJECT_COUNT 0)
|
||||
add_subdirectory(plugin/device/cpu/kernel)
|
||||
foreach(number RANGE 1 ${CPU_KERNEL_OBJECT_COUNT})
|
||||
if(TARGET _mindspore_plugin_device_cpu_kernel_obj_${number})
|
||||
list(APPEND BACKEND_SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_plugin_device_cpu_kernel_obj_${number}>)
|
||||
add_dependencies(_mindspore_plugin_device_cpu_kernel_obj_${number} proto_input)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
target_compile_definitions(_mindspore_plugin_device_cpu_kernel_obj_${number} PRIVATE BACKEND_DLL)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(ENABLE_TEST OR ENABLE_TESTCASES)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
list(APPEND STUB_BACKEND_SOURCE ${CMAKE_SOURCE_DIR}/tests/ut/cpp/stub/ps/ps_core_stub.cc)
|
||||
|
|
|
@ -47,8 +47,14 @@ if(ENABLE_AKG AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND ENABLE_CPU)
|
|||
)
|
||||
endif()
|
||||
|
||||
set_property(SOURCE ${CPU_SRC_LIST} ${AKG_CPU_SRC_LIST}
|
||||
set(CPU_SRC_LIST ${CPU_SRC_LIST} ${AKG_CPU_SRC_LIST})
|
||||
set_property(SOURCE ${CPU_SRC_LIST}
|
||||
PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_KERNEL)
|
||||
if(ENABLE_CPU)
|
||||
add_library(_mindspore_plugin_device_cpu_kernel_obj OBJECT ${CPU_SRC_LIST} ${AKG_CPU_SRC_LIST})
|
||||
set(CPU_OBJECT_COUNT 1)
|
||||
src_separate_compile(
|
||||
OBJECT_NAME _mindspore_plugin_device_cpu_kernel_obj
|
||||
OBJECT_SIZE CPU_OBJECT_COUNT
|
||||
SRC_LIST ${CPU_SRC_LIST})
|
||||
set(CPU_KERNEL_OBJECT_COUNT "${CPU_OBJECT_COUNT}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
|
|
@ -69,11 +69,22 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|||
-Wno-unused-private-field")
|
||||
endif()
|
||||
|
||||
set(CORE_OBJECT_COUNT 1)
|
||||
|
||||
set_property(SOURCE ${CORE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_CORE)
|
||||
add_library(core_proto_obj OBJECT ${PROTO_SRCS})
|
||||
add_library(core_obj OBJECT ${CORE_SRC_LIST})
|
||||
add_dependencies(core_obj core_proto_obj)
|
||||
add_library(mindspore_core SHARED $<TARGET_OBJECTS:core_obj> $<TARGET_OBJECTS:core_proto_obj>)
|
||||
list(APPEND CORE_OBJECT_LIST $<TARGET_OBJECTS:core_proto_obj>)
|
||||
|
||||
src_separate_compile(
|
||||
OBJECT_NAME core_obj
|
||||
OBJECT_SIZE CORE_OBJECT_COUNT
|
||||
SRC_LIST ${CORE_SRC_LIST})
|
||||
foreach(number RANGE 1 ${CORE_OBJECT_COUNT})
|
||||
list(APPEND CORE_OBJECT_LIST $<TARGET_OBJECTS:core_obj_${number}>)
|
||||
add_dependencies(core_obj_${number} core_proto_obj)
|
||||
endforeach()
|
||||
|
||||
add_library(mindspore_core SHARED ${CORE_OBJECT_LIST})
|
||||
target_link_libraries(mindspore_core PRIVATE mindspore::protobuf securec)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT BUILD_LITE)
|
||||
|
|
|
@ -268,10 +268,16 @@ list(REMOVE_ITEM MINDSPORE_SRC_LIST
|
|||
add_library(_ut_mindspore_obj OBJECT ${MINDSPORE_SRC_LIST})
|
||||
add_library(_ut_ut_obj OBJECT ${UT_SRCS})
|
||||
add_dependencies(_ut_ut_obj engine-cache-server)
|
||||
set(ut_objects $<TARGET_OBJECTS:_ut_ut_obj> $<TARGET_OBJECTS:_ut_mindspore_obj>
|
||||
$<TARGET_OBJECTS:core_obj> $<TARGET_OBJECTS:core_proto_obj> $<TARGET_OBJECTS:mindrt_mid>
|
||||
|
||||
foreach(number RANGE 1 9)
|
||||
list(APPEND CORE_OBJECT_LIST $<TARGET_OBJECTS:core_obj_${number}>)
|
||||
endforeach()
|
||||
|
||||
set(ut_objects ${CORE_OBJECT_LIST} $<TARGET_OBJECTS:_ut_ut_obj> $<TARGET_OBJECTS:_ut_mindspore_obj>
|
||||
$<TARGET_OBJECTS:core_proto_obj> $<TARGET_OBJECTS:mindrt_mid>
|
||||
$<TARGET_OBJECTS:mindspore_shared_lib_obj> $<TARGET_OBJECTS:_mindspore_utils_obj>
|
||||
$<TARGET_OBJECTS:_mindspore_common_obj>)
|
||||
|
||||
if(ENABLE_MINDDATA)
|
||||
set(ut_objects ${ut_objects} ${dataengine_submodules} $<TARGET_OBJECTS:mindrecord_obj>)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue