Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkl CI config #4529

Merged
merged 3 commits into from Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .ci/ci.yml
Expand Up @@ -132,13 +132,24 @@ jobs:
ccacheDir: '$(build.binariesDirectory)/ccache'
ccacheArtifactName: 'ccache-macos'
ccacheArchive: '$(Build.ArtifactStagingDirectory)/ccache-$(Build.BuildId).tar'
commonMacOSCMakeFlags: '-DBUILD_EXAMPLES=OFF -DBUNDLE_JSON=OFF -DBUNDLE_NLOPT=OFF -DENABLE_TESTING=ON -DENABLE_COVERAGE=OFF -DBUILD_META_EXAMPLES=OFF'

pool:
vmImage: xcode9-macos10.13

steps:
- template: ./macos-steps.yml

strategy:
maxParallel: 2
matrix:
ACCELERATE:
use_mkl: false
cmakeOptions: '$(commonMacOSCMakeFlags)'
MKL:
use_mkl: true
cmakeOptions: '$(commonMacOSCMakeFlags) -DBLAS_LIBRARIES=$(CONDA)/lib/libmkl_core.dylib -DLAPACK_LIBRARIES=$(CONDA)/lib/libmkl_core.dylib -DBLA_VENDOR=Intel'

- job: windows_libshogun
displayName: Windows
timeoutInMinutes: 120
Expand Down
10 changes: 7 additions & 3 deletions .ci/macos-steps.yml
Expand Up @@ -11,7 +11,7 @@ steps:
- template: ./download-extract.yml
parameters:
name: 'CCache'
artifactName: $(ccacheArtifactName)
artifactName: $(ccacheArtifactName)-$(use_mkl)
destinationFolder: $(ccacheDir)
downloadPath: $(build.binariesDirectory)

Expand All @@ -20,10 +20,14 @@ steps:
brew install ccache pkg-config arpack eigen glpk hdf5 json-c lapack lzo nlopt snappy xz
displayName: Install dependencies

- script: sudo $(CONDA)/bin/conda install mkl-devel -y -q
condition: eq(variables['use_mkl'], 'true')
displayName: Install MKL

- task: CMake@1
displayName: Setup
inputs:
cmakeArgs: -DBUILD_EXAMPLES=OFF -DBUNDLE_JSON=OFF -DBUNDLE_NLOPT=OFF -DENABLE_TESTING=ON -DENABLE_COVERAGE=OFF -DBUILD_META_EXAMPLES=OFF ..
cmakeArgs: $(cmakeOptions) ..

- script: make -j4
displayName: Build
Expand All @@ -40,4 +44,4 @@ steps:
name: 'CCache'
dir: $(ccacheDir)
archive: $(ccacheArchive)
artifactName: $(ccacheArtifactName)
artifactName: $(ccacheArtifactName)-$(use_mkl)
5 changes: 3 additions & 2 deletions cmake/ShogunFindLAPACK.cmake
Expand Up @@ -38,7 +38,7 @@ IF (LAPACK_FOUND)
endif()
endif()
endif()
ELSEIF("${LAPACK_LIBRARIES}" MATCHES ".*/.*mkl_.*")
ELSEIF(EXISTS "${LAPACK_LIBRARIES}" AND "${LAPACK_LIBRARIES}" MATCHES ".*/.*mkl_.*")
# in case MKL is available enable Eigen to use it.
# for more fine grained control and details see:
# https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html
Expand Down Expand Up @@ -66,14 +66,15 @@ IF (LAPACK_FOUND)
ENDIF()

IF (ENABLE_EIGEN_LAPACK)
FIND_PATH(MKL_INCLUDE_DIR mkl.h)
FIND_PATH(MKL_INCLUDE_DIR mkl.h HINTS ${MKL_PATH}/../include/)
IF(NOT MKL_INCLUDE_DIR)
MESSAGE(STATUS "Found MKL, but not mkl.h. Make sure that mkl headers are available in order to use MKL as BLAS/Lapack backend for Eigen.")
SET(ENABLE_EIGEN_LAPACK OFF CACHE BOOL "Use ${ENABLE_EIGEN_LAPACK}" FORCE)
ELSE()
MESSAGE(STATUS "Enabling MKL as BLAS/Lapack backend for Eigen.")
SET(EIGEN_USE_MKL_ALL 1)
target_include_directories(shogun PUBLIC ${MKL_INCLUDE_DIR})
target_include_directories(libshogun PRIVATE ${MKL_INCLUDE_DIR})
IF (LIBSHOGUN_BUILD_STATIC)
target_include_directories(shogun-static PUBLIC ${MKL_INCLUDE_DIR})
ENDIF()
Expand Down
7 changes: 5 additions & 2 deletions src/shogun/converter/ica/SOBI.cpp
Expand Up @@ -66,8 +66,11 @@ void CSOBI::fit_dense(CDenseFeatures<float64_t>* features)
MatrixXd M0 = cor(EX,int(m_tau[0]));
EigenSolver<MatrixXd> eig;
eig.compute(M0);
MatrixXd SPH = (eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix().cwiseSqrt() * eig.pseudoEigenvectors ().transpose()).inverse();
MatrixXd spx = SPH*EX;
MatrixXd EVMsqrt = eig.pseudoEigenvalueMatrix().cwiseSqrt();
MatrixXd SPH = (eig.pseudoEigenvectors() * EVMsqrt *
eig.pseudoEigenvectors().transpose())
.inverse();
MatrixXd spx = SPH * EX;

