Showing posts with label News. Show all posts
Showing posts with label News. Show all posts

September 19, 2021

Java 17 GA: Simple benchmark with Vector API (Second Preview)

A few years ago I was hoping that Java will have a chance to become again an important contented into machine learning field. I was hoping for interactivity, vectorization, and seamless integration with the external world (c/c++/fortran). With the last release of Java 17 the last two dreams are closer to reality than ever.

JEP 414: Vector API (Second Incubator) is something I awaited a lot and I spent a few hours playing with it. Personally, I am really happy with the results, and I have a lot of motivation to migrate much of the linear algebra staff on that. It looks really cool.

To make a story short, I implemented a small set of microbenchmarks for two simple operations. The first operation is fillNaN and for the second test, we simply add elements of a vector

fillNaN

This is a common problem when working with large chunks of floating numbers: some of them are not numbers for various reasons: missing data, impossible operations, and so on. A panda version of it could be fillna. The whole idea is that for a given vector you want to replace all Double.NaN values with a given value to make arithmetic possible. 

The following is a listing of the fillNa benchmark. 

As you can see, nothing fancy here. The `testFillNaNArrays` method iterates over the array and if the given value is Double.NaN. Pretty straightforward. How about the results? It should be faster.

Benchmark                                      Mode  Cnt   Score   Error   Units
VectorFillNaNBenchmark.testFillNaNArrays      thrpt   10   3.405 ± 0.149  ops/ms
VectorFillNaNBenchmark.testFillNaNVectorized  thrpt   10  41.930 ± 4.437  ops/ms
VectorFillNaNBenchmark.testFillNaNArrays       avgt   10   0.289 ± 0.002   ms/op
VectorFillNaNBenchmark.testFillNaNVectorized   avgt   10   0.023 ± 0.001   ms/op

But over 10 times faster? It is a really pleasant surprise, but not quite a surprise. This is in strict connection with auto-vectorization in Java. When it works, and for simple loops it works, it gives intrinsic optimizations and sometimes even SIMD based. But calling such a thing as Double.isNaN is not a simple thing, at least for auto-vectorization. In the new Vector API this operation is vectorized and we go fast, even if we use masks, which are not the lightest things in this new API. So we get a boost of 13x in speed which looks amazing.

sum and sumNaN

For the second microbenchmark, we have the same operation in two flavors. The first sum is implemented over all elements, with no constraints. The second sum operation, we call it sumNaN skips the potential non-numeric values and computes the sum of the rest of the numbers. We do that to check two things. We want to know how vectorization behaves compared to auto-vectorization (this is the normal sum, which is implemented as a simple loop that benefits from all optimizations possible). And we also want to see another operation with masks, compared with an auto-vectorized code. Let's see the benchmark:


And with no additional comments the results:

Benchmark                                 Mode  Cnt   Score   Error   Units
VectorSumBenchmark.testSumArrays         thrpt   10   9.264 ± 1.591  ops/ms
VectorSumBenchmark.testSumVectorized     thrpt   10  12.222 ± 0.738  ops/ms
VectorSumBenchmark.testSumNanArrays      thrpt   10   2.692 ± 0.191  ops/ms
VectorSumBenchmark.testSumNanVectorized  thrpt   10  10.704 ± 0.428  ops/ms
VectorSumBenchmark.testSumArrays          avgt   10   0.120 ± 0.011   ms/op
VectorSumBenchmark.testSumVectorized      avgt   10   0.054 ± 0.011   ms/op
VectorSumBenchmark.testSumNanArrays       avgt   10   0.390 ± 0.018   ms/op
VectorSumBenchmark.testSumNanVectorized   avgt   10   0.068 ± 0.005   ms/op

We can see from those results that the unoptimized code for sumNan on arrays performs badly by distance. This is expected. What I personally did not expect was the vectorized version with masks (sum nan vectorized) to perform better than an auto-vectorized version of the simple sum (sum arrays).  Really good job. Hat off!

Conclusions

For the sake of reproduction, I have run that on 'Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz/8cores/32GB RAM'. This processor can make SIMD operations on lanes of 256 bits / 4 double floats. A better one runs faster, of course. But the absolute numbers are not important here. What is important is that you can vectorize many things in Java directly and it makes it possible to implement complex things with masks, which, at least sometimes, is faster than auto-vectorization. This is a really really amazing job.

August 17, 2009

NetBeans 6.7.1 with JavaFX

NetBeans soon after 6.7 had launched another version of its IDE. That's 6.7.1 with JavaFX. As its name states, this version is an update version of the previous one containing few adiitional things:
  • Support for JavaFX 1.2
  • Update of GlassFish v3 Prelude
  • Important bux fixes requested by users
You should give it a try, even if you don't use actually JavaFX. Bring it from here and have fun.

NetBeans 6.7 was launched, what brings with him?




NetBeans 6.7
On June 2009 Netbeans released the final version of 6.7. You can find more about here, on their release page. You can download it here.
From the beginning I must say that I am a big fun of NetBeans. I used since it was named Forte for Java version 2. I appreciate also Eclipse, but don't start here a flame on why I consider Netbeans superior.
From the release page we can see major topics on the improvements of new features brought to us by this version. You can read yourself about them. Here is my only humble opinion on this release.
Overview. The first impression is that is faster than its predecessors. The difference is visible in usage. Also, they added a feature to enable/disable features with you don't work.
Other languages than Java. Since I don't work too much with either of them I can't provide a full coverage. Still I am happy that I can have in the same IDE some tools for managing this kind of projects. That's cool. I tried PHP support, which I found quite good. Comparing with dedicated tools on that, it manages good. I found it fine for may needs. All that languages were supported before. Thought new valuable features were added for all of them. I would call here the sql editing and PHPUnit in php scripts, remote debugging for Ruby, code complettion on Groovy, profiling and QT libraries support for C/C++. Just to name few of them which are really consistent.
GlassFish. Nice that v3 is supported now. You have code completion, there is also a nice plug-in called GlassFish v3 enabler, quite usefull. You have also v2 version support.
Maven. That's really a very good thing. Maven support is much better now. You have a viewer for dependency graphs, you can configure a lot of your settings through UI. Also, you have archetypes for Java EE projects. The most appealing thing on that is that you can easily use your NetBeans project in another IDE. Practically nothing need to be done to do that. That's impressive. For the ones who want to know more on Maven they should take a look here.
Kenai. The most appealing to me. Kenai is a community similar to sourceforge, I think. But the best thing is that is fully integrated with NetBeans. For start up project is increddible. You have almost everything you can wish: bug tracking, wiki, dedicated place for a site, IM chats, etc. Take a loot at kenai.com. It worths the effort.
Conclusion. This release means "get into community" to my. Kenai is very apealing. In the same time they did not lost focus on continuous improvements. I believe everybody can found a new good reason to use NetBeans.
PS: for Eclipse developers now there's a button called "Synchronize editor with views" ;)