[arrayfire] 48/75: Fixes for using MKL on OSX

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:01:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit 513e7115b2699f15aff17fafbbd5f9fde38e383c
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Mon Feb 22 16:34:38 2016 -0500

    Fixes for using MKL on OSX
---
 src/backend/cblas.cpp                         |  8 ++++----
 src/backend/cpu/CMakeLists.txt                | 13 +++++++------
 src/backend/cpu/blas.hpp                      | 16 +++++++--------
 src/backend/cpu/lapack_helper.hpp             | 20 +++++++++----------
 src/backend/cuda/CMakeLists.txt               |  9 +++++++--
 src/backend/cuda/cpu_lapack/lapack_helper.hpp | 20 +++++++++----------
 src/backend/opencl/CMakeLists.txt             | 13 +++++++------
 src/backend/opencl/cpu/cpu_helper.hpp         | 28 +++++++++++++--------------
 src/backend/opencl/magma/magma_cpu_blas.h     | 16 +++++++--------
 src/backend/opencl/magma/magma_cpu_lapack.h   | 18 ++++++++++-------
 10 files changed, 86 insertions(+), 75 deletions(-)

diff --git a/src/backend/cblas.cpp b/src/backend/cblas.cpp
index 4d99d45..1be15e4 100644
--- a/src/backend/cblas.cpp
+++ b/src/backend/cblas.cpp
@@ -12,11 +12,11 @@
 #ifdef AF_CPU
     #include <blas.hpp>
 #else
-    #ifdef __APPLE__
-        #include <Accelerate/Accelerate.h>
+    #ifdef USE_MKL
+        #include <mkl_cblas.h>
     #else
-        #ifdef USE_MKL
-            #include <mkl_cblas.h>
+        #ifdef __APPLE__
+            #include <Accelerate/Accelerate.h>
         #else
             extern "C" {
                 #include <cblas.h>
diff --git a/src/backend/cpu/CMakeLists.txt b/src/backend/cpu/CMakeLists.txt
index 8ada1d6..2032f0b 100644
--- a/src/backend/cpu/CMakeLists.txt
+++ b/src/backend/cpu/CMakeLists.txt
@@ -14,9 +14,14 @@ IF(USE_CPU_F77_BLAS)
     ADD_DEFINITIONS(-DUSE_F77_BLAS)
 ENDIF()
 
-IF(USE_CPU_MKL)
-    MESSAGE("Using MKL")
+IF(USE_CPU_MKL) # Manual MKL Setup
+    MESSAGE("CPU Backend Using MKL")
     ADD_DEFINITIONS(-DUSE_MKL)
+ELSE(USE_CPU_MKL)
+    IF(${MKL_FOUND}) # Automatic MKL Setup from BLAS
+        MESSAGE("CPU Backend Using MKL RT")
+        ADD_DEFINITIONS(-DUSE_MKL)
+    ENDIF()
 ENDIF()
 
 IF (NOT CBLAS_LIBRARIES)
@@ -29,10 +34,6 @@ IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND "${APPLE}")
     ADD_DEFINITIONS(-flax-vector-conversions)
 ENDIF()
 
-IF(${MKL_FOUND})
-    ADD_DEFINITIONS(-DUSE_MKL)
-ENDIF()
-
 FIND_PACKAGE(FFTW REQUIRED)
 MESSAGE(STATUS "FFTW Found ? ${FFTW_FOUND}")
 MESSAGE(STATUS "FFTW Library: ${FFTW_LIBRARIES}")
diff --git a/src/backend/cpu/blas.hpp b/src/backend/cpu/blas.hpp
index 0548433..3f5b745 100644
--- a/src/backend/cpu/blas.hpp
+++ b/src/backend/cpu/blas.hpp
@@ -12,16 +12,16 @@
 #include <Array.hpp>
 #include <types.hpp>
 
-#ifdef __APPLE__
-#include <Accelerate/Accelerate.h>
-#else
 #ifdef USE_MKL
-#include <mkl_cblas.h>
+    #include <mkl_cblas.h>
 #else
-extern "C" {
-#include <cblas.h>
-}
-#endif
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+    #else
+        extern "C" {
+            #include <cblas.h>
+        }
+    #endif
 #endif
 
 // TODO: Ask upstream for a more official way to detect it
diff --git a/src/backend/cpu/lapack_helper.hpp b/src/backend/cpu/lapack_helper.hpp
index f978ecb..c5ed4fa 100644
--- a/src/backend/cpu/lapack_helper.hpp
+++ b/src/backend/cpu/lapack_helper.hpp
@@ -17,17 +17,17 @@
 #define AF_LAPACK_COL_MAJOR LAPACK_COL_MAJOR
 #define LAPACK_NAME(fn) LAPACKE_##fn
 
