Giter Club home page Giter Club logo

hipsparse's Introduction

hipSPARSE

hipSPARSE is a SPARSE marshalling library with multiple supported backends. It sits between your application and a 'worker' SPARSE library, where it marshals inputs to the backend library and marshals results to your application. hipSPARSE exports an interface that doesn't require the client to change, regardless of the chosen backend. Currently, hipSPARSE supports rocSPARSE and cuSPARSE backends.

Documentation

Documentation for hipSPARSE is available at https://rocm.docs.amd.com/projects/hipSPARSE/en/latest/.

To build our documentation locally, run the following code:

cd docs

pip3 install -r sphinx/requirements.txt

python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html

Alternatively, build with CMake:

cmake -DBUILD_DOCS=ON ...

Installing pre-built packages

Download pre-built packages from ROCm's package servers using the following code:

`sudo apt update && sudo apt install hipsparse`

Build hipSPARSE

To build hipSPARSE, you can use our bash helper script (for Ubuntu only) or you can perform a manual build (for all supported platforms).

  • Bash helper script (install.sh): This script, which is located in the root of this repository, builds and installs hipSPARSE on Ubuntu with a single command. Note that this option doesn't allow much customization and hard-codes configurations that can be specified through invoking CMake directly. Some commands in the script require sudo access, so it may prompt you for a password.

    `./install -h`  # shows help
    `./install -id` # builds library, dependencies, then installs (the `-d` flag only needs to be passed once on a system)
  • Manual build: If you use a distribution other than Ubuntu, or would like more control over the build process, the hipSPARSE build wiki provides information on how to configure CMake and build hipSPARSE manually.

Supported functions

You can find a list of exported functions on our wiki.

Interface examples

The hipSPARSE interface is compatible with rocSPARSE and cuSPARSE-v2 APIs. Porting a CUDA application that calls the cuSPARSE API to an application that calls the hipSPARSE API is relatively straightforward. For example, the hipSPARSE SCSRMV interface is:

CSRMV API

hipsparseStatus_t
hipsparseScsrmv(hipsparseHandle_t handle,
                hipsparseOperation_t transA,
                int m, int n, int nnz, const float *alpha,
                const hipsparseMatDescr_t descrA,
                const float *csrValA,
                const int *csrRowPtrA, const int *csrColIndA,
                const float *x, const float *beta,
                float *y);

hipSPARSE assumes matrix A and vectors x, y are allocated in GPU memory space filled with data. Users are responsible for copying data to and from the host and device memory.

hipsparse's People

Contributors

aaronenyeshi avatar afanfa avatar agonzales-amd avatar alexbrownamd avatar aligirayhanozbay avatar amd-jmacaran avatar amdkila avatar angeloo01 avatar arvindcheru avatar cgmb avatar dependabot[bot] avatar eidenyoshida avatar evetsso avatar jsandham avatar lawruble13 avatar lisadelaney avatar maetveis avatar matyas-streamhpc avatar ntrost57 avatar pavahora avatar peterjunpark avatar poznano-amd avatar pruthvistony avatar randyh62 avatar raramakr avatar saadrahim avatar samjwu avatar urmbista avatar yvanmokwinski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hipsparse's Issues

Build homogeneity for CMake options?

Both hipBLAS and hipSOLVER use "USE_CUDA=ON" to specify a CUDA backend build,
whereas hipSPARSE currently uses "BUILD_CUDA=ON".
(hipFFT uses yet another one)

It would probably ease installation efforts if the syntax could be made more homogeneous.

Thanks,

unclear buffersize

Hello,

In the documentation, in the generic API section, the _buffersize functions do not specify whether the buffer size is in bytes or in elements. Should I allocate buffersize or buffersize * sizeof(double) bytes of memory for the buffer?

Please clarify that in the docs.

[bug] Wrong `CUDA_VERSION` for `hipsparseSpVecDescr_t` and `hipsparseDnVecDescr_t`

The corresponding to hipsparseSpVecDescr_t and hipsparseDnVecDescr_t cuSPARSE APIs cusparseSpVecDescr_t and cusparseDnVecDescr_t appeared in CUDA 10.2, not in CUDA 10.1.

