Skip to content

Linking Caffe with BLIS

santanu edited this page Oct 17, 2017 · 6 revisions

BLIS

BLIS is a portable software framework for instantiating high-performance BLAS-like dense linear algebra libraries. The framework was designed to isolate essential kernels of computation that, when optimized, immediately enable optimized implementations of most of its commonly used and computationally intensive operations. More about in here: https://github.com/amd/blis

BLIS is optimized for caffe

The Caffe MNIST benchmark calls GEMM routines for really small matrix sizes. For lot of image processing applications such as hand written digit recognition, the region of interest is usually a smaller subsection of the large image, where the small matrix computation is commonly employed. The small matrix performance of BLIS was fine tuned for the AMD EPYC processors and it resulted in good performance improvement. You can read more about them here: http://developer.amd.com/wordpress/media/2013/12/Accelerating-Machine-Learning-using-BLIS.pdf

The performance improvement in using the AMD optimized BLIS in EPYC processors is about 18% compared to the base version of BLIS in single threaded configuration and it is faster than the OpenBLAS.

Linking BLIS with Caffe

Caffe by default does not link with BLIS, hence you need to make modifications in the Makefile to enable it. Locate the lines in Makefile, where it checks through the list of BLAS libraries (Hint: just search for the line : ifeq ($(BLAS), open)).

Append these lines in the conditional check:

 else ifeq ($(BLAS), blis)
    #BLIS
    LIBRARIES += blis

So after the changes the Makefile will look similar to this:

#BLAS configuration (default = ATLAS)
else ifeq ($(BLAS), open)
    #OpenBLAS
     LIBRARIES += openblas
 else ifeq ($(BLAS), blis)
     #BLIS
     LIBRARIES += blis
 else
     #ATLAS 

Then in the Makefile.config file, set BLAS := blis and point the BLAS_INCLUDE and BLAS_LIB variables to the installation folder of BLIS. Finally don't forget to set CPU_ONLY := 1.

Note: To build BLIS perform the following steps: https://github.com/flame/blis/wiki/BuildSystem.