Package org.apache.sysds.utils

# Class NativeHelper

java.lang.Object
org.apache.sysds.utils.NativeHelper

public class NativeHelper extends Object
This class helps in loading native library. By default, it first tries to load Intel MKL, else tries to load OpenBLAS.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`NativeHelper.NativeBlasState`

## Field Summary

Fields
Modifier and Type
Field
Description
`static NativeHelper.NativeBlasState`
`CURRENT_NATIVE_BLAS_STATE`

## Constructor Summary

Constructors
Constructor
Description
`NativeHelper()`

## Method Summary

Modifier and Type
Method
Description
`static long`
`conv2dBackwardDataDense(double[] filter, double[] dout, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static long`
`conv2dBackwardFilterDense(double[] input, double[] dout, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static boolean`
`conv2dBackwardFilterSparseDense(int apos, int alen, int[] aix, double[] avals, double[] rotatedDoutPtr, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static long`
`conv2dDense(double[] input, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static boolean`
`conv2dSparse(int apos, int alen, int[] aix, double[] avals, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static long`
`dconv2dBiasAddDense(double[] input, double[] bias, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static long`
`dmmdd(double[] m1, double[] m2, double[] ret, int m1rlen, int m1clen, int m2clen, int numThreads)`
`static String`
`getCurrentBLAS()`
Called by Statistics to print the loaded BLAS.
`static int`
`getMaxNumThreads()`
`static void`
`initialize(String customLibPath, String userSpecifiedBLAS)`
Initialize the native library before executing the DML program
`static boolean`
`isNativeLibraryLoaded()`
Called by runtime to check if the BLAS is available for exploitation
`static boolean`
`loadBLAS(String customLibPath, String blas, String optionalMsg)`
Attempts to load native BLAS
`static boolean`
`loadLibraryHelperFromResource(String libFileName)`
Attempts to load the JNI shared library from the sysds jar
`static long`
`sconv2dBiasAddDense(FloatBuffer input, FloatBuffer bias, FloatBuffer filter, FloatBuffer ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)`
`static long`
`smmdd(FloatBuffer m1, FloatBuffer m2, FloatBuffer ret, int m1rlen, int m1clen, int m2clen, int numThreads)`
`static long`
`tsmm(double[] m1, double[] ret, int m1rlen, int m1clen, boolean leftTrans, int numThreads)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### CURRENT_NATIVE_BLAS_STATE

public static NativeHelper.NativeBlasState CURRENT_NATIVE_BLAS_STATE

## Constructor Details

### NativeHelper

public NativeHelper()

## Method Details

### getCurrentBLAS

public static String getCurrentBLAS()
Called by Statistics to print the loaded BLAS.

Returns:
  empty string or the BLAS that is loaded

### isNativeLibraryLoaded

public static boolean isNativeLibraryLoaded()
Called by runtime to check if the BLAS is available for exploitation

Returns:
  true if CURRENT_NATIVE_BLAS_STATE is SUCCESSFULLY_LOADED_NATIVE_BLAS_AND_NOT_IN_USE else false

### initialize

public static void initialize(String customLibPath, String userSpecifiedBLAS)
Initialize the native library before executing the DML program

Parameters:
  `customLibPath` - specified by sysds.native.blas.directory
  `userSpecifiedBLAS` - specified by sysds.native.blas

### getMaxNumThreads

public static int getMaxNumThreads()

### loadBLAS

public static boolean loadBLAS(String customLibPath, String blas, String optionalMsg)
Attempts to load native BLAS

Parameters:
  `customLibPath` - can be null (if we want to only want to use LD_LIBRARY_PATH), else the
  `blas` - can be gomp, openblas or mkl_rt
  `optionalMsg` - message for debugging
Returns:
  true if successfully loaded BLAS

### loadLibraryHelperFromResource

public static boolean loadLibraryHelperFromResource(String libFileName)
Attempts to load the JNI shared library from the sysds jar

Parameters:
  `libFileName` - library file name)
Returns:
  true if successfully loaded BLAS

### dmmdd

public static long dmmdd(double[] m1, double[] m2, double[] ret, int m1rlen, int m1clen, int m2clen, int numThreads)

### smmdd

public static long smmdd(FloatBuffer m1, FloatBuffer m2, FloatBuffer ret, int m1rlen, int m1clen, int m2clen, int numThreads)

### tsmm

public static long tsmm(double[] m1, double[] ret, int m1rlen, int m1clen, boolean leftTrans, int numThreads)

### conv2dDense

public static long conv2dDense(double[] input, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### dconv2dBiasAddDense

public static long dconv2dBiasAddDense(double[] input, double[] bias, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### sconv2dBiasAddDense

public static long sconv2dBiasAddDense(FloatBuffer input, FloatBuffer bias, FloatBuffer filter, FloatBuffer ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### conv2dBackwardFilterDense

public static long conv2dBackwardFilterDense(double[] input, double[] dout, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### conv2dBackwardDataDense

public static long conv2dBackwardDataDense(double[] filter, double[] dout, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### conv2dBackwardFilterSparseDense

public static boolean conv2dBackwardFilterSparseDense(int apos, int alen, int[] aix, double[] avals, double[] rotatedDoutPtr, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)

### conv2dSparse

public static boolean conv2dSparse(int apos, int alen, int[] aix, double[] avals, double[] filter, double[] ret, int N, int C, int H, int W, int K, int R, int S, int stride_h, int stride_w, int pad_h, int pad_w, int P, int Q, int numThreads)