-#ifdef __APPLE__
-#include <Accelerate/Accelerate.h>
-#include <lapacke.hpp>
-#undef AF_LAPACK_COL_MAJOR
-#define AF_LAPACK_COL_MAJOR 0
-#else
 #ifdef USE_MKL
-#include<mkl_lapacke.h>
-#else // NETLIB LAPACKE
-#include<lapacke.h>
-#endif
+    #include<mkl_lapacke.h>
+#else
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+        #include <lapacke.hpp>
+        #undef AF_LAPACK_COL_MAJOR
+        #define AF_LAPACK_COL_MAJOR 0
+    #else // NETLIB LAPACKE
+        #include<lapacke.h>
+    #endif
 #endif
 
 #endif
diff --git a/src/backend/cuda/CMakeLists.txt b/src/backend/cuda/CMakeLists.txt
index 81d6ba2..8cecd81 100644
--- a/src/backend/cuda/CMakeLists.txt
+++ b/src/backend/cuda/CMakeLists.txt
@@ -112,9 +112,14 @@ ELSE(CUDA_cusolver_LIBRARY)
         ELSE(NOT LAPACK_FOUND)
             MESSAGE(STATUS "CUDA Version ${CUDA_VERSION_STRING} does not contain cusolver library. But CPU LAPACK libraries are available. Will fallback to using host side code.")
             ADD_DEFINITIONS(-DWITH_CPU_LINEAR_ALGEBRA)
-            IF(USE_CUDA_MKL)
-                MESSAGE("Using MKL")
+            IF(USE_CUDA_MKL) # Manual MKL Setup
+                MESSAGE("CUDA LAPACK CPU Fallback Using MKL")
                 ADD_DEFINITIONS(-DUSE_MKL)
+            ELSE(USE_CUDA_MKL)
+                IF(${MKL_FOUND}) # Automatic MKL Setup from BLAS
+                    MESSAGE("CUDA LAPACK CPU Fallback Using MKL RT")
+                    ADD_DEFINITIONS(-DUSE_MKL)
+                ENDIF()
             ENDIF()
         ENDIF()
     ELSE()
diff --git a/src/backend/cuda/cpu_lapack/lapack_helper.hpp b/src/backend/cuda/cpu_lapack/lapack_helper.hpp
index 5826587..b85a80b 100644
--- a/src/backend/cuda/cpu_lapack/lapack_helper.hpp
+++ b/src/backend/cuda/cpu_lapack/lapack_helper.hpp
@@ -19,17 +19,17 @@
 #define AF_LAPACK_COL_MAJOR LAPACK_COL_MAJOR
 #define LAPACK_NAME(fn) LAPACKE_##fn
 
-#ifdef __APPLE__
-#include <Accelerate/Accelerate.h>
-#include <lapacke.hpp>
-#undef AF_LAPACK_COL_MAJOR
-#define AF_LAPACK_COL_MAJOR 0
-#else
 #ifdef USE_MKL
-#include<mkl_lapacke.h>
-#else // NETLIB LAPACKE
-#include<lapacke.h>
-#endif
+    #include<mkl_lapacke.h>
+#else
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+        #include <lapacke.hpp>
+        #undef AF_LAPACK_COL_MAJOR
+        #define AF_LAPACK_COL_MAJOR 0
+    #else // NETLIB LAPACKE
+        #include<lapacke.h>
+    #endif
 #endif
 
 #endif
diff --git a/src/backend/opencl/CMakeLists.txt b/src/backend/opencl/CMakeLists.txt
index e598a97..ce45c4b 100644
--- a/src/backend/opencl/CMakeLists.txt
+++ b/src/backend/opencl/CMakeLists.txt
@@ -10,9 +10,14 @@ IF(USE_OPENCL_F77_BLAS)
     ADD_DEFINITIONS(-DUSE_F77_BLAS)
 ENDIF()
 
-IF(USE_OPENCL_MKL)
-    MESSAGE("Using MKL")
+IF(USE_OPENCL_MKL) # Manual MKL Setup
+    MESSAGE("OpenCL Backend Using MKL")
     ADD_DEFINITIONS(-DUSE_MKL)
+ELSE(USE_OPENCL_MKL)
+    IF(${MKL_FOUND}) # Automatic MKL Setup from BLAS
+        MESSAGE("OpenCL Backend Using MKL RT")
+        ADD_DEFINITIONS(-DUSE_MKL)
+    ENDIF()
 ENDIF()
 
 IF(APPLE)
@@ -42,10 +47,6 @@ ELSE(NOT LAPACK_FOUND)
   ENDIF()
 ENDIF()
 
-IF(${MKL_FOUND})
-  ADD_DEFINITIONS(-DUSE_MKL)
-ENDIF()
-
 IF(NOT UNIX)
     ADD_DEFINITIONS(-DAFDLL)
 ENDIF()
diff --git a/src/backend/opencl/cpu/cpu_helper.hpp b/src/backend/opencl/cpu/cpu_helper.hpp
index cbdc470..f7f6903 100644
--- a/src/backend/opencl/cpu/cpu_helper.hpp
+++ b/src/backend/opencl/cpu/cpu_helper.hpp
@@ -29,32 +29,32 @@
 #define AF_LAPACK_COL_MAJOR LAPACK_COL_MAJOR
 #define LAPACK_NAME(fn) LAPACKE_##fn
 
-#ifdef __APPLE__
-    #include <Accelerate/Accelerate.h>
-    #include <lapacke.hpp>
-    #undef AF_LAPACK_COL_MAJOR
-    #define AF_LAPACK_COL_MAJOR 0
+#ifdef USE_MKL
+    #include<mkl_lapacke.h>
 #else
-    #ifdef USE_MKL
-        #include<mkl_lapacke.h>
-    #else
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+        #include <lapacke.hpp>
+        #undef AF_LAPACK_COL_MAJOR
+        #define AF_LAPACK_COL_MAJOR 0
+    #else // NETLIB LAPACKE
         #include<lapacke.h>
     #endif
-#endif //OS
+#endif
 
 #endif // WITH_OPENCL_LINEAR_ALGEBRA
 
 //********************************************************/
 // BLAS
 //********************************************************/
-#ifdef __APPLE__
-    #include <Accelerate/Accelerate.h>
+#ifdef USE_MKL
+    #include <mkl_cblas.h>
 #else
-    #ifdef USE_MKL
-        #include <mkl_cblas.h>
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
     #else
         extern "C" {
-        #include <cblas.h>
+            #include <cblas.h>
         }
     #endif
 #endif
diff --git a/src/backend/opencl/magma/magma_cpu_blas.h b/src/backend/opencl/magma/magma_cpu_blas.h
index b3cba09..6661aad 100644
--- a/src/backend/opencl/magma/magma_cpu_blas.h
+++ b/src/backend/opencl/magma/magma_cpu_blas.h
@@ -13,16 +13,16 @@
 #include <defines.hpp>
 #include "magma_types.h"
 
-#ifdef __APPLE__
-#include <Accelerate/Accelerate.h>
-#else
 #ifdef USE_MKL
-#include <mkl_cblas.h>
+    #include <mkl_cblas.h>
 #else
-extern "C" {
-#include <cblas.h>
-}
-#endif
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+    #else
+        extern "C" {
+            #include <cblas.h>
+        }
+    #endif
 #endif
 
 // Todo: Ask upstream for a more official way to detect it
diff --git a/src/backend/opencl/magma/magma_cpu_lapack.h b/src/backend/opencl/magma/magma_cpu_lapack.h
index 5974dab..54c26ae 100644
--- a/src/backend/opencl/magma/magma_cpu_lapack.h
+++ b/src/backend/opencl/magma/magma_cpu_lapack.h
@@ -39,16 +39,20 @@ int LAPACKE_dlacgv_work(Args... args) { return 0; }
 #define ORDER_TYPE int
 #define LAPACK_NAME(fn) LAPACKE_##fn
 
-#if defined(__APPLE__)
-    #define LAPACK_COL_MAJOR 102
-    #include "../../lapacke.hpp"
+#ifdef USE_MKL
+    #include<mkl_lapacke.h>
 #else
-    #ifdef USE_MKL
-        #include<mkl_lapacke.h>
+    #ifdef __APPLE__
+        #include <Accelerate/Accelerate.h>
+        #include <lapacke.hpp>
+        #undef LAPACK_COL_MAJOR
+        #define LAPACK_COL_MAJOR 102
+        #undef AF_LAPACK_COL_MAJOR
+        #define AF_LAPACK_COL_MAJOR 0
     #else // NETLIB LAPACKE
         #include<lapacke.h>
-    #endif  // MKL/NETLIB
-#endif  //APPLE
+    #endif
+#endif
 
 #define LAPACKE_CHECK(fn) do {                  \
         int __info = fn;                        \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list