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

Remove dummy hooks for kernels #1700

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
994 changes: 0 additions & 994 deletions core/device_hooks/common_kernels.inc.cpp

This file was deleted.

5 changes: 0 additions & 5 deletions core/device_hooks/cuda_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,3 @@ void end_nvtx(const char*, profile_event_category) GKO_NOT_COMPILED(cuda);

} // namespace log
} // namespace gko


#define GKO_HOOK_MODULE cuda
#include "core/device_hooks/common_kernels.inc.cpp"
#undef GKO_HOOK_MODULE
5 changes: 0 additions & 5 deletions core/device_hooks/dpcpp_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,3 @@ std::chrono::nanoseconds DpcppTimer::difference_async(const time_point& start,


} // namespace gko


#define GKO_HOOK_MODULE dpcpp
#include "core/device_hooks/common_kernels.inc.cpp"
#undef GKO_HOOK_MODULE
5 changes: 0 additions & 5 deletions core/device_hooks/hip_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,3 @@ void end_roctx(const char*, profile_event_category) GKO_NOT_COMPILED(hip);

} // namespace log
} // namespace gko


#define GKO_HOOK_MODULE hip
#include "core/device_hooks/common_kernels.inc.cpp"
#undef GKO_HOOK_MODULE
5 changes: 0 additions & 5 deletions core/device_hooks/omp_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ int OmpExecutor::get_num_omp_threads() { return 1; }


} // namespace gko


#define GKO_HOOK_MODULE omp
#include "core/device_hooks/common_kernels.inc.cpp"
#undef GKO_HOOK_MODULE
5 changes: 0 additions & 5 deletions core/device_hooks/reference_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@ scoped_device_id_guard::scoped_device_id_guard(const ReferenceExecutor* exec,


} // namespace gko


#define GKO_HOOK_MODULE reference
#include "core/device_hooks/common_kernels.inc.cpp"
#undef GKO_HOOK_MODULE
10 changes: 10 additions & 0 deletions include/ginkgo/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
// clang-format on


/* Describe which backends are enabled. */
// clang-format off
#cmakedefine01 GINKGO_BUILD_CUDA
#cmakedefine01 GINKGO_BUILD_HIP
#cmakedefine01 GINKGO_BUILD_OMP
#cmakedefine01 GINKGO_BUILD_REFERENCE
#cmakedefine01 GINKGO_BUILD_SYCL
// clang-format on


/* Is MPI available ? */
// clang-format off
#cmakedefine01 GINKGO_BUILD_MPI
Expand Down
19 changes: 19 additions & 0 deletions include/ginkgo/core/base/exception_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ namespace gko {
"semi-colon warnings")


/**
* Marks a kernel as not compiled.
*
* The same behavior as GKO_NOT_COMPILED, except that the kernel name is
* explicitly specified, instead of based on the __func__ macro.
*
* @param _module the module which should be compiled to enable the kernel
* @param _kernel the name of the kernel
*/
#define GKO_KERNEL_NOT_COMPILED(_module, _kernel) \
{ \
throw ::gko::NotCompiled(__FILE__, __LINE__, _kernel, \
GKO_QUOTE(_module)); \
} \
static_assert(true, \
"This assert is used to counter the false positive extra " \
"semi-colon warnings")


namespace detail {


Expand Down
101 changes: 62 additions & 39 deletions include/ginkgo/core/base/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <type_traits>
#include <vector>

#include <ginkgo/config.hpp>
#include <ginkgo/core/base/device.hpp>
#include <ginkgo/core/base/fwd_decls.hpp>
#include <ginkgo/core/base/machine_topology.hpp>
Expand Down Expand Up @@ -423,46 +424,68 @@ RegisteredOperation<Closure> make_register_operation(const char* name,
return ::gko::detail::make_register_operation( \
#_kernel, [&args...](auto exec) { \
using exec_type = decltype(exec); \
if (std::is_same< \
if constexpr (std::is_same< \
exec_type, \
std::shared_ptr< \
const ::gko::ReferenceExecutor>>:: \
value) { \
if constexpr (GINKGO_BUILD_REFERENCE) { \
::gko::kernels::reference::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::ReferenceExecutor>(exec), \
std::forward<Args>(args)...); \
} else { \
GKO_KERNEL_NOT_COMPILED(reference, #_kernel); \
} \
} else if constexpr ( \
std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::ReferenceExecutor>>:: \
value) { \
::gko::kernels::reference::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::ReferenceExecutor>(exec), \
std::forward<Args>(args)...); \
} else if (std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::OmpExecutor>>:: \
value) { \
::gko::kernels::omp::_kernel( \
std::dynamic_pointer_cast<const ::gko::OmpExecutor>( \
exec), \
std::forward<Args>(args)...); \
} else if (std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::CudaExecutor>>:: \
value) { \
::gko::kernels::cuda::_kernel( \
std::dynamic_pointer_cast<const ::gko::CudaExecutor>( \
exec), \
std::forward<Args>(args)...); \
} else if (std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::HipExecutor>>:: \
value) { \
::gko::kernels::hip::_kernel( \
std::dynamic_pointer_cast<const ::gko::HipExecutor>( \
exec), \
std::forward<Args>(args)...); \
} else if (std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::DpcppExecutor>>:: \
value) { \
::gko::kernels::dpcpp::_kernel( \
std::dynamic_pointer_cast<const ::gko::DpcppExecutor>( \
exec), \
std::forward<Args>(args)...); \
std::shared_ptr<const ::gko::OmpExecutor>>::value) { \
if constexpr (GINKGO_BUILD_OMP) { \
::gko::kernels::omp::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::OmpExecutor>(exec), \
std::forward<Args>(args)...); \
} else { \
GKO_KERNEL_NOT_COMPILED(omp, #_kernel); \
} \
} else if constexpr ( \
std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::CudaExecutor>>::value) { \
if constexpr (GINKGO_BUILD_CUDA) { \
::gko::kernels::cuda::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::CudaExecutor>(exec), \
std::forward<Args>(args)...); \
} else { \
GKO_KERNEL_NOT_COMPILED(cuda, #_kernel); \
} \
} else if constexpr ( \
std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::HipExecutor>>::value) { \
if constexpr (GINKGO_BUILD_HIP) { \
::gko::kernels::hip::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::HipExecutor>(exec), \
std::forward<Args>(args)...); \
} else { \
GKO_KERNEL_NOT_COMPILED(hip, #_kernel); \
} \
} else if constexpr ( \
std::is_same< \
exec_type, \
std::shared_ptr<const ::gko::DpcppExecutor>>::value) { \
if constexpr (GINKGO_BUILD_SYCL) { \
::gko::kernels::dpcpp::_kernel( \
std::dynamic_pointer_cast< \
const ::gko::DpcppExecutor>(exec), \
std::forward<Args>(args)...); \
} else { \
GKO_KERNEL_NOT_COMPILED(sycl, #_kernel); \
} \
\
Comment on lines +487 to +488
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} \
\
} \

nit

} else { \
GKO_NOT_IMPLEMENTED; \
} \
Expand Down
Loading