Wrapper do not support 64-bit support of OpenBLAS

Issue #308 resolved
Marc Henning created an issue

With respect to issue #114 I want to ask whether support for 64-bit Versions of OpenBLAS is planned? The question why I’m asking is that I have to work with blaze on a university HPC cluster for a project with a square matrix of 64k rows.

I need to explicitly diagonalize this matrix using the the routine

template< typename MT1, bool SO1, typename VT, bool TF, typename MT2, bool SO2 >
void eigen( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V );

which itselfs calls subroutines from OpenBLAS. Unfortunately, since blaze uses regular ints to index the elements of this matrix in the syevd wrappers I am not able to allocate the respective memory because of

int lwork( 2*n*n + 6*n + 3 );

in syevd.h which results for n=64k in an overflow for an int. Even if the memory is present I thus cannot allocate it.

Currently, I manually changed the declarations from int to long as proposed when using the 64-bit version of OpenBLAS as described here at OpenBLAS issues.

This proceding seems rather fragile so I wonder whether blaze may support a simple directive for that in order to incorporate 64-bit BLAS libraries as well.

If there is a special reason for not doing so or if there are side-effects I am not aware of please tell me 🙂

Comments (9)

  1. Klaus Iglberger

    Hi Marc!

    Thanks a lot for creating this issue. You are correct, so far Blaze does not support the 64bit interface of OpenBLAS, but of course it should be possible to use Blaze for very large problems and to go beyond the limitations of int. We will definitely take a look into how we can provide a 64bit LAPACK mode, but cannot promise that this will be part of the next release of Blaze. For now, please continue to manually adapt the necessary LAPACK wrappers, this should have no bad side effect. Thanks again,

    Best regards,

    Klaus!

  2. Marc Henning reporter

    Dear Klaus!

    Thanks for your very fast answer - especially on Christmas. Merry Christmas by the way!

    Thanks for having a look inside providing a 64bit LAPACK mode in one of the next releases. That would be awesome given the fact that Blaze is perfectly usable for large scale problems - with the only limitation of the wrappers to BLAS/LAPACK.

    Provided that I only use eigen for computation of eigenvalues (and sometimes eigenvectors) of symmetric/Hermitian matrices: Do I need to make modifications elsewhere than in the syevd.h and underlying wrappers? I ask because Blaze seems to rely on BLAS/LAPACK at many different points (cf. Blaze Intro). And very often in the OpenBLAS Threads I read that the mixture of code using the 32-bit interface with the 64-bit OpenBLAS library is highly not recommended. Thanks again for your great help as well as the Blaze lib itself!

  3. Klaus Iglberger

    Hi Marc!

    We have used the last few days to implement a complete 64-bit support for both BLAS and LAPACK functions. You are now able to switch to 64-bit BLAS/LAPACK libraries by means of the BLAZE_BLAS_IS_64BIT compilation switch. You can either set this switch to 1 before including any Blaze header

    #define BLAZE_BLAS_IS_64BIT=1
    #include <blaze/Blaze.h>
    

    or on the command line:

    g++ ... -DBLAZE_BLAS_IS_64BIT=1 ...
    

    In case you encounter any problems, please feel free to (re-)open an issue.

    Best regards,

    Klaus!

  4. Klaus Iglberger

    Summary

    The feature has been implemented, tested, optimized, and documented as required. It is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.7.

    BLAS Mode

    In order to achieve maximum performance for multiplications with dense matrices, Blaze can be configured to use a BLAS library. Via the following compilation switch in the configuration file ./blaze/config/BLAS.h BLAS can be enabled:

    #define BLAZE_BLAS_MODE 1
    

    By default, Blaze assumes a 32-bit BLAS library. Via the BLAZE_BLAS_IS_64BIT compilation switch, the 64-bit BLAS mode can be selected:

    #define BLAZE_BLAS_IS_64BIT 1
    

    Note that the BLAZE_BLAS_IS_64BIT switch also has an effect on the LAPACK Functions

    In case the selected BLAS library provides parallel execution, the BLAZE_BLAS_IS_PARALLEL switch should be activated to prevent Blaze from parallelizing on its own:

    #define BLAZE_BLAS_IS_PARALLEL 1
    

    Additionally, it is possible to specify the name of the BLAS include file via the BLAZE_BLAS_INCLUDE_FILE switch. The default setting is <cblas.h>:

    #define BLAZE_BLAS_INCLUDE_FILE <cblas.h>
    

    Alternatively, all settings can be specified via command line or by defining the symbols manually before including any Blaze header file:

    #define BLAZE_BLAS_MODE 1
    #define BLAZE_BLAS_IS_64BIT 1
    #define BLAZE_BLAS_IS_PARALLEL 1
    #define BLAZE_BLAS_INCLUDE_FILE <cblas.h>
    #include <blaze/Blaze.h>
    

    In case no BLAS library is available, Blaze will still work and will not be reduced in functionality, but performance may be limited.

  5. Klaus Iglberger
    • changed status to open

    We have detected an issue that prevents the 64-bit mode from working correctly. We apologize for the inconvenience and will try to fix the issue as quickly as possible.

  6. Log in to comment