Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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. Also moved mkl interface defs in CPU backend into single source file
- Loading branch information
Showing
19 changed files
with
1,018 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/******************************************************* | ||
* Copyright (c) 2018, ArrayFire | ||
* All rights reserved. | ||
* | ||
* This file is distributed under 3-clause BSD license. | ||
* The complete license agreement can be obtained at: | ||
* http://arrayfire.com/licenses/BSD-3-Clause | ||
********************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
#ifdef USE_MKL | ||
#include <mkl_spblas.h> | ||
#endif | ||
|
||
#include <types.hpp> | ||
|
||
namespace cpu | ||
{ | ||
|
||
#ifdef USE_MKL | ||
typedef MKL_Complex8 sp_cfloat; | ||
typedef MKL_Complex16 sp_cdouble; | ||
#else | ||
typedef cfloat sp_cfloat; | ||
typedef cdouble sp_cdouble; | ||
#endif | ||
|
||
template<typename T, class Enable = void> | ||
struct blas_base { | ||
using type = T; | ||
}; | ||
|
||
template<typename T> | ||
struct blas_base <T, typename std::enable_if< is_complex<T>::value>::type> { | ||
using type = typename std::conditional<std::is_same<T, cdouble>::value, | ||
sp_cdouble, sp_cfloat> | ||
::type; | ||
}; | ||
|
||
template<typename T> | ||
using cptr_type = typename std::conditional< is_complex<T>::value, | ||
const typename blas_base<T>::type *, | ||
const T*>::type; | ||
template<typename T> | ||
using ptr_type = typename std::conditional< is_complex<T>::value, | ||
typename blas_base<T>::type *, | ||
T*>::type; | ||
template<typename T> | ||
using scale_type = typename std::conditional< is_complex<T>::value, | ||
const typename blas_base<T>::type, | ||
const T>::type; | ||
} |
Oops, something went wrong.