Today we are pleased to announce the release of ArrayFire v3.5, our open source library of parallel computing functions supporting CUDA, OpenCL, and CPU devices. This new version of ArrayFire improves features and performance for applications in machine learning, computer vision, signal processing, statistics, finance, and more. This release focuses on thread-safety, support for simple sparse-dense arithmetic operations, canny edge detector function, and a genetic algorithm example. A complete list of ArrayFire v3.5 updates and new features are found in the product Release Notes. Thread Safety ArrayFire now supports threading programming models. This is not intended to improve the performance since most of the parallelism is happening on the device, but it does allow you to use multiple devices in ...

## ArrayFire - CUDA Interoperability

Although ArrayFire is quite extensive, there remain many cases in which you may want to write custom kernels in CUDA or OpenCL. For example, you may wish to add ArrayFire to an existing code base to increase your productivity, or you may need to supplement ArrayFire's functionality with your own custom implementation of specific algorithms. Today's "Learning ArrayFire from scratch", blog post discusses how you can interface ArrayFire and CUDA.

## Setting up an ArrayFire project on Linux

Continuing our blog series "Learning ArrayFire from scratch" today we will discuss how to set up an ArrayFire project on Linux using CMake or standard makefiles.

## Benchmarking parallel vector libraries

There are many open source libraries that implement parallel versions of the algorithms in the C++ standard template libraries. Inevitably we get asked questions about how ArrayFire compares to the other libraries out in the open. In this post we are going to compare the performance of ArrayFire to that of BoostCompute, HSA-Bolt, Intel TBB and Thrust. The benchmarks include the following commonly used vector algorithms across 3 different architectures. Reductions Scan Transform The following setup has been used for the benchmarking purposes. The code to reproduce the benchmarks is linked at the bottom of the post. The hardware used for the benchmarks is listed below: NVIDIA Tesla K20 AMD FirePro S10000 Intel Xeon E5-2560v2 Background ArrayFire ArrayFire provides high ...

## ArrayFire v3.0 is here!

Today we are pleased to announce the release of ArrayFire v3.0. This new version features major changes to ArrayFire’s visualization library, a new CPU backend, and dense linear algebra for OpenCL devices. It also includes improvements across the board for ArrayFire’s OpenCL backend. A complete list ArrayFire v3.0 updates and new features can be found in the product Release Notes. With over 8 years of continuous development, the open source ArrayFire library is the top CUDA and OpenCL software library. ArrayFire supports CUDA-capable GPUs, OpenCL devices, and other accelerators. With its easy-to-use API, this hardware-neutral software library is designed for maximum speed without the hassle of writing time-consuming CUDA and OpenCL device code. With ArrayFire’s library functions, developers can maximize ...

## Machine Learning with ArrayFire: Linear Classifiers

Linear classifiers perform classification based on the linear combinition of the component features. Some examples of Linear Classifiers include: Naive Bayes Classifier, Linear Discriminant Analysis, Logistic Regression and Perceptrons. ArrayFire's easy to use API enables users to write such classifiers from scratch fairly easily. In this post, we show how you can map mathematical equations to ArrayFire code and implement them from scratch. Naive Bayes Classifier Perceptron Naive Bayes Classifier Naive bayes classifier is a probabilistic classifier that assumes all the features in a feature vector are independent of each other. This assumption simplifies the bayes rule to a simple multiplication of probabilities as show below. First we start with the simple Baye's rule. Where: Since p(x) is the same ...

## Performance of ArrayFire JIT Code Generation

The ArrayFire library offers JIT (Just In Time) compiling for standard arithmetic operations. This includes trigonometric functions, comparisons, and element-wise operations. At run-time, ArrayFire aggregates these function calls using an Abstract Syntax Tree (AST) data structure such that when ever a JIT supported function is ''met'' it is added into the AST for a given variable instance. The AST of the variable is computed if one of the following conditions is met: an explication evaluation is required by the programmer using the eval() function member or the variable is required for the computation of a different variable that is not-JIT supported it. When the above occurs and the variable needs to be evaluated, the functions and variables in the AST ...

## ArrayFire is Now Open Source

Yes, you read that right! ArrayFire is open source—it’s all there and it’s all free. This is big, and you and the rest of the parallel computing community are going to love it! You can download our pre-compiled binary installers which are optimized for a wide variety of systems or you can get a copy of the ArrayFire source code from our GitHub page. ArrayFire is being released under the BSD 3-Clause License, which will enable unencumbered deployment and portability of ArrayFire for commercial use. So go check it out! We welcome your feedback and look forward to your future contributions to ArrayFire. The move to open source isn't our only news—we've also made ArrayFire better than ever. Check out our recent ...

## Accelerating Java using ArrayFire, CUDA and OpenCL

We have previously mentioned the ability to use ArrayFire through Java. In this post, we are going to show how you can get the best performance inside Java using ArrayFire for CUDA and OpenCL. Code Here is a sample code to perform Monte Caro Estimation of Pi.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import java.util.Random; // Native Java Code public static double hostCalcPi(int size) { Random rand = new Random(); int count = 0; for (int i = 0; i < size; i++) { float x = rand.nextFloat(); float y = rand.nextFloat(); boolean lt1 = (x * x + y * y) < 1; if (lt1) count++; } return 4.0 * ((double)(count)) / size; } |

The same code can be written using ArrayFire in the following manner.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import com.arrayfire.Array; // ArrayFire through Java public static double deviceCalcPi(int size) throws Exception { Array x = null, y = null, res = null; try { int[] dims = new int[] {size, 1}; x = Array.randu(dims, Array.FloatType); y = Array.randu(dims, Array.FloatType); x = Array.mul(x, x); y = Array.mul(y, y); res = Array.add(x , y); res = Array.lt(res, 1); double count = Array.sumAll(res); return 4.0 * ((double)(count)) / size; } finally { if (x != null) x.close(); if (y != null) y.close(); if (res != null) res.close(); } } |

Array.randu(dims, Array.FloatType) creates a uniform random Array. Array.FloatType is passed in to create a uniform random array of 32 bit floating point numbers. Other types can include Array.FloatComplexType, Array.DoubleType and so on. Array.mul, Array.add and Array.lt perform element wise operations on the two operands to produce an output. Array.sumAll adds up all the elements in the array to produce ...

## Image editing using ArrayFire: Part 3

Today, we will be doing the third post in our series Image editing using ArrayFire. References to old posts are available below. * Part 1 * Part 2 In this post, we will be looking at the following operations. Image Histogram Simple Binary Theshold Otsu Threshold Iterative Threshold Adaptive Binary Threshold Emboss Filter Today's post will be mostly dominated by different types of threshold operations we can achieve using ArrayFire. Image Histogram We have a built-in function in ArrayFire that creates a histogram. The input image was converted to gray scale before histogram calculation as our histogram implementation works for vector and 2D matrices only. In case, you need histogram for all three channels of a color image, you can ...