https://github.com/ROCmSoftwarePlatform/hipSPARSE/blob/develop/library/include/hipsparse.h#LL8777C1-L8783C7:

/* Generic API opaque structures holding information */
#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010)
typedef void* hipsparseSpVecDescr_t;
typedef void* hipsparseSpMatDescr_t;
typedef void* hipsparseDnVecDescr_t;
typedef void* hipsparseDnMatDescr_t;
#endif

Wrong hipsparseSpSV_solve argument

cusparseSpSV_solve does not receive buffer as the last argument but hipsparseSpSV_solve does.
If this was not intentional, it should be fixed.

cusparseSpSV_solve
https://docs.nvidia.com/cuda/cusparse/#cusparsespsv

hipsparseSpSV_solve

hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t           handle,
                                      hipsparseOperation_t        opA,
                                      const void*                 alpha,
                                      const hipsparseSpMatDescr_t matA,
                                      const hipsparseDnVecDescr_t x,
                                      const hipsparseDnVecDescr_t y,
                                      hipDataType                 computeType,
                                      hipsparseSpSVAlg_t          alg,
                                      hipsparseSpSVDescr_t        spsvDescr,
                                      void*                       externalBuffer);

Build error for 3.5.0 on Arch Linux

I'm compiling ROCm 3.5.0 on Arch Linux and using hip with its new ROCclr backend. I could compile all ROCm libs (rocblas, rocsparse, rocalution, ...) except hipsparse:

