-
Notifications
You must be signed in to change notification settings - Fork 407
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
Kokkos::DualView: Incorrect deduction of "not device type" #1659
Comments
FYI I'm happy to fix this myself but I just want to check if this makes sense. |
Well, this does beg the question of why the member functions are being called with template parameters other than the one that was used to define the |
@ibaned SPARC has an option to build with or without Trilinos. In the without-Trilinos build, SPARC uses Kokkos' default behavior of setting |
Micah, Travis, and I debated whether it would be better to force the correct memory space via |
Yea, I marked this as an enhancement because stronger error checks need to be put in place ( using DeviceSpace = Kokkos::Cuda::memory_space I think the interface should require exactly one of the two spaces involved, and compile error if the space is something else. |
@ibaned wrote:
I think that's a good idea. SPARC has plans to do something like what you mentioned. |
Awesome. On second thought, if SPARC doesn't need UVM for their DualViews, they should probably instead define a |
@ibaned wrote:
They already do that :-) The issue is interactions with Trilinos' types. |
@ibaned wrote:
You're a dear; thanks :D |
I concur with Dans solution. |
Found some issues with it, which I am fixing. |
This is the new deduction mechanism - BEHOLD the power of LOGIC: template<class Device>
static int get_device_side() {
constexpr bool device_is_memspace = std::is_same<Device,typename Device::memory_space>::value;
constexpr bool device_is_execspace = std::is_same<Device,typename Device::execution_space>::value;
constexpr bool device_exec_is_t_dev_exec = std::is_same<typename Device::execution_space,typename t_dev::execution_space>::value;
constexpr bool device_mem_is_t_dev_mem = std::is_same<typename Device::memory_space,typename t_dev::memory_space>::value;
constexpr bool device_exec_is_t_host_exec = std::is_same<typename Device::execution_space,typename t_host::execution_space>::value;
constexpr bool device_mem_is_t_host_mem = std::is_same<typename Device::memory_space,typename t_host::memory_space>::value;
constexpr bool device_is_t_host_device = std::is_same<typename Device::execution_space,typename t_host::device_type>::value;
constexpr bool device_is_t_dev_device = std::is_same<typename Device::memory_space,typename t_host::device_type>::value;
#ifndef KOKKOS_ENABLE_DEPRECATED_CODE
static_assert(
device_is_t_dev_device || device_is_t_host_device ||
(device_is_memspace && (device_mem_is_t_dev_mem || device_mem_is_t_host_mem) ) ||
(device_is_execspace && (device_exec_is_t_dev_exec || device_exec_is_t_host_exec) ) ||
(
(!device_is_execspace && !device_is_memspace) && (
(device_mem_is_t_dev_mem || device_mem_is_t_host_mem) ||
(device_exec_is_t_dev_exec || device_exec_is_t_host_exec)
)
)
,
"Template parameter to .sync() must exactly match one of the DualView's device types or one of the execution or memory spaces");
#endif
int dev = -1;
if(device_is_t_dev_device) dev = 1;
else if(device_is_t_host_device) dev = 0;
else {
if(device_is_memspace) {
if(device_mem_is_t_dev_mem) dev = 1;
if(device_mem_is_t_host_mem) dev = 0;
if(device_mem_is_t_host_mem && device_mem_is_t_dev_mem) dev = -1;
}
if(device_is_execspace) {
if(device_exec_is_t_dev_exec) dev = 1;
if(device_exec_is_t_host_exec) dev = 0;
if(device_exec_is_t_host_exec && device_exec_is_t_dev_exec) dev = -1;
}
if(!device_is_execspace && !device_is_memspace) {
if(device_mem_is_t_dev_mem) dev = 1;
if(device_mem_is_t_host_mem) dev = 0;
if(device_mem_is_t_host_mem && device_mem_is_t_dev_mem) dev = -1;
if(device_exec_is_t_dev_exec) dev = 1;
if(device_exec_is_t_host_exec) dev = 0;
if(device_exec_is_t_host_exec && device_exec_is_t_dev_exec) dev = -1;
}
}
return dev;
} |
L O G I C |
Thanks @crtrott :D |
Improved fix for DualView synd deduction issue #1659
If I create a
DualView<..., Device<Cuda, CudaUVMSpace>>
, and I callview
,sync
,modify
, orneed_sync
withDevice<Cuda, CudaSpace>
, DualView incorrectly deduces that I meant the host space. Vice versa for a DualView on CudaSpace.This is a problem when interacting with Trilinos especially, because Trilinos forces Kokkos to set Cuda's default memory space to
CudaUVMSpace
. Thus, whether or not the following two code examples are correct depends merely on whether building Kokkos through Trilinos or by itself.Example 1:
Example 2:
DualView uses code like the following to select which memory space to access:
kokkos/containers/src/Kokkos_DualView.hpp
Line 311 in d3a9419
I propose this instead:
The text was updated successfully, but these errors were encountered: