KellenSunderland commented on a change in pull request #11148: [MXNET-679] 
Refactor handling BLAS libraries with cmake
URL: https://github.com/apache/incubator-mxnet/pull/11148#discussion_r209254870
 
 

 ##########
 File path: cmake/ChooseBLAS.cmake
 ##########
 @@ -0,0 +1,273 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set(BLAS "Open" CACHE STRING "Selected BLAS library")
+set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL;Apple")
+
+function(switch_lapack ENABLE)
+  if(ENABLE)
+    message(STATUS "Enabling LAPACK functionality")
+    add_definitions(-DMXNET_USE_LAPACK=1)
+  else()
+    if(USE_LAPACK)
+      message(WARNING "LAPACK functionality not available")
+    else()
+      message(STATUS "LAPACK functionality not available")
+    endif()
+  endif()
+endfunction()
+
+function(try_mkldnn)
+
+  if(NOT USE_MKLDNN)
+    return()
+  endif()
+
+  if(NOT MKL_FOUND)
+    message(WARNING "MKLDNN requires either MKL or MKLML, MKLDNN will not be 
available")
+    return()
+  endif()
+
+  message(STATUS "Adding MKLDNN to the build due to USE_MKLDNN=${USE_MKLDNN} 
and MKL_FOUND=${MKL_FOUND}")
+
+  # CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
+  if(NOT MSVC)
+    set(ARCH_OPT_FLAGS ${ARCH_OPT_FLAGS} "-mtune=generic" PARENT_SCOPE)
+  endif()
+
+  set(WITH_TEST OFF)
+  set(WITH_EXAMPLE OFF)
+  add_subdirectory(3rdparty/mkldnn)
+
+  include_directories(3rdparty/mkldnn/include)
+  set(mxnet_LINKER_LIBS ${mxnet_LINKER_LIBS} mkldnn PARENT_SCOPE)
+
+  add_definitions(-DUSE_MKL=1)
+  add_definitions(-DCUB_MKL=1)
+  add_definitions(-DMXNET_USE_MKLDNN=1)
+
+endfunction()
+
+function(try_mkl)
+  if(USE_MKLML)
+    return()
+  endif()
+
+  if(CMAKE_CROSSCOMPILING)
+    message(WARNING "MKL with cross compilation is not supported, MKL will not 
be available")
+    return()
+  endif()
+
+  if(NOT SYSTEM_ARCHITECTURE STREQUAL "x86_64")
+    message(WARNING "MKL is supported only for desktop platforms 
(SYSTEM_ARCHITECTURE=${SYSTEM_ARCHITECTURE}), \
+                     MKL will not be available")
+    return()
+  endif()
+
+  message(STATUS "Trying to enable MKL framework due to 
USE_MKL_IF_AVAILABLE=${USE_MKL_IF_AVAILABLE}")
+
+  find_package(MKL)
+
+  if(MKL_FOUND)
+    message(STATUS "MKL framework found")
+
+    set(MKL_FOUND ${MKL_FOUND} PARENT_SCOPE)
+    set(MKL_INCLUDE_DIR ${MKL_INCLUDE_DIR} PARENT_SCOPE)
+    set(MKL_LIBRARIES ${MKL_LIBRARIES} PARENT_SCOPE)
+    set(MKLROOT ${MKLROOT} PARENT_SCOPE)
+
+    set(BLAS MKL PARENT_SCOPE)
+  else()
+    message(STATUS "MKL framework not found")
+  endif()
+
+endfunction()
+
+function(try_mklml)
+  if(NOT USE_MKLML)
+    return()
+  endif()
+
+  if(CMAKE_CROSSCOMPILING)
+    message(STATUS "MKLML is supported only for desktop platforms, 
skipping...")
+    return()
+  endif()
+
+  if(MKL_FOUND)
+    return()
+  endif()
+
+  if(CMAKE_CROSSCOMPILING)
 
 Review comment:
   Will it be able to get to this line, or will it return on line 107?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to