[ 50%] Building CXX object library/CMakeFiles/hipsparse.dir/src/hcc_detail/hipsparse.cpp.o
/build/hipsparse/src/hipSPARSE-rocm-3.5.0/library/src/hcc_detail/hipsparse.cpp:6381:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
In file included from /build/hipsparse/src/hipSPARSE-rocm-3.5.0/library/src/hcc_detail/hipsparse.cpp:24:
In file included from /build/hipsparse/src/hipSPARSE-rocm-3.5.0/library/include/hipsparse.h:41:
In file included from /opt/rocm/hip/include/hip/hip_complex.h:29:
In file included from /opt/rocm/hip/include/hip/hcc_detail/hip_complex.h:26:
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1186:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned char, 2>::HIP_vector_type<unsigned char, unsigned char, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(unsigned char, uchar2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1187:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned char, 3>::HIP_vector_type<unsigned char, unsigned char, unsigned char, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(unsigned char, uchar3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1188:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned char, 4>::HIP_vector_type<unsigned char, unsigned char, unsigned char, unsigned char, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(unsigned char, uchar4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1191:1: note: in instantiation of function template specialization 'HIP_vector_type<char, 2>::HIP_vector_type<signed char, signed char, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(signed char, char2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1192:1: note: in instantiation of function template specialization 'HIP_vector_type<char, 3>::HIP_vector_type<signed char, signed char, signed char, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(signed char, char3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1193:1: note: in instantiation of function template specialization 'HIP_vector_type<char, 4>::HIP_vector_type<signed char, signed char, signed char, signed char, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(signed char, char4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1196:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned short, 2>::HIP_vector_type<unsigned short, unsigned short, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(unsigned short, ushort2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1197:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned short, 3>::HIP_vector_type<unsigned short, unsigned short, unsigned short, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(unsigned short, ushort3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1198:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned short, 4>::HIP_vector_type<unsigned short, unsigned short, unsigned short, unsigned short, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(unsigned short, ushort4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1201:1: note: in instantiation of function template specialization 'HIP_vector_type<short, 2>::HIP_vector_type<short, short, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(signed short, short2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1202:1: note: in instantiation of function template specialization 'HIP_vector_type<short, 3>::HIP_vector_type<short, short, short, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(signed short, short3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1203:1: note: in instantiation of function template specialization 'HIP_vector_type<short, 4>::HIP_vector_type<short, short, short, short, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(signed short, short4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1206:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned int, 2>::HIP_vector_type<unsigned int, unsigned int, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(unsigned int, uint2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1207:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned int, 3>::HIP_vector_type<unsigned int, unsigned int, unsigned int, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(unsigned int, uint3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1208:1: note: in instantiation of function template specialization 'HIP_vector_type<unsigned int, 4>::HIP_vector_type<unsigned int, unsigned int, unsigned int, unsigned int, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(unsigned int, uint4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1211:1: note: in instantiation of function template specialization 'HIP_vector_type<int, 2>::HIP_vector_type<int, int, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(signed int, int2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1212:1: note: in instantiation of function template specialization 'HIP_vector_type<int, 3>::HIP_vector_type<int, int, int, nullptr>' requested here
DECLOP_MAKE_THREE_COMPONENT(signed int, int3);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1156:53: note: expanded from macro 'DECLOP_MAKE_THREE_COMPONENT'
    type make_##type(comp x, comp y, comp z) { type r{x, y, z}; return r; }
                                                    ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1213:1: note: in instantiation of function template specialization 'HIP_vector_type<int, 4>::HIP_vector_type<int, int, int, int, nullptr>' requested here
DECLOP_MAKE_FOUR_COMPONENT(signed int, int4);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1161:14: note: expanded from macro 'DECLOP_MAKE_FOUR_COMPONENT'
        type r{x, y, z, w}; \
             ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:585:17: error: no matching function for call to 'operator new'
                new (&data) Native_vec_{static_cast<T>(xs)...};
                ^~~
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1216:1: note: in instantiation of function template specialization 'HIP_vector_type<float, 2>::HIP_vector_type<float, float, nullptr>' requested here
DECLOP_MAKE_TWO_COMPONENT(float, float2);
^
/opt/rocm/hip/include/hip/hcc_detail/hip_vector_types.h:1152:45: note: expanded from macro 'DECLOP_MAKE_TWO_COMPONENT'
    type make_##type(comp x, comp y) { type r{x, y}; return r; }
                                            ^
note: candidate function not viable: requires 1 argument, but 2 were provided
note: candidate function not viable: requires 1 argument, but 2 were provided

Add a hipsparseGetErrorString() function ?

#define CHECK_HIPSPARSE(func)                                                   \
{                                                                              \
    hipsparseStatus_t status = (func);                                          \
    if (status != HIPSPARSE_STATUS_SUCCESS) {                                   \
        printf("HIPSPARSE API failed at line %d with error: %s (%d)\n",         \
               __LINE__, hipsparseGetErrorString(status), status);              \
        return EXIT_FAILURE;                                                   \
    }                                                                          \
}

[bug] deps/convert: Unable to execute binary file

When I was in cmake, it prompted "-- Downloading and extracting test matrix SNAP/amazon0312.tar.gz
/home/loongson/ROCm/rocSPARSE/deps/convert: /home/loongson/ROCm/rocSPARSE/deps/convert:
Unable to execute binary file".
My system is based on mips. It cannot execute this binary file, can you share it?
So I can compile it from source code by myself, this convert

HIPSPARSE_STATUS_INVALID_VALUE from hipsparseSpGEMM_compute

I migrated a CUDA program that executes the cusparseSpGEMM function. While the CUDA program runs without errors, the HIP program reports the following error. I am not sure if the error is caused by the library or subtle differences between the API functions I am not aware of. Thank you for taking a look at the program.

To reproduce:

cd into the directory "spmm-hip" in https://github.com/zjin-lcf/HeCBench/tree/master/spmm-hip
make
./main 1024 1024 1024 1024 1024 1 1
hipSPARSE error: HIPSPARSE API failed at line 261 with error: HIPSPARSE_STATUS_INVALID_VALUE

[5.7.0] Probably typo in `hipsparseCcsrilu02_numericBoost` implementation

Shouldn't rocsparse_ccsrilu0_numeric_boost be called from hipsparseCcsrilu02_numericBoost instead of rocsparse_dccsrilu0_numeric_boost?

hipsparseStatus_t hipsparseCcsrilu02_numericBoost(hipsparseHandle_t handle,
                                                  csrilu02Info_t    info,
                                                  int               enable_boost,
                                                  double*           tol,
                                                  hipComplex*       boost_val)
{
    return rocSPARSEStatusToHIPStatus(
        rocsparse_dccsrilu0_numeric_boost((rocsparse_handle)handle, // <== rocsparse_ccsrilu0_numeric_boost ?
                                          (rocsparse_mat_info)info,
                                          enable_boost,
                                          tol,
                                          (rocsparse_float_complex*)boost_val));
}

hipsparse in rocm repositories

First of all: Thanks for building an alternative to the nvidia universe out there!

I just tried to build pytorch and needed rocsparse and hipsparse (at least the errors tell me that). I noticed that the README tells me to install it via apt but it's not in the repo... Is that intentional?

I have installed the whole rocm-stack by following the instructions here: https://rocm.github.io/install.html#installing-from-amd-rocm-repositories and the tensorflow examples work as intended so I assume it is set up properly.

Edit: I use Ubuntu 18.04

Can not use headers from c files compiled with gcc 9

In file included from /workspaces/OpenFOAM/ThirdParty-v2112/petsc-3.18.1/include/petscdevice_hip.h:16,
                 from /workspaces/OpenFOAM/ThirdParty-v2112/petsc-3.18.1/include/../src/vec/is/sf/impls/basic/sfpack.h:12,
                 from /workspaces/OpenFOAM/ThirdParty-v2112/petsc-3.18.1/src/vec/is/sf/impls/basic/sfpack.c:2:
/opt/rocm/include/hipsparse/hipsparse.h:8741:28: error: expected ‘,’ or ‘}’ before ‘[’ token
 8741 |     HIPSPARSE_ORDER_COLUMN [[deprecated("Please use HIPSPARSE_ORDER_COL instead")]] = 1,
hipconfig
hipconfig
HIP version  : 5.4.22801-aaa1e3d8

== hipconfig
HIP_PATH     : /opt/rocm-5.4.0
ROCM_PATH    : /opt/rocm
HIP_COMPILER : clang
HIP_PLATFORM : amd
HIP_RUNTIME  : rocclr
CPP_CONFIG   :  -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I/opt/rocm-5.4.0/include -I/opt/rocm/llvm/bin/../lib/clang/15.0.0 -I/opt/rocm/hsa/include

== hip-clang
HSA_PATH         : /opt/rocm/hsa
HIP_CLANG_PATH   : /opt/rocm/llvm/bin
AMD clang version 15.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.4.0 22465 d6f0fe8b22e3d8ce0f2cbd657ea14b16043018a5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm/llvm/bin
AMD LLVM version 15.0.0git
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: znver3

  Registered Targets:
    amdgcn - AMD GCN GPUs
    r600   - AMD GPUs HD2XXX-HD6XXX
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64
hip-clang-cxxflags :  -isystem "/opt/rocm-5.4.0/llvm/lib/clang/15.0.0/include/.." -isystem /opt/rocm/hsa/include -is"/opt/rocm-5.4.0/include" -O3
hip-clang-ldflags  :  -L"/opt/rocm-5.4.0/lib" -O3 -lgcc_s -lgcc -lpthread -lm -lrt

=== Environment Variables
PATH=/vscode/vscode-server/bin/linux-x64/6261075646f055b99068d3688932416f2346dd3b/bin/remote-cli:/home/rocm-user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rocm/bin

== Linux Kernel
Hostname     : cfd6b6261979
Linux cfd6b6261979 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal
gcc version
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Even tough [[deprecated]] is standard in C++17, it is only standardized in C23.
GCC 10 implements [[deprecated]] as a language extension in earlier C modes, clang only implements it with the -std=c2x flag. See this minimal reproducer on godbolt

HIPSPARSE_STATUS_INVALID_VALUE from hipsparseSpSM_bufferSize

I migrated a CUDA program that executes the cusparseSpSM function. The HIP program reports the following error for the given command-line options. I am not sure if the error is caused by the library. Thank you for taking a look at the program.

To reproduce:

cd into the directory "spsm-hip" in https://github.com/zjin-lcf/HeCBench/tree/master/src/spsm-hip
make
./main 4 2 9 1 1
hipSPARSE error: HIPSPARSE API failed at line 224 with error: HIPSPARSE_STATUS_INVALID_VALUE

'boost::wrapexcept<std::logic_error>'

clients/staging/rocsparse-bench 
terminate called after throwing an instance of 'boost::wrapexcept<std::logic_error>'
  what():  character conversion failed
Aborted (core dumped)

my changes to the default configutation

Commandline options:
-DAMDGPU_TARGETS:STRING="gfx803" -Drocprim_DIR:PATH="/opt/rocm/lib/cmake/rocprim" -DGPU_TARGETS:STRING="gfx803" -DROCSPARSE_CONFIG_DIR:PATH="${CPACK_PACKAGING_INSTALL_PREFIX}/lib" 


Cache file:
AMDGPU_TARGETS:STRING=gfx803
rocprim_DIR:PATH=/opt/rocm/lib/cmake/rocprim
GPU_TARGETS:STRING=gfx803
ROCSPARSE_CONFIG_DIR:PATH=${CPACK_PACKAGING_INSTALL_PREFIX}/lib

let me know what I can do

Build issue - 'Label field of continuation line is not blank' in Fortran files

What is the expected behavior

Build completes successfully. Renaming the .f files to .f90 fixes all issues - see #209

What actually happens

Build fails. Below you may find the output from CMake:

-- The CXX compiler identification is Clang 13.0.0
-- The Fortran compiler identification is Flang 99.99.1
-- Check for working CXX compiler: /opt/rocm/bin/hipcc
-- Check for working CXX compiler: /opt/rocm/bin/hipcc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working Fortran compiler: /opt/rocm/llvm/bin/flang
-- Check for working Fortran compiler: /opt/rocm/llvm/bin/flang  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /opt/rocm/llvm/bin/flang supports Fortran 90
-- Checking whether /opt/rocm/llvm/bin/flang supports Fortran 90 -- yes
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Found HIP: /opt/rocm-4.3.0/hip (found version "4.3.21300-5bbc51d8") 
-- Performing Test HIP_CLANG_SUPPORTS_PARALLEL_JOBS
-- Performing Test HIP_CLANG_SUPPORTS_PARALLEL_JOBS - Success
sh: 1: lsmod: not found
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- ROCclr at /opt/rocm/lib/cmake/rocclr
-- hip::amdhip64 is SHARED_LIBRARY
sh: 1: lsmod: not found
-- ROCclr at /opt/rocm/lib/cmake/rocclr
-- hip::amdhip64 is SHARED_LIBRARY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /rocm-build/build/hipsparse
[1/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_roti.dir/example_fortran_roti.f90-pp.f90
[2/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_dotci.dir/example_fortran_dotci.f90-pp.f90
[3/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_auxiliary.dir/example_fortran_auxiliary.f90-pp.f90
[4/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_bsric02.dir/example_fortran_bsric02.f90-pp.f90
[5/72] Building Fortran preprocessed library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse_enums.f-pp.f
clang-13: warning: argument unused during compilation: '-std=f2003' [-Wunused-command-line-argument]
clang-13: warning: argument unused during compilation: '-ffree-form' [-Wunused-command-line-argument]
[6/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_csrilu02.dir/example_fortran_csrilu02.f90-pp.f90
[7/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_spmv.dir/example_fortran_spmv.f90-pp.f90
[8/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_csrsv2.dir/example_fortran_csrsv2.f90-pp.f90
[9/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_bsrmm.dir/example_fortran_bsrmm.f90-pp.f90
[10/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_csrsm2.dir/example_fortran_csrsm2.f90-pp.f90
[11/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_csric02.dir/example_fortran_csric02.f90-pp.f90
[12/72] Building Fortran preprocessed clients/samples/CMakeFiles/example_fortran_bsrilu02.dir/example_fortran_bsrilu02.f90-pp.f90
[13/72] Building Fortran preprocessed library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse.f-pp.f
clang-13: warning: argument unused during compilation: '-std=f2003' [-Wunused-command-line-argument]
clang-13: warning: argument unused during compilation: '-ffree-form' [-Wunused-command-line-argument]
[14/72] Generating Fortran dyndep file library/CMakeFiles/hipsparse_fortran.dir/Fortran.dd
[15/72] Building Fortran object library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse_enums.f.o
FAILED: library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse_enums.f.o include/hipsparse_enums.mod 
/opt/rocm/llvm/bin/flang  -I//hipSPARSE/library/src -O3 -DNDEBUG -Jinclude   -std=f2003 -ffree-form -cpp -c library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse_enums.f-pp.f -o library/CMakeFiles/hipsparse_fortran.dir/src/hipsparse_enums.f.o
clang-13: warning: argument unused during compilation: '-ffree-form' [-Wunused-command-line-argument]
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 24)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 25)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 32)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 33)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 34)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 35)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 36)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 37)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 38)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 39)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 40)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 41)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 43)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 46)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 42)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 47)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 49)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 52)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 48)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 53)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 55)
F90-S-0021-Label field of continuation line is not blank (/hipSPARSE/library/src/hipsparse_enums.f: 58)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 54)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 59)
F90-S-0034-Syntax error at or near :: (/hipSPARSE/library/src/hipsparse_enums.f: 60)
F90-F-0008-Error limit exceeded (/hipSPARSE/library/src/hipsparse_enums.f: 60)
F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted
[16/72] Building CXX object clients/samples/CMakeFiles/example_fortran_roti.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[17/72] Building CXX object clients/samples/CMakeFiles/example_fortran_spmv.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[18/72] Building CXX object clients/samples/CMakeFiles/example_fortran_bsrmm.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[19/72] Building CXX object clients/samples/CMakeFiles/example_fortran_csric02.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[20/72] Building CXX object clients/samples/CMakeFiles/example_fortran_csrsm2.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[21/72] Building CXX object clients/samples/CMakeFiles/example_fortran_bsrilu02.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[22/72] Building CXX object clients/samples/CMakeFiles/example_handle.dir/example_handle.cpp.o
sh: 1: lsmod: not found
[23/72] Building CXX object clients/samples/CMakeFiles/example_handle.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[24/72] Building CXX object clients/samples/CMakeFiles/example_fortran_auxiliary.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[25/72] Building CXX object clients/samples/CMakeFiles/example_fortran_csrilu02.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[26/72] Building CXX object clients/samples/CMakeFiles/example_fortran_bsric02.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[27/72] Building CXX object clients/samples/CMakeFiles/example_csrmv.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[28/72] Building CXX object clients/samples/CMakeFiles/example_hybmv.dir/example_hybmv.cpp.o
sh: 1: lsmod: not found
[29/72] Building CXX object clients/samples/CMakeFiles/example_fortran_dotci.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[30/72] Building CXX object clients/samples/CMakeFiles/example_csrmv.dir/example_csrmv.cpp.o
sh: 1: lsmod: not found
[31/72] Building CXX object clients/samples/CMakeFiles/example_fortran_csrsv2.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[32/72] Building CXX object clients/samples/CMakeFiles/example_hybmv.dir/__/common/utility.cpp.o
sh: 1: lsmod: not found
[33/72] Building CXX object library/CMakeFiles/hipsparse.dir/src/hcc_detail/hipsparse.cpp.o
sh: 1: lsmod: not found
ninja: build stopped: subcommand failed.

