Commit 6b579ed9 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed check for HAVE_CUSPARSE

It is not needed, since CUSPARSE is included in all versions of CUDA
since at least 7.0.

Also note that CUSPARSE is needed only for some tests and legacy code
(tnl-benchmark-spmv and wrappers in Matrices::CSR) and experimental code
(Preconditioners::ILU0). Everything is still guarded by the
HAVE_CUSPARSE macro, so the user can pass -DHAVE_CUSPARSE -lcusparse to
the compiler to enable the features.
parent 91dce530
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -170,25 +170,6 @@ if( ${WITH_CUDA} )
        set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES )
        # TODO: this is necessary only due to a bug in cmake
        set( CUDA_ADD_LIBRARY_OPTIONS -shared )

        ####
        # Check for CUSPARSE
        #
        if( WITH_CUSPARSE )
           find_path( CUSPARSE_INCLUDE_DIR cusparse.h
                      /usr/local/cuda/include
                      ${CUDA_INCLUDE_DIR}
                      DOC "CUSPARSE headers." )
           if( ${CUSPARSE_INCLUDE_DIR} STREQUAL "CUSPARSE_INCLUDE_DIR-NOTFOUND" )
               message( "CUSPARSE not found." )
               set( HAVE_CUSPARSE "//#define HAVE_CUSPARSE 1" )
           else()
               message( "CUSPARSE found. -- ${CUSPARSE_INCLUDE_DIR}" )
               set( HAVE_CUSPARSE "#define HAVE_CUSPARSE 1" )
               cuda_include_directories( ${CUSPARSE_INCLUDE_DIR} )
               set( CUSPARSE_LIBRARY "${CUDA_cusparse_LIBRARY}" )
           endif()
        endif()
    endif()
endif()

+4 −4
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#include <TNL/Containers/Vector.h>
#include <TNL/Matrices/CSR.h>

#ifdef HAVE_CUDA
#if defined(HAVE_CUDA) && defined(HAVE_CUSPARSE)
#include <cusparse.h>
#endif

@@ -66,7 +66,7 @@ public:

   ILU0()
   {
#ifdef HAVE_CUDA
#if defined(HAVE_CUDA) && defined(HAVE_CUSPARSE)
      cusparseCreate( &handle );
#endif
   }
@@ -84,14 +84,14 @@ public:

   ~ILU0()
   {
#ifdef HAVE_CUDA
#if defined(HAVE_CUDA) && defined(HAVE_CUSPARSE)
      resetMatrices();
      cusparseDestroy( handle );
#endif
   }

protected:
#ifdef HAVE_CUDA
#if defined(HAVE_CUDA) && defined(HAVE_CUSPARSE)
   Matrices::CSR< RealType, DeviceType, IndexType > A;
   Containers::Vector< RealType, DeviceType, IndexType > y;

+8 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ ILU0< double, Devices::Cuda, int >::
update( const MatrixPointer& matrixPointer )
{
#ifdef HAVE_CUDA
#ifdef HAVE_CUSPARSE
   // TODO: only numerical factorization has to be done every time, split the rest into separate "setup" method which is called less often
   resetMatrices();

@@ -254,6 +255,9 @@ update( const MatrixPointer& matrixPointer )
      std::cerr << "A(" << numerical_zero << ", " << numerical_zero << ") is zero." << std::endl;
      throw 1;
   }
#else
   throw std::runtime_error("The program was not compiled with the CUSPARSE library. Pass -DHAVE_CUSPARSE -lcusparse to the compiler.")
#endif
#else
   throw Exceptions::CudaSupportMissing();
#endif
@@ -265,6 +269,7 @@ ILU0< double, Devices::Cuda, int >::
solve( const Vector1& b, Vector2& x ) const
{
#ifdef HAVE_CUDA
#ifdef HAVE_CUSPARSE
   const int m = A.getRows();
   const int nnz = A.getValues().getSize();

@@ -289,6 +294,9 @@ solve( const Vector1& b, Vector2& x ) const
                          policy_U, (void*) pBuffer.getData() );

   return true;
#else
   throw std::runtime_error("The program was not compiled with the CUSPARSE library. Pass -DHAVE_CUSPARSE -lcusparse to the compiler.")
#endif
#else
   throw Exceptions::CudaSupportMissing();
#endif
+3 −3
Original line number Diff line number Diff line
@@ -4,13 +4,13 @@ ADD_SUBDIRECTORY( heat-equation-benchmark )
IF( BUILD_CUDA )
    CUDA_ADD_EXECUTABLE( tnl-benchmark-blas tnl-benchmark-blas.cu )
    CUDA_ADD_CUBLAS_TO_TARGET( tnl-benchmark-blas )
    TARGET_LINK_LIBRARIES( tnl-benchmark-blas tnl ${CUSPARSE_LIBRARY} )
    TARGET_LINK_LIBRARIES( tnl-benchmark-blas tnl )

    CUDA_ADD_EXECUTABLE( tnl-benchmark-spmv tnl-benchmark-spmv.cu )
    TARGET_LINK_LIBRARIES( tnl-benchmark-spmv tnl ${CUSPARSE_LIBRARY} )
    TARGET_LINK_LIBRARIES( tnl-benchmark-spmv tnl ${CUDA_cusparse_LIBRARY} )

    CUDA_ADD_EXECUTABLE( tnl-benchmark-linear-solvers tnl-benchmark-linear-solvers.cu )
    TARGET_LINK_LIBRARIES( tnl-benchmark-linear-solvers tnl ${CUSPARSE_LIBRARY} )
    TARGET_LINK_LIBRARIES( tnl-benchmark-linear-solvers tnl )
ELSE()
    ADD_EXECUTABLE( tnl-benchmark-blas tnl-benchmark-blas.cpp )
    TARGET_LINK_LIBRARIES( tnl-benchmark-blas tnl )
+0 −4
Original line number Diff line number Diff line
@@ -4,10 +4,6 @@

@HAVE_SYS_IOCTL_H@

#ifdef HAVE_CUDA
    @HAVE_CUSPARSE@
#endif

@HAVE_DCMTK_H@

@HAVE_PNG_H@