// Compute Correlation Matrices
index_t * M_dims = SG_MALLOC(index_t, 3);
Expand Down
7 changes: 4 additions & 3 deletions src/shogun/machine/gp/LogitVGPiecewiseBoundLikelihood.cpp
Expand Up @@ -502,11 +502,12 @@ void CLogitVGPiecewiseBoundLikelihood::precompute()

float64_t h_bak = eigen_h(eigen_h.size()-1);
eigen_h(eigen_h.size()-1) = 0;

//bsxfun(@plus, l.^2, v)
eigen_l2_plus_s2 = (eigen_s2.replicate(1,eigen_l.rows()).array().transpose().colwise() + eigen_l.array().pow(2)).matrix();
VectorXd epl_pow = eigen_l.array().pow(2);
VectorXd eph_pow = eigen_h.array().pow(2);
eigen_l2_plus_s2 = (eigen_s2.replicate(1,eigen_l.rows()).array().transpose().colwise() + epl_pow.array()).matrix();
//bsxfun(@plus, h.^2, v)
eigen_h2_plus_s2 = (eigen_s2.replicate(1,eigen_h.rows()).array().transpose().colwise() + eigen_h.array().pow(2)).matrix();
eigen_h2_plus_s2 = (eigen_s2.replicate(1,eigen_h.rows()).array().transpose().colwise() + eph_pow.array()).matrix();
//pl.*l - ph.*h
eigen_weighted_pdf_diff = (eigen_pl.array().colwise() * eigen_l.array() - eigen_ph.array().colwise() * eigen_h.array()).matrix();

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/mathematics/Statistics.cpp
Expand Up @@ -605,7 +605,7 @@ float64_t CStatistics::log_det_general(const SGMatrix<float64_t> A)
{
Map<MatrixXd> eigen_A(A.matrix, A.num_rows, A.num_cols);
REQUIRE(eigen_A.rows()==eigen_A.cols(),
"Input matrix should be a sqaure matrix row(%d) col(%d)\n",
"Input matrix should be a square matrix row(%d) col(%d)\n",
eigen_A.rows(), eigen_A.cols());

PartialPivLU<MatrixXd> lu(eigen_A);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/features/iterators/DotIterator_unittest.cc
Expand Up @@ -92,5 +92,5 @@ TEST(DotIterator, add)
}

for (i = 0; i < vec.vlen; ++i)
EXPECT_EQ(vec[i], res[i]);
EXPECT_NEAR(vec[i], res[i], 1E-12);
}
28 changes: 14 additions & 14 deletions tests/unit/preprocessor/FisherLDA_unittest.cc
Expand Up @@ -152,26 +152,26 @@ TEST_F(FLDATest, CANVAR_FLDA_Unit_test)
float64_t epsilon=0.00000000001;

// comparing projection outputs against Matlab 'CannonVar' implementation
EXPECT_NEAR(+51.3760082238439111, y(0,0), epsilon);
EXPECT_NEAR(-56.4869601858493127, y(0,1), epsilon);
EXPECT_NEAR(-63.3150724246548862, y(0,2), epsilon);
EXPECT_NEAR(+75.1693851132601338, y(0,3), epsilon);
EXPECT_NEAR( 0.00000000000000000, y(0,4), epsilon);
EXPECT_NEAR(+87.4243337392790067, y(0,5), epsilon);
EXPECT_NEAR(-114.092258182259556, y(0,6), epsilon);
EXPECT_NEAR(-94.010102920274619, y(0,7), epsilon);
EXPECT_NEAR(-66.5754164410987244, y(0,8), epsilon);
EXPECT_NEAR(-109.483855254332568, y(0,9), epsilon);
EXPECT_NEAR(+27.5378037199449182, y(0,10), epsilon);
EXPECT_NEAR(-158.649815592855759, y(0,11), epsilon);
EXPECT_NEAR(51.3760082238439111, std::abs(y(0,0)), epsilon);
EXPECT_NEAR(56.4869601858493127, std::abs(y(0,1)), epsilon);
EXPECT_NEAR(63.3150724246548862, std::abs(y(0,2)), epsilon);
EXPECT_NEAR(75.1693851132601338, std::abs(y(0,3)), epsilon);
EXPECT_NEAR(0.00000000000000000, std::abs(y(0,4)), epsilon);
EXPECT_NEAR(87.4243337392790067, std::abs(y(0,5)), epsilon);
EXPECT_NEAR(114.092258182259556, std::abs(y(0,6)), epsilon);
EXPECT_NEAR(94.010102920274619, std::abs(y(0,7)), epsilon);
EXPECT_NEAR(66.5754164410987244, std::abs(y(0,8)), epsilon);
EXPECT_NEAR(109.483855254332568, std::abs(y(0,9)), epsilon);
EXPECT_NEAR(27.5378037199449182, std::abs(y(0,10)), epsilon);
EXPECT_NEAR(158.649815592855759, std::abs(y(0,11)), epsilon);

// comparing eigenvectors from the transformation_matrix with that from the
// 'CannonVar' implementation.
SGMatrix<float64_t> transformy=fisherlda.get_transformation_matrix();
EXPECT_NEAR(0.576749097670396393, std::abs(transformy[0]), epsilon);
EXPECT_NEAR(0.158373354160231516, std::abs(transformy[1]), epsilon);
EXPECT_NEAR(0.47693388209865617, std::abs(transformy[2]), epsilon);
EXPECT_NEAR(0.64405933820939687, std::abs(transformy[3]), epsilon);
EXPECT_NEAR(0.47693388209865617, std::abs(transformy[2]), epsilon);
EXPECT_NEAR(0.64405933820939687, std::abs(transformy[3]), epsilon);

SG_UNREF(dense_feat);
SG_UNREF(labels);
Expand Down