How to reproduce

I attempted building git develop version of hipsparse in Ubuntu 20.04 after installing the rocm-dev package. I can provide a Dockerfile of my environment if requested.

Add support for the cusparseSgemmi API

I was looking into what it would take to Marian-NMT to HIP (note: I am not affiliated with the project). Having gone through an initial hipification, I stumbled into a function call to cusparseSgemmi, which does not seem to be supported by hipSPARSE/rocSPARSE as far as I can tell from the documentation and source code.

Is this something that happens to be in your roadmap? Thanks for all of your efforts!

hipsparseScsrmm output not match

Hi there, I try to use hipsparseScsrmm to perform the sparse matrix multiplication, and found that the output results are not aligned with the dense computation, Is there anything wrong in my code? Any help is appreciated. Thanks.

#include <cmath>
#include <cstdint>
#include <fstream>
#include "iostream"
#include "sstream"
#include "time.h"
#include "memory"
#include "vector"
#include <hip/hip_runtime.h>
#include <hipsparse.h>
using namespace std;

int32_t * row_idx, *col_idx, *d_row_idx, *d_col_idx, *row_swizzle, *d_row_swizzle;
int32_t row_idx_size, col_idx_size, values_size;
float * values, *d_values;
float * matA, *matB, *matC,*d_matA, *d_matB, *d_matC;
int m, k, n;
float alpha=1.0, beta=0.0;

