-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge add absolute function, complex/real converter on class
This PR adds the absolute (inplace/outplace) of the matrix and complex<-> real on class Summary - add `to_complex` and to_real as remove_complex alias - make `to_complex/real` and `remove_complex` work for class or scalar/complex Note. Can not use `remove_complex<class>` as friend class. Need to use `class<remove_complex<V>, I>`. this type helper should work in the other situation. - add `inplace_absolute_array` and `outplace_absolute_array` - `format->compute_absolute_inplace()` is inplace absolute function - `auto result = format->compute_absolute()` is outplace absolute function: format -> remove_complex<format> - Add `AbsoluteComputable` interface and `compute_absolute_linop` can be used with LinOp. - After this PR, need /bigobj for all MSVC. Related PR: #636
- Loading branch information
Showing
75 changed files
with
3,310 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*******************************<GINKGO LICENSE>****************************** | ||
Copyright (c) 2017-2020, the Ginkgo authors | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
******************************<GINKGO LICENSE>*******************************/ | ||
|
||
namespace kernel { | ||
|
||
|
||
template <typename ValueType> | ||
__global__ | ||
__launch_bounds__(default_block_size) void inplace_absolute_array_kernel( | ||
const size_type n, ValueType *__restrict__ array) | ||
{ | ||
const auto tidx = thread::get_thread_id_flat(); | ||
if (tidx < n) { | ||
array[tidx] = abs(array[tidx]); | ||
} | ||
} | ||
|
||
|
||
template <typename ValueType> | ||
__global__ | ||
__launch_bounds__(default_block_size) void outplace_absolute_array_kernel( | ||
const size_type n, const ValueType *__restrict__ in, | ||
remove_complex<ValueType> *__restrict__ out) | ||
{ | ||
const auto tidx = thread::get_thread_id_flat(); | ||
if (tidx < n) { | ||
out[tidx] = abs(in[tidx]); | ||
} | ||
} | ||
|
||
|
||
} // namespace kernel |
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,109 @@ | ||
/*******************************<GINKGO LICENSE>****************************** | ||
Copyright (c) 2017-2020, the Ginkgo authors | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
******************************<GINKGO LICENSE>*******************************/ | ||
|
||
#ifndef GKO_CORE_COMPONENTS_ABSOLUTE_ARRAY_HPP_ | ||
#define GKO_CORE_COMPONENTS_ABSOLUTE_ARRAY_HPP_ | ||
|
||
|
||
#include <memory> | ||
|
||
|
||
#include <ginkgo/core/base/executor.hpp> | ||
#include <ginkgo/core/base/math.hpp> | ||
#include <ginkgo/core/base/types.hpp> | ||
|
||
|
||
namespace gko { | ||
namespace kernels { | ||
|
||
|
||
#define GKO_DECLARE_INPLACE_ABSOLUTE_ARRAY_KERNEL(ValueType) \ | ||
void inplace_absolute_array(std::shared_ptr<const DefaultExecutor> exec, \ | ||
ValueType *data, size_type num_entries) | ||
|
||
#define GKO_DECLARE_OUTPLACE_ABSOLUTE_ARRAY_KERNEL(ValueType) \ | ||
void outplace_absolute_array(std::shared_ptr<const DefaultExecutor> exec, \ | ||
const ValueType *in, size_type num_entries, \ | ||
remove_complex<ValueType> *out) | ||
|
||
|
||
#define GKO_DECLARE_ALL_AS_TEMPLATES \ | ||
template <typename ValueType> \ | ||
GKO_DECLARE_INPLACE_ABSOLUTE_ARRAY_KERNEL(ValueType); \ | ||
template <typename ValueType> \ | ||
GKO_DECLARE_OUTPLACE_ABSOLUTE_ARRAY_KERNEL(ValueType) | ||
|
||
|
||
namespace omp { | ||
namespace components { | ||
|
||
GKO_DECLARE_ALL_AS_TEMPLATES; | ||
|
||
} // namespace components | ||
} // namespace omp | ||
|
||
|
||
namespace cuda { | ||
namespace components { | ||
|
||
GKO_DECLARE_ALL_AS_TEMPLATES; | ||
|
||
} // namespace components | ||
} // namespace cuda | ||
|
||
|
||
namespace reference { | ||
namespace components { | ||
|
||
GKO_DECLARE_ALL_AS_TEMPLATES; | ||
|
||
} // namespace components | ||
} // namespace reference | ||
|
||
|
||
namespace hip { | ||
namespace components { | ||
|
||
GKO_DECLARE_ALL_AS_TEMPLATES; | ||
|
||
} // namespace components | ||
} // namespace hip | ||
|
||
|
||
#undef GKO_DECLARE_ALL_AS_TEMPLATES | ||
|
||
|
||
} // namespace kernels | ||
} // namespace gko | ||
|
||
|
||
#endif // GKO_CORE_COMPONENTS_ABSOLUTE_ARRAY_HPP_ |
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
Oops, something went wrong.