jblas-project / jblas

Linear Algebra for Java
http://jblas.org
BSD 3-Clause "New" or "Revised" License
590 stars 149 forks source link

Power Linux (ppc64le) support? #57

Closed mtbrandy closed 9 years ago

mtbrandy commented 9 years ago

What is the process for adding support for additional platforms?

Running Spark on RHEL/Ubuntu (ppc64le) currently requires a manually build of libjblas.so to enable some of the Machine learning library functionality.

I can assist in obtaining access to Power hardware to ease the process.

mikiobraun commented 9 years ago

Hi Matthew,

so you say you already have a build of libjblas.so available which includes ATLAS, but you are interested in bundling it with jblas so that the jar could be able to run that out of the box?

Actually, I'm not 100% sure that the current build would extend beyond that. jblas tries to pull system information from system properties like os.name and os.arch. In addition org.jblas.util.ArchFlavor uses some assembler code to determine the exact capabilities on x86 hardware... .

In principle, the main tasks are putting the libs into the src/main/resources/Linux/... directories, and then adding enough magic that jblas know where it should look.

What do you think?

-M

mtbrandy commented 9 years ago

Thanks for the response. It sounds like you agree it should be fairly easy. This is what I was assuming as well -- just wanted to reach out and the ball rolling.

Right now my libjblas.so dynamically links with atlas/lapack, but my next step is to build a version that is more self-contained. Once I find time to work on that I'll link up with you again.

mtbrandy commented 9 years ago

I now have the self-contained native libraries. I'll work on submitting a pull request next. For documentation, build steps were as follows:

  WORK_DIR=$HOME/work
  cd $WORK_DIR

  # Retrieve atlas and lapack
  wget http://www.netlib.org/lapack/lapack-3.5.0.tgz
  wget http://sourceforge.net/projects/math-atlas/files/Stable/3.10.2/atlas3.10.2.tar.bz2/download -O atlas3.10.2.tar.bz2
  bunzip2 atlas3.10.2.tar.bz2
  tar -xf atlas3.10.2.tar

  # Retrieve and apply ppc64le patches for atlas v3.10.2
  # from https://bugzilla.redhat.com/show_bug.cgi?id=1080073#c40
  # See the following for discussion of patch acceptance upstream:
  #   http://sourceforge.net/p/math-atlas/patches/65/ (step2/3 and vsx)
  #   http://sourceforge.net/p/math-atlas/patches/66/ (ppc64le archdef)
  #   http://sourceforge.net/p/math-atlas/patches/67/ (power8 support)
  mkdir patches
  cd patches
  wget https://bugzilla.redhat.com/attachment.cgi?id=927915 -O atlas.3.10.2-ppc64le_abiv2_step2.patch
  wget https://bugzilla.redhat.com/attachment.cgi?id=927916 -O atlas.3.10.2-ppc64le_abiv2_step3.patch
  wget https://bugzilla.redhat.com/attachment.cgi?id=939357 -O atlas.3.10.2-add_power8_cpu.patch
  wget https://bugzilla.redhat.com/attachment.cgi?id=942576 -O atlas.3.10.2-ppc64le_do_not_use_files_with_lvx.patch
  wget https://bugzilla.redhat.com/attachment.cgi?id=942578 -O atlas-new_archdef_for_ppc64le.patch
  cd ../ATLAS
  for f in `find ../patches -type f`; do echo $f; cat $f | patch -u -p1; done                                                                                                                                                                                             

  # Build atlas libraries
  mkdir build
  cd build
  $WORK_DIR/ATLAS/configure --with-netlib-lapack-tarfile=$WORK_DIR/lapack-3.5.0.tgz
  make

  # Build jblas native libraries
  cd $WORK_DIR
  git clone https://github.com/mikiobraun/jblas.git
  cd jblas
  ./configure --ptatlas --static-libs --libpath=$WORK_DIR/ATLAS/build/lib/
  # Manual step ---> modify configure.out: change "libgfortran.a" to "libgfortran.so" due to PIC
  make
mtbrandy commented 9 years ago

The PR simply adds the libraries to the appropriate directories in the jar. No changes were required for ArchFlavor since it will default to null.

mikiobraun commented 9 years ago

Hi Matthew,

so I got that right, that just adding these files was all that was required to work? That would be pretty cool ;)

Can you also attach the outputs of running "java -jar jblas...." to get some performance results?

-M

mtbrandy commented 9 years ago
-- org.jblas INFO jblas version is 1.2.3
Simple benchmark for jblas

Running sanity benchmarks.

checking vector addition... ok
-- org.jblas CONFIG BLAS native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
-- org.jblas CONFIG ArchFlavor native library not found in path. Copying native library libjblas_arch_flavor from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH).
-- org.jblas CONFIG Loading libjblas_arch_flavor.so from /lib/static/Linux/ppc64le/, copying to libjblas_arch_flavor.so.
-- org.jblas CONFIG Loading libjblas.so from /lib/static/Linux/ppc64le/, copying to libjblas.so.
checking matrix multiplication... ok
checking existence of dsyev...... ok
[-0.210656, -0.640445, 0.656727; -0.509085, -0.116445, 0.154634; -0.807515, 0.407556, -0.077317; 0.210656, 0.640445, 0.734044]                                                                                                                                            
[17.233688; 1.414214; 0.000000]                                                                                                                                                                                                                                           
[-0.470605, 0.782218, -0.408248; -0.571449, 0.082339, 0.816497; -0.672293, -0.617540, -0.408248]                                                                                                                                                                          
[17.233688; 1.414214; 0.000000]                                                                                                                                                                                                                                           
checking existence of dgesvd...... ok
Checking complex return values... (z = -21.0 + 88.0i)
Check whether we're catching XERBLA errors. If you see something like "** On entry to DGEMM  parameter number  4 had an illegal value", it didn't work!
checking XERBLA... ok
Sanity checks passed.

Each benchmark will take about 5 seconds...

Running benchmark "Java matrix multiplication, double precision".
n = 10   :  0.744 GFLOPS (1860623 iterations in 5.0 seconds)
n = 100  :  0.832 GFLOPS (2080 iterations in 5.0 seconds)
n = 1000 :  1.147 GFLOPS (3 iterations in 5.2 seconds)

Running benchmark "Java matrix multiplication, single precision".
n = 10   :  1.530 GFLOPS (3825980 iterations in 5.0 seconds)
n = 100  :  1.912 GFLOPS (4780 iterations in 5.0 seconds)
n = 1000 :  1.822 GFLOPS (5 iterations in 5.5 seconds)

Running benchmark "ATLAS matrix multiplication, double precision".
n = 10   :  1.189 GFLOPS (2973313 iterations in 5.0 seconds)
n = 100  : 10.554 GFLOPS (26385 iterations in 5.0 seconds)
n = 1000 : 45.501 GFLOPS (114 iterations in 5.0 seconds)

Running benchmark "ATLAS matrix multiplication, single precision".
n = 10   :  1.196 GFLOPS (2990934 iterations in 5.0 seconds)
n = 100  : 20.357 GFLOPS (50894 iterations in 5.0 seconds)
n = 1000 : 87.484 GFLOPS (219 iterations in 5.0 seconds)
-- org.jblas INFO Deleting /tmp/jblas2184582525322398166/libjblas_arch_flavor.so
-- org.jblas INFO Deleting /tmp/jblas2184582525322398166/libjblas.so
-- org.jblas INFO Deleting /tmp/jblas2184582525322398166
mtbrandy commented 9 years ago

Will there be a version bump and an update to the mvn repository as a result of this new platform support?

mikiobraun commented 9 years ago

Thanks, Matthew. These are some impressive performance numbers! Pardon my ignorance but what kind of machine is this?

There are a few old pull requests I finally want to merge, then there'll definitely be a bump in the version number.

Best,

Mikio

----- Ursprüngliche Nachricht ----- Von: "Matthew Brandyberry" notifications@github.com Gesendet: ‎27.‎04.‎2015 15:58 An: "mikiobraun/jblas" jblas@noreply.github.com Cc: "Mikio L. Braun" mikiobraun@gmail.com Betreff: Re: [jblas] Power Linux (ppc64le) support? (#57)

Will there be a version bump and an update to the mvn repository as a result of this new platform support? — Reply to this email directly or view it on GitHub.

mtbrandy commented 9 years ago

Thanks for the update. That measurement was taken on a VM provisioned with 8 Power7+ CPUs.

mtbrandy commented 9 years ago

Checking in. Do you have a date in mind for the publish of the new version?

mikiobraun commented 9 years ago

Hi, Matthew,

In was at Strata London all week. There are some doc fixes i need to make and there are bindings again openblas and nvblas people have submitted that I'm looking into. But hopefully, i can make the release next week.

I guess it will simply be 1.2.4

-M

Dr. Mikio L. Braun http://blog.mikiobraun.de

Am 08.05.2015 um 15:46 schrieb Matthew Brandyberry notifications@github.com:

Checking in. Do you have a date in mind for the publish of the new version?

― Reply to this email directly or view it on GitHub.

mikiobraun commented 9 years ago

Getting closer...

mtbrandy commented 9 years ago

Hi Mikio, when do expect 1.2.4 to be available in the maven repository?

mikiobraun commented 9 years ago

I published on Tuesday afternoon. Unless I forgot some step in the process, it should become available any time now.

-M

----- Ursprüngliche Nachricht ----- Von: "Matthew Brandyberry" notifications@github.com Gesendet: ‎15.‎05.‎2015 16:29 An: "mikiobraun/jblas" jblas@noreply.github.com Cc: "Mikio L. Braun" mikiobraun@gmail.com Betreff: Re: [jblas] Power Linux (ppc64le) support? (#57)

Hi Mikio, when do expect 1.2.4 to be available in the maven repository? — Reply to this email directly or view it on GitHub.

mikiobraun commented 9 years ago

Hm. I can see its in the releases repo which should sync in no about two hours... Will inquire.

-M

----- Ursprüngliche Nachricht ----- Von: "Matthew Brandyberry" notifications@github.com Gesendet: ‎15.‎05.‎2015 16:29 An: "mikiobraun/jblas" jblas@noreply.github.com Cc: "Mikio L. Braun" mikiobraun@gmail.com Betreff: Re: [jblas] Power Linux (ppc64le) support? (#57)

Hi Mikio, when do expect 1.2.4 to be available in the maven repository? — Reply to this email directly or view it on GitHub.

agibsonccc commented 9 years ago

I was able to resolve it for our project. I dug around on maven central and hadn't seen it but saw it on oss.sonatype.org. When you do the release make sure to refresh the gui and ensure all the tests pass (checksums,gpg,sources,javadoc,..)

It's an obnoxious and error prone process without automated CI and the like. I'd be curious to know what the problem was.

mtbrandy commented 9 years ago

I see it now. Was looking in the wrong place previously (http://mvnrepository.com/artifact/org.jblas/jblas). Thanks!

mikiobraun commented 9 years ago

Yeah, I can also see it now. Don't know how long it will take to show up in the repository search indices, but doing a maven build with jblas 1.2.4 as dependency seems to work fine.