Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: sparse-sparse add/sub support #2312

Merged
merged 4 commits into from Dec 19, 2018
Merged

Conversation

9prady9
Copy link
Member

@9prady9 9prady9 commented Oct 11, 2018

  • CPU backend:

    • Use mkl sparse-sparse add/sub when available
    • Fallback cpu implementation: has support for mul and div too
  • CUDA backend sparse-sparse add/sub

  • OpenCL backend sparse-sparse add/sub/div/mul

The output of sub/div/mul is not guaranteed to have only
non-zero results of the arithmetic operation. The user has
to take care of pruning the zero results from the output.

Support for div/mul isn't exposed to the user yet as it is not uniform across all backends or even within CPU backend at the moment.

Also moved mkl interface defs in CPU backend into single source file

@9prady9
Copy link
Member Author

9prady9 commented Oct 11, 2018

I have a pending issue on CPU backend that I am currently debugging but the other two backends work as expected. It is probably some typo, will get it soon.

Update - Resolved: It was a mistake on my end mixing up custom code with MKL upstream calls that caused the segfaults.

@9prady9
Copy link
Member Author

9prady9 commented Oct 16, 2018

Update: There are some additional changes I need to make to sparse array creation when MKL upstream is used in CPU backend. It involves replacing deprecated API with newest.

Copy link
Member

@umar456 umar456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial run through this. Some of the inner loops can be improved. I wonder if it would be better if we allocated memory based on the worst case scenario rather than the exact size. Will require experimentation.

src/backend/cpu/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/cpu/sparse_arith.cpp Outdated Show resolved Hide resolved
src/backend/cpu/sparse_arith.cpp Outdated Show resolved Hide resolved
src/backend/cpu/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/cpu/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/cpu/kernel/sparse_arith.hpp Show resolved Hide resolved
src/backend/cpu/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/cpu/sparse_blas.cpp Outdated Show resolved Hide resolved
src/backend/cpu/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
@9prady9 9prady9 force-pushed the sparse_arith branch 2 times, most recently from cbf1c41 to d65af90 Compare October 17, 2018 17:27
@9prady9 9prady9 dismissed umar456’s stale review October 17, 2018 17:28

Addressed feedback

@9prady9
Copy link
Member Author

9prady9 commented Oct 17, 2018

I will look into the windows compiler errors tomorrow.

@9prady9
Copy link
Member Author

9prady9 commented Oct 18, 2018

I have fixed windows compilation problems. 🤞

umar456
umar456 previously requested changes Nov 1, 2018
src/backend/opencl/kernel/ssarith_calc_out_nnz.cl Outdated Show resolved Hide resolved
src/backend/opencl/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/opencl/sparse_arith.cpp Show resolved Hide resolved
src/backend/opencl/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
@9prady9
Copy link
Member Author

9prady9 commented Nov 12, 2018

Requires arrayfire/arrayfire-data#12

src/backend/opencl/kernel/sp_sp_arith_csr.cl Show resolved Hide resolved
src/backend/opencl/kernel/sparse_arith.hpp Outdated Show resolved Hide resolved
src/backend/opencl/kernel/sp_sp_arith_csr.cl Show resolved Hide resolved
src/api/c/binary.cpp Outdated Show resolved Hide resolved
src/backend/opencl/kernel/ssarith_calc_out_nnz.cl Outdated Show resolved Hide resolved
src/backend/cuda/sparse_arith.cu Outdated Show resolved Hide resolved
src/backend/opencl/kernel/sp_sp_arith_csr.cl Outdated Show resolved Hide resolved
src/backend/opencl/sparse_arith.cpp Show resolved Hide resolved
test/CMakeLists.txt Outdated Show resolved Hide resolved
test/mmio/mmio.c Show resolved Hide resolved
@9prady9 9prady9 requested a review from umar456 November 29, 2018 09:54
@9prady9 9prady9 dismissed umar456’s stale review November 29, 2018 09:54

Addressed feedback, review again pls

Latest MKL API, doesn't handle the dense data to sparse
storage conversion. It expects pointers to rows, cols and
values arrays. It also returns sparse_matrix_t opaque handles
that we don't use inside ArrayFire. Hence, deprecated MKL API
has been removed in favor of our in-house kernels for conversions.
CPU and OpenCL backends have support for mul/div but they
are disabled to have feature parity with CUDA which doesn't
have support for mul/div.

The output of sub/div/mul is not guaranteed to have only
non-zero results of the arithmetic operation. The user has
to take care of pruning the zero results from the output.
- Includes tests to read sparse matrix from mtx file

cmake configure downloads the compressed mtx files, uncompresses
the files and places them under the source tree location
`test/data/matrixmarket` so that clean builds don't redownload
entire data set. Hence, a new change has been added to test/data
git repository to ignore the matrixmarket folder.

If for any reason download fails, MTX tests are disabled.
@9prady9 9prady9 merged commit d0da171 into arrayfire:master Dec 19, 2018
@9prady9 9prady9 deleted the sparse_arith branch December 19, 2018 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants