diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index 1aab0d9cd1..ff6f43f314 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -5,10 +5,10 @@ resources: containers: - container: CentosContainer - image: microsoft/dotnet-buildtools-prereqs:centos-7-b46d863-20180719033416 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-mlnet-8bba86b-20190314145033 - container: UbuntuContainer - image: microsoft/dotnet-buildtools-prereqs:ubuntu-16.04-10fcdcf-20190208200917 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-mlnet-207e097-20190312152303 phases: - template: /build/ci/phase-template.yml diff --git a/build/Dependencies.props b/build/Dependencies.props index bce591d4ef..a748124053 100644 --- a/build/Dependencies.props +++ b/build/Dependencies.props @@ -15,7 +15,7 @@ 3.5.1 2.2.3 0.2.1 - 0.0.0.7 + 0.0.0.9 2.1.3 4.5.0 4.5.0 diff --git a/build/ci/phase-template.yml b/build/ci/phase-template.yml index e0818c796f..cdb4928dbb 100644 --- a/build/ci/phase-template.yml +++ b/build/ci/phase-template.yml @@ -33,13 +33,13 @@ phases: ${{ insert }}: ${{ parameters.customMatrixes }} ${{ insert }}: ${{ parameters.queue }} steps: + - ${{ if eq(parameters.name, 'MacOS') }}: + - script: brew update && brew install libomp && brew install mono-libgdiplus gettext && brew link gettext --force && brew link libomp --force + displayName: Install build dependencies - script: $(_buildScript) -$(_configuration) -buildArch=$(_arch) displayName: Build - script: $(_buildScript) -- /t:DownloadExternalTestFiles /p:IncludeBenchmarkData=$(_includeBenchmarkData) displayName: Download Benchmark Data - - ${{ if eq(parameters.name, 'MacOS') }}: - - script: brew update && brew install libomp mono-libgdiplus gettext && brew link gettext --force - displayName: Install runtime dependencies - script: $(_buildScript) -$(_configuration) -runtests -coverage=$(_codeCoverage) displayName: Run Tests. - script: $(Build.SourcesDirectory)/Tools/dotnetcli/dotnet msbuild build/Codecoverage.proj /p:CodeCovToken=$(CODECOV_TOKEN) diff --git a/build/vsts-ci.yml b/build/vsts-ci.yml index 2ec9cfe0ae..078f835f97 100644 --- a/build/vsts-ci.yml +++ b/build/vsts-ci.yml @@ -5,7 +5,7 @@ resources: containers: - container: CentosContainer - image: microsoft/dotnet-buildtools-prereqs:centos-7-b46d863-20180719033416 + image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-mlnet-8bba86b-20190314145033 phases: ################################################################################ @@ -48,6 +48,8 @@ phases: demands: - agent.os -equals Darwin steps: + - script: brew update && brew install libomp && brew link libomp --force + displayName: Install build dependencies # Only build native assets to avoid conflicts. - script: ./build.sh -buildNative -$(BuildConfig) -skipRIDAgnosticAssets displayName: Build diff --git a/src/Microsoft.ML.Console/Microsoft.ML.Console.csproj b/src/Microsoft.ML.Console/Microsoft.ML.Console.csproj index 2d8eb66be0..5972806b62 100644 --- a/src/Microsoft.ML.Console/Microsoft.ML.Console.csproj +++ b/src/Microsoft.ML.Console/Microsoft.ML.Console.csproj @@ -31,8 +31,11 @@ + - + + + diff --git a/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs b/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs index 6f37cdc847..9e18e6b306 100644 --- a/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs +++ b/src/Microsoft.ML.Mkl.Components/SymSgdClassificationTrainer.cs @@ -43,7 +43,7 @@ public sealed class Options : TrainerInputBaseWithLabel { /// /// Degree of lock-free parallelism. Determinism not guaranteed if this is set to higher than 1. - /// Multi-threading is not supported currently. + /// The default value is the number of logical cores that are available on the system. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Degree of lock-free parallelism. Determinism not guaranteed. " + "Multi-threading is not supported currently.", ShortName = "nt")] @@ -662,7 +662,8 @@ private TPredictor TrainCore(IChannel ch, RoleMappedData data, LinearModelParame { int numFeatures = data.Schema.Feature.Value.Type.GetVectorSize(); var cursorFactory = new FloatLabelCursor.Factory(data, CursOpt.Label | CursOpt.Features); - int numThreads = 1; + int numThreads = _options.NumberOfThreads ?? Environment.ProcessorCount; + ch.CheckUserArg(numThreads > 0, nameof(_options.NumberOfThreads), "The number of threads must be either null or a positive integer."); diff --git a/src/Native/SymSgdNative/CMakeLists.txt b/src/Native/SymSgdNative/CMakeLists.txt index 4bbf9f69d6..80665883b9 100644 --- a/src/Native/SymSgdNative/CMakeLists.txt +++ b/src/Native/SymSgdNative/CMakeLists.txt @@ -1,13 +1,31 @@ project (SymSgdNative) + set(SOURCES SymSgdNative.cpp ) -find_library(MKL_LIBRARY MklImports HINTS ${MKL_LIB_PATH}) -if(NOT WIN32) +if(APPLE) + # CMake has support for OpenMP, however, Apple has a version of Clang + # that does not support openMP out of the box. Therefore + # these commands are added to sepcifically handle the Apple Clang scenario + # If the LLVM version of clang is used for Apple builds, this can be removed + # and the else condition can be used instead. + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp") + SET(OPENMP_LIBRARY "omp") + include_directories("/usr/local/opt/libomp/include") + link_directories("/usr/local/opt/libomp/lib") + list(APPEND SOURCES ${VERSION_FILE_PATH}) - if(NOT APPLE) +else() + find_package(OpenMP) + if (OPENMP_FOUND) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + endif() + + if (NOT WIN32) + list(APPEND SOURCES ${VERSION_FILE_PATH}) SET(CMAKE_SKIP_BUILD_RPATH FALSE) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -15,11 +33,14 @@ if(NOT WIN32) endif() endif() +find_library(MKL_LIBRARY MklImports HINTS ${MKL_LIB_PATH}) + +add_definitions(-DUSE_OMP) add_library(SymSgdNative SHARED ${SOURCES} ${RESOURCES}) -target_link_libraries(SymSgdNative PUBLIC ${MKL_LIBRARY}) +target_link_libraries(SymSgdNative PUBLIC ${MKL_LIBRARY} PUBLIC ${OPENMP_LIBRARY}) if(APPLE) set_target_properties(SymSgdNative PROPERTIES INSTALL_RPATH "@loader_path;@loader_path/${MKL_LIB_RPATH}}") endif() -install_library_and_symbols (SymSgdNative) \ No newline at end of file +install_library_and_symbols (SymSgdNative) diff --git a/src/Native/build.proj b/src/Native/build.proj index 0d12196c26..e6f5e9ea50 100644 --- a/src/Native/build.proj +++ b/src/Native/build.proj @@ -72,7 +72,10 @@ - + + + diff --git a/test/Microsoft.ML.Benchmarks/Microsoft.ML.Benchmarks.csproj b/test/Microsoft.ML.Benchmarks/Microsoft.ML.Benchmarks.csproj index 8d9d4963cb..dd5cbf68f3 100644 --- a/test/Microsoft.ML.Benchmarks/Microsoft.ML.Benchmarks.csproj +++ b/test/Microsoft.ML.Benchmarks/Microsoft.ML.Benchmarks.csproj @@ -24,5 +24,6 @@ + - \ No newline at end of file + diff --git a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj index 1d60c31ad9..889cca84c0 100644 --- a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj +++ b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj @@ -28,11 +28,12 @@ - + + diff --git a/test/Microsoft.ML.Functional.Tests/Microsoft.ML.Functional.Tests.csproj b/test/Microsoft.ML.Functional.Tests/Microsoft.ML.Functional.Tests.csproj index fe8f59ce0f..7fe72d3369 100644 --- a/test/Microsoft.ML.Functional.Tests/Microsoft.ML.Functional.Tests.csproj +++ b/test/Microsoft.ML.Functional.Tests/Microsoft.ML.Functional.Tests.csproj @@ -38,6 +38,7 @@ + diff --git a/test/Microsoft.ML.OnnxTransformerTest/Microsoft.ML.OnnxTransformerTest.csproj b/test/Microsoft.ML.OnnxTransformerTest/Microsoft.ML.OnnxTransformerTest.csproj index db261434bb..6d11c627ee 100644 --- a/test/Microsoft.ML.OnnxTransformerTest/Microsoft.ML.OnnxTransformerTest.csproj +++ b/test/Microsoft.ML.OnnxTransformerTest/Microsoft.ML.OnnxTransformerTest.csproj @@ -30,6 +30,7 @@ + diff --git a/test/Microsoft.ML.Predictor.Tests/Microsoft.ML.Predictor.Tests.csproj b/test/Microsoft.ML.Predictor.Tests/Microsoft.ML.Predictor.Tests.csproj index 281a2c6abe..d92df71aea 100644 --- a/test/Microsoft.ML.Predictor.Tests/Microsoft.ML.Predictor.Tests.csproj +++ b/test/Microsoft.ML.Predictor.Tests/Microsoft.ML.Predictor.Tests.csproj @@ -21,6 +21,7 @@ + diff --git a/test/Microsoft.ML.StaticPipelineTesting/Microsoft.ML.StaticPipelineTesting.csproj b/test/Microsoft.ML.StaticPipelineTesting/Microsoft.ML.StaticPipelineTesting.csproj index 877fc33815..f78940c900 100644 --- a/test/Microsoft.ML.StaticPipelineTesting/Microsoft.ML.StaticPipelineTesting.csproj +++ b/test/Microsoft.ML.StaticPipelineTesting/Microsoft.ML.StaticPipelineTesting.csproj @@ -26,5 +26,6 @@ + diff --git a/test/Microsoft.ML.Sweeper.Tests/Microsoft.ML.Sweeper.Tests.csproj b/test/Microsoft.ML.Sweeper.Tests/Microsoft.ML.Sweeper.Tests.csproj index 1ebd86b042..c8415ff24e 100644 --- a/test/Microsoft.ML.Sweeper.Tests/Microsoft.ML.Sweeper.Tests.csproj +++ b/test/Microsoft.ML.Sweeper.Tests/Microsoft.ML.Sweeper.Tests.csproj @@ -10,5 +10,6 @@ + diff --git a/test/Microsoft.ML.TestFramework/Microsoft.ML.TestFramework.csproj b/test/Microsoft.ML.TestFramework/Microsoft.ML.TestFramework.csproj index 1f13552b00..2b7cc65110 100644 --- a/test/Microsoft.ML.TestFramework/Microsoft.ML.TestFramework.csproj +++ b/test/Microsoft.ML.TestFramework/Microsoft.ML.TestFramework.csproj @@ -19,9 +19,10 @@ - + + diff --git a/test/Microsoft.ML.Tests/FeatureContributionTests.cs b/test/Microsoft.ML.Tests/FeatureContributionTests.cs index 8273f54f6e..3ea59f5e80 100644 --- a/test/Microsoft.ML.Tests/FeatureContributionTests.cs +++ b/test/Microsoft.ML.Tests/FeatureContributionTests.cs @@ -157,14 +157,22 @@ public void TestSDCABinary() public void TestSGDBinary() { TestFeatureContribution(ML.BinaryClassification.Trainers.SgdCalibrated( - new SgdCalibratedTrainer.Options { NumberOfThreads = 1 }), + new SgdCalibratedTrainer.Options() + { + NumberOfThreads = 1 + }), GetSparseDataset(TaskType.BinaryClassification, 100), "SGDBinary"); } [Fact] public void TestSSGDBinary() { - TestFeatureContribution(ML.BinaryClassification.Trainers.SymbolicSgd(), GetSparseDataset(TaskType.BinaryClassification, 100), "SSGDBinary", 4); + TestFeatureContribution(ML.BinaryClassification.Trainers.SymbolicSgd( + new SymbolicSgdTrainer.Options() + { + NumberOfThreads = 1 + }), + GetSparseDataset(TaskType.BinaryClassification, 100), "SSGDBinary", 4); } [Fact] diff --git a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj index 1b7c86830d..2104af700f 100644 --- a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj +++ b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj @@ -38,6 +38,7 @@ + diff --git a/test/Microsoft.ML.TimeSeries.Tests/Microsoft.ML.TimeSeries.Tests.csproj b/test/Microsoft.ML.TimeSeries.Tests/Microsoft.ML.TimeSeries.Tests.csproj index 9b23e12fc9..218978ae86 100644 --- a/test/Microsoft.ML.TimeSeries.Tests/Microsoft.ML.TimeSeries.Tests.csproj +++ b/test/Microsoft.ML.TimeSeries.Tests/Microsoft.ML.TimeSeries.Tests.csproj @@ -13,5 +13,6 @@ + - \ No newline at end of file +