Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Marc_R_
Beginner
82 Views

mkl under netlib-java under Scala Breeze, on Windows

I'm looking for advice to configure the use of MKL under netlib-java, under Scala Breeze, on Windows 7.

How do configure netlib-java to use MKL?

How do I know that I'm actually using it?

Thanks, --Marc

0 Kudos
3 Replies
Marc_R_
Beginner
82 Views

Okay, I answered my own question after a bunch of trial and error.

  1. Added C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\redist\intel64_win\mkl to my PATH.
  2. Set runtime JVM param -Dcom.github.fommil.netlib.NativeSystemBLAS.natives=mkl_rt.dll  [Which resides in the above directory]
  3. Code looks as follows:
package org.mriehm.breeze1

import breeze.linalg.DenseVector
import com.github.fommil.netlib.BLAS
import org.slf4j.LoggerFactory

/**
  * Created by mriehm on 29/12/2016.
  */
object Breeze1 {
  def main(args:Array[String]): Unit = {
    println("Init logging...")
    System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
    val log = LoggerFactory.getLogger("main")
    log.trace("Starting...")
    val b = BLAS.getInstance()
    log.trace(s"BLAS = $b")
    val v = DenseVector(1,2,3,4)
    log.trace("Ending.")
  }
}

Output from Idea is as follows:

"C:\Program Files\Java\jdk1.8.0_74\bin\java" -Dcom.github.fommil.netlib.NativeSystemBLAS.natives=mkl_rt.dll -Didea.launcher.port=7540 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_74\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_74\jre\lib\rt.jar;C:\Users\mriehm\IdeaWorkspace\Breeze1\target\scala-2.11\classes;C:\Users\mriehm\.ivy2\cache\com.chuusai\shapeless_2.11\bundles\shapeless_2.11-2.0.0.jar;C:\Users\mriehm\.ivy2\cache\org.slf4j\slf4j-simple\jars\slf4j-simple-1.7.22.jar;C:\Users\mriehm\.ivy2\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.7.22.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil\jniloader\jars\jniloader-1.1.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\core\jars\core-1.1.2.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\native_ref-java\jars\native_ref-java-1.1.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\native_system-java\jars\native_system-java-1.1.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-linux-armhf\jars\netlib-native_ref-linux-armhf-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-linux-i686\jars\netlib-native_ref-linux-i686-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-linux-x86_64\jars\netlib-native_ref-linux-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-osx-x86_64\jars\netlib-native_ref-osx-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-win-i686\jars\netlib-native_ref-win-i686-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_ref-win-x86_64\jars\netlib-native_ref-win-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-linux-armhf\jars\netlib-native_system-linux-armhf-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-linux-i686\jars\netlib-native_system-linux-i686-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-linux-x86_64\jars\netlib-native_system-linux-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-osx-x86_64\jars\netlib-native_system-osx-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-win-i686\jars\netlib-native_system-win-i686-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.fommil.netlib\netlib-native_system-win-x86_64\jars\netlib-native_system-win-x86_64-1.1-natives.jar;C:\Users\mriehm\.ivy2\cache\com.github.rwl\jtransforms\jars\jtransforms-2.4.0.jar;C:\Users\mriehm\.ivy2\cache\junit\junit\jars\junit-4.8.2.jar;C:\Users\mriehm\.ivy2\cache\net.sf.opencsv\opencsv\jars\opencsv-2.3.jar;C:\Users\mriehm\.ivy2\cache\net.sourceforge.f2j\arpack_combined_all\jars\arpack_combined_all-0.1-javadoc.jar;C:\Users\mriehm\.ivy2\cache\net.sourceforge.f2j\arpack_combined_all\jars\arpack_combined_all-0.1.jar;C:\Users\mriehm\.ivy2\cache\org.apache.commons\commons-math3\jars\commons-math3-3.2.jar;C:\Users\mriehm\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.11.8.jar;C:\Users\mriehm\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.11.8.jar;C:\Users\mriehm\.ivy2\cache\org.scalanlp\breeze-macros_2.11\jars\breeze-macros_2.11-0.12.jar;C:\Users\mriehm\.ivy2\cache\org.scalanlp\breeze-natives_2.11\jars\breeze-natives_2.11-0.12.jar;C:\Users\mriehm\.ivy2\cache\org.scalanlp\breeze_2.11\jars\breeze_2.11-0.12.jar;C:\Users\mriehm\.ivy2\cache\org.spire-math\spire-macros_2.11\jars\spire-macros_2.11-0.7.4.jar;C:\Users\mriehm\.ivy2\cache\org.spire-math\spire_2.11\jars\spire_2.11-0.7.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.mriehm.breeze1.Breeze1
Init logging...
[main] TRACE main - Starting...
Dec 29, 2016 7:28:05 PM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\redist\intel64_win\mkl\mkl_rt.dll
[main] TRACE main - BLAS = com.github.fommil.netlib.NativeSystemBLAS@6537cf78
[main] TRACE main - Ending.

Process finished with exit code 0

 

yarish__george
Beginner
82 Views

how setup the same for linux machine?

Ying_H_Intel
Employee
82 Views

Hi George,

​How about copy the processing under linux? 

  1. source /opt/intel/mkl/mklvars.sh intel64

2. Set runtime JVM param -Dcom.github.fommil.netlib.NativeSystemBLAS.natives=libmkl_rt.so  [Which resides in the above directory]
3. then test your code.

Best Regards,
​Ying