Skip to content

Commit

Permalink
simplify kernel declaration in namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Sep 14, 2021
1 parent 8fb652f commit dc31f35
Show file tree
Hide file tree
Showing 39 changed files with 245 additions and 1,645 deletions.
44 changes: 1 addition & 43 deletions benchmark/utils/overhead_linop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,49 +73,7 @@ namespace overhead {
} // namespace overhead


namespace omp {
namespace overhead {

GKO_DECLARE_ALL;

} // namespace overhead
} // namespace omp


namespace cuda {
namespace overhead {

GKO_DECLARE_ALL;

} // namespace overhead
} // namespace cuda


namespace reference {
namespace overhead {

GKO_DECLARE_ALL;

} // namespace overhead
} // namespace reference


namespace hip {
namespace overhead {

GKO_DECLARE_ALL;

} // namespace overhead
} // namespace hip


namespace dpcpp {
namespace overhead {

GKO_DECLARE_ALL;

} // namespace overhead
} // namespace dpcpp
GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(overhead, GKO_DECLARE_ALL);


#undef GKO_DECLARE_ALL
Expand Down
69 changes: 69 additions & 0 deletions core/base/kernel_declaration.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2021, 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_BASE_KERNEL_DECLARATION_HPP_
#define GKO_CORE_BASE_KERNEL_DECLARATION_HPP_


#define GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(_kernel_namespace, ...) \
\
namespace omp { \
namespace _kernel_namespace { \
__VA_ARGS__; \
} \
} \
namespace cuda { \
namespace _kernel_namespace { \
__VA_ARGS__; \
} \
} \
namespace reference { \
namespace _kernel_namespace { \
__VA_ARGS__; \
} \
} \
namespace hip { \
namespace _kernel_namespace { \
__VA_ARGS__; \
} \
} \
namespace dpcpp { \
namespace _kernel_namespace { \
__VA_ARGS__; \
} \
} \
static_assert(true, \
"This assert is used to counter the false positive extra " \
"semi-colon warnings")


#endif // GKO_CORE_BASE_KERNEL_DECLARATION_HPP_
48 changes: 5 additions & 43 deletions core/components/absolute_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/base/types.hpp>


#include "core/base/kernel_declaration.hpp"


namespace gko {
namespace kernels {

Expand All @@ -63,49 +66,8 @@ namespace kernels {
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


namespace dpcpp {
namespace components {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace components
} // namespace dpcpp
GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(components,
GKO_DECLARE_ALL_AS_TEMPLATES);


#undef GKO_DECLARE_ALL_AS_TEMPLATES
Expand Down
48 changes: 5 additions & 43 deletions core/components/fill_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/base/types.hpp>


#include "core/base/kernel_declaration.hpp"


namespace gko {
namespace kernels {

Expand All @@ -61,49 +64,8 @@ namespace kernels {
GKO_DECLARE_FILL_SEQ_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


namespace dpcpp {
namespace components {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace components
} // namespace dpcpp
GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(components,
GKO_DECLARE_ALL_AS_TEMPLATES);


#undef GKO_DECLARE_ALL_AS_TEMPLATES
Expand Down
48 changes: 5 additions & 43 deletions core/components/precision_conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/base/types.hpp>


#include "core/base/kernel_declaration.hpp"


namespace gko {
namespace kernels {

Expand All @@ -57,49 +60,8 @@ namespace kernels {
GKO_DECLARE_CONVERT_PRECISION_KERNEL(SourceType, TargetType)


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


namespace dpcpp {
namespace components {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace components
} // namespace dpcpp
GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(components,
GKO_DECLARE_ALL_AS_TEMPLATES);


#undef GKO_DECLARE_ALL_AS_TEMPLATES
Expand Down
48 changes: 5 additions & 43 deletions core/components/prefix_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/base/types.hpp>


#include "core/base/kernel_declaration.hpp"


namespace gko {
namespace kernels {

Expand Down Expand Up @@ -71,49 +74,8 @@ namespace kernels {
GKO_DECLARE_PREFIX_SUM_KERNEL(IndexType)


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


namespace dpcpp {
namespace components {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace components
} // namespace dpcpp
GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(components,
GKO_DECLARE_ALL_AS_TEMPLATES);


#undef GKO_DECLARE_ALL_AS_TEMPLATES
Expand Down
Loading

0 comments on commit dc31f35

Please sign in to comment.