#define CUDNN_SAFE_CALL(func)                                                                      \
do                                                                                             \
{                                                                                              \
    cudnnStatus_t e = (func);                                                                  \
    if (e != CUDNN_STATUS_SUCCESS)                                                             \
    {                                                                                          \
        const char* msg = cudnnGetErrorString(e);                                              \
        std::stringstream safe_call_ss;                                                        \
        safe_call_ss << "\nerror: " #func " failed with error"                                 \
                        << "\nfile: " << __FILE__ << "\nline: " << __LINE__ << "\nmsg: " << msg;  \
        throw std::runtime_error(safe_call_ss.str());                                          \
    }                                                                                          \
    } while (0)
#define CUBLAS_SAFE_CALL(func)                                                                     \
do                                                                                             \
{                                                                                              \
    cublasStatus_t e = (func);                                                                 \
    if (e != CUBLAS_STATUS_SUCCESS)                                                            \
    {                                                                                          \
        std::stringstream safe_call_ss;                                                        \
        safe_call_ss << "\nerror: " #func " failed with error"                                 \
                        << "\nfile: " << __FILE__ << "\nline: " << __LINE__ << "\nmsg: " << e;    \
        throw std::runtime_error(safe_call_ss.str());                                          \
    }                                                                                          \
} while (0)

