diff --git a/build.bat b/build.bat index 07f9676a1a2..f7c3c6c2ead 100644 --- a/build.bat +++ b/build.bat @@ -48,6 +48,15 @@ IF %errorlevel% == 0 ( echo "use mingw compiler" ) +set USE_SCCACHE=off +where sccache +IF %errorlevel% == 0 ( + set USE_SCCACHE=on + echo "use sccache to speed up compilation" +) ELSE ( + echo "sccache doesn't exist" +) + IF NOT EXIST "%BUILD_PATH%" ( md "build" ) @@ -71,18 +80,21 @@ IF "%1%" == "lite" ( ) ELSE ( IF "%1%" == "ms_vs_gpu" ( echo "======Start gen VS2019 Project for MS gpu ======" - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_GPU=ON -DGPU_BACKEND_CUDA=ON -DMS_REQUIRE_CUDA_VERSION=11.1 -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ - -G "Visual Studio 16 2019" -A x64 ../.. + for /f "delims=" %%i in ('powershell.exe -ExecutionPolicy Bypass -Command "Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | foreach { Get-ItemProperty $_.PsPath } | where { $_.DisplayName -like '*Visual Studio*' -and $_.InstallLocation.Length -gt 0 } | sort InstallDate -Descending | foreach { Join-Path $_.InstallLocation 'VC\Auxiliary\Build'}"') do (call "%%i\vcvars64.bat") + IF %USE_SCCACHE% == on ( + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CUDA_COMPILER_LAUNCHER=sccache -DENABLE_CPU=ON -DENABLE_GPU=ON -DGPU_BACKEND_CUDA=ON -DMS_REQUIRE_CUDA_VERSION=11.1 -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ + -G Ninja ../.. + ) ELSE ( + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_GPU=ON -DGPU_BACKEND_CUDA=ON -DMS_REQUIRE_CUDA_VERSION=11.1 -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ + -G Ninja ../.. + ) ) ELSE IF "%1%" == "ms_vs_cpu" ( echo "======Start gen VS2019 Project for MS cpu ======" for /f "delims=" %%i in ('powershell.exe -ExecutionPolicy Bypass -Command "Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | foreach { Get-ItemProperty $_.PsPath } | where { $_.DisplayName -like '*Visual Studio*' -and $_.InstallLocation.Length -gt 0 } | sort InstallDate -Descending | foreach { Join-Path $_.InstallLocation 'VC\Auxiliary\Build'}"') do (call "%%i\vcvars64.bat") - where sccache - IF !errorlevel! == 0 ( - echo "use sccache to speed up compile" + IF %USE_SCCACHE% == on ( cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ -G Ninja ../.. ) ELSE ( - echo "fail to find sccache" cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ -G Ninja ../.. ) diff --git a/mindspore/ccsrc/plugin/device/gpu/kernel/cuda_impl/CMakeLists.txt b/mindspore/ccsrc/plugin/device/gpu/kernel/cuda_impl/CMakeLists.txt index 93200fd4d47..6dbcf4dd38b 100644 --- a/mindspore/ccsrc/plugin/device/gpu/kernel/cuda_impl/CMakeLists.txt +++ b/mindspore/ccsrc/plugin/device/gpu/kernel/cuda_impl/CMakeLists.txt @@ -33,7 +33,17 @@ if(ENABLE_GPU) else() target_compile_options(cuda_common_obj PRIVATE "/std:c++17") endif() - cuda_add_library(cuda_ops SHARED ${CUDA_OPS_SRC_LIST} $) + if(WIN32) + list(JOIN CUDA_NVCC_FLAGS " " tmp_nvcc_flags) + # CUDA_NVCC_FLAGS is not valid for add_library(), use CMAKE_CUDA_FLAGS instead. + string(APPEND CMAKE_CUDA_FLAGS " ${tmp_nvcc_flags}") + add_compile_definitions(_ENABLE_EXTENDED_ALIGNED_STORAGE) + # cuda_add_library() doesn't support ccache or sccache and it is deprecated for cmake v3.10+ + add_library(cuda_ops SHARED ${CUDA_OPS_SRC_LIST} $) + else() + cuda_add_library(cuda_ops SHARED ${CUDA_OPS_SRC_LIST} $) + endif() + if(NOT BUILD_LITE) set_target_properties(cuda_ops PROPERTIES SOVERSION ${CUDA_VERSION_MAJOR}) endif()