#define CUDA_SAFE_CALL(x)                                                                          \
do                                                                                             \
{                                                                                              \
    hipError_t result = (x);                                                                  \
    if (result != hipSuccess)                                                                 \
    {                                                                                          \
        const char* msg = hipGetErrorString(result);                                          \
        std::stringstream safe_call_ss;                                                        \
        safe_call_ss << "\nerror: " #x " failed with error"                                    \
                        << "\nfile: " << __FILE__ << "\nline: " << __LINE__ << "\nmsg: " << msg;  \
        throw std::runtime_error(safe_call_ss.str());                                          \
    }                                                                                          \
} while (0)


void init(float * ptr, size_t length, float sparsity)
{
    for (int i = 0; i < length; i++)
    {
        float pro = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
        if (pro < sparsity)
        {
            ptr[i] = 0.0;
        }
        else
        {
            ptr[i] = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
        }
    }
}

void convert_csr(float * ptr, int32_t row, int32_t col, int32_t * &row_idx, int32_t * &col_idx, float * &values)
{
    auto v_row_idx = std::make_shared<vector<int32_t>>();
    auto v_col_idx = std::make_shared<vector<int32_t>>();
    auto v_values = std::make_shared<vector<float>>();

    for (int i = 0; i < row; i++)
    {
        v_row_idx->push_back(v_values->size());
        for (int j = 0; j < col; j++)
        {
            size_t pos = i * col + j;
            if (ptr[pos] < 1e-8)
            {
                // sparsity
                continue;
            }
            else
            {
                v_values->push_back(ptr[pos]);
                v_col_idx->push_back(j);
            }
        }
    }
    v_row_idx->push_back(v_values->size());
    row_idx_size = sizeof(int32_t)*v_row_idx->size();
    col_idx_size = sizeof(int32_t)*v_col_idx->size();
    values_size = sizeof(float)*v_values->size();
    row_idx = (int32_t*) malloc(row_idx_size);
    col_idx = (int32_t*) malloc(col_idx_size);
    values = (float*) malloc(values_size);
    memcpy(row_idx, v_row_idx->data(), row_idx_size);
    memcpy(col_idx, v_col_idx->data(), col_idx_size);
    memcpy(values, v_values->data(), values_size);
}
int main()
{
    string row_f, col_f, value_f;
    int m=1024, k=1024, n=1024;
    int sparsity = 0.95;
    matA = (float*) malloc(sizeof(float)*m*k);
    matB = (float*) malloc(sizeof(float)*k*n);
    matC = (float*) malloc(sizeof(float)*m*n);
    init(matA, m*k, sparsity);
    init(matB, k*n, 0);
    convert_csr(matA, m, k, row_idx, col_idx, values);

    CUDA_SAFE_CALL(hipMalloc(&d_matA, sizeof(float)*m*k));
    CUDA_SAFE_CALL(hipMalloc(&d_matB, sizeof(float)*n*k));
    CUDA_SAFE_CALL(hipMalloc(&d_row_idx, row_idx_size));
    CUDA_SAFE_CALL(hipMalloc(&d_col_idx, col_idx_size));
    CUDA_SAFE_CALL(hipMalloc(&d_values, values_size));
    CUDA_SAFE_CALL(hipMalloc(&d_matC, sizeof(float)*m*n));
    CUDA_SAFE_CALL(hipMemcpy(d_matA, matA, sizeof(float)*m*k, hipMemcpyHostToDevice));
    CUDA_SAFE_CALL(hipMemcpy(d_matB, matB, sizeof(float)*n*k, hipMemcpyHostToDevice));
    CUDA_SAFE_CALL(hipMemcpy(d_row_idx, row_idx, row_idx_size, hipMemcpyHostToDevice));
    CUDA_SAFE_CALL(hipMemcpy(d_col_idx, col_idx, col_idx_size, hipMemcpyHostToDevice));
    CUDA_SAFE_CALL(hipMemcpy(d_values, values, values_size, hipMemcpyHostToDevice));

    int nnz = values_size / sizeof(float);

    hipsparseHandle_t handle;
    hipsparseCreate(&handle);
    hipsparseMatDescr_t descrA;
    hipsparseCreateMatDescr(&descrA);
    hipsparseScsrmm(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, m, n, k, nnz, &alpha, descrA, d_values, d_row_idx, d_col_idx, d_matB, k, &beta, d_matC, m);
    // hipsparseScsrmm2(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, HIPSPARSE_OPERATION_NON_TRANSPOSE, m, n, k, nnz, &alpha, descrA, d_values, d_row_idx, d_col_idx, d_matB, k, &beta, d_matC, m);

    hipDeviceSynchronize();

    CUDA_SAFE_CALL(hipMemcpy(matC, d_matC, sizeof(float)*m*n, hipMemcpyDeviceToHost));
    for(int i=0;i<20;i++)
        std::cout<<matC[i]<<" ";
    std::cout<<"\n"<<std::endl;
    memset(matC, 0,sizeof(float)*m*n);
    for(int i=0;i<20;i++){
        for(int j=0; j<20;j++){
            for(int tmp=0;tmp<k;tmp++){
                // matc[i][j] = sum(A[i][tmp]*B[tmp][j])
                matC[i*n+j] += matA[i*k+tmp] * matB[tmp*n+j];
            }
        }
    }
    // CUBLAS_SAFE_CALL(cublasSgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, m, n, k, &alpha, d_matA, m, d_matB, k, &beta, d_matC, m));
    // CUDA_SAFE_CALL(cudaMemcpy(matC, d_matC, sizeof(float)*m*n, cudaMemcpyDeviceToHost));
    for(int i=0;i<20;i++)
        std::cout<<matC[i]<<" ";
    std::cout<<"\n"<<std::endl;


    hipsparseDestroyMatDescr(descrA);
    hipsparseDestroy(handle);

    return 0;
}

image

Don't use find_package(HIP REQUIRED)

This package uses find_package(HIP REQUIRED).

There is both a module FindHIP.cmake and a hip-config.cmake file, it's ambiguous because search is case-insensitive, so please specify whether it's the module or the config file explicitly, like find_package(HIP MODULE REQUIRED) or find_package(HIP REQUIRED CONFIG).

From the CMake docs:

In Module mode, CMake searches for a file called Find.cmake. The file is first searched in the CMAKE_MODULE_PATH, then among the Find Modules provided by the CMake installation.

If the MODULE option is not specified in the above signature, CMake first searches for the package using Module mode. Then, if the package is not found, it searches again using Config mode.

The Spack package manager sets CMAKE_PREFIX_PATH to the hip install prefix, but since this is only used only in Config mode, no module is found, so when it switches to Config mode it detects hip-config.cmake. (see spack/spack#25264)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.