Skip to content

Commit

Permalink
Merge pull request #1956 from kokkos/issue-1948
Browse files Browse the repository at this point in the history
Fix zero length MDRange: issue #1948
  • Loading branch information
crtrott committed Dec 21, 2018
2 parents db67cbd + 5fdae0e commit 36a6603
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions core/src/Cuda/Kokkos_Cuda_Parallel.hpp
Expand Up @@ -525,6 +525,7 @@ class ParallelFor< FunctorType
inline
void execute() const
{
if(m_rp.m_num_tiles==0) return;
const array_index_type maxblocks = static_cast<array_index_type>(Kokkos::Impl::CudaTraits::UpperBoundGridCount);
if ( RP::rank == 2 )
{
Expand Down
7 changes: 6 additions & 1 deletion core/unit_test/TestMDRange.hpp
Expand Up @@ -956,7 +956,12 @@ struct TestMDRange_3D {
}
, Kokkos::Min<double>(min) );

ASSERT_EQ( min, 8.0 );
if((N0-1)*(N1-1)*(N2-1)>0)
ASSERT_EQ( min, 8.0 );
else {
double min_identity = Kokkos::reduction_identity<double>::min();
ASSERT_EQ( min, min_identity );
}
}
#endif
#endif
Expand Down
2 changes: 2 additions & 0 deletions core/unit_test/TestMDRange_d.hpp
Expand Up @@ -46,8 +46,10 @@
namespace Test {

TEST_F( TEST_CATEGORY , mdrange_3d) {
TestMDRange_3D< TEST_EXECSPACE >::test_for3( 1, 10, 100 );
TestMDRange_3D< TEST_EXECSPACE >::test_for3( 100, 10, 100 );
#if !defined( KOKKOS_ENABLE_ROCM ) // MDRange Reduced explicitly handled in its own cpp file
TestMDRange_3D< TEST_EXECSPACE >::test_reduce3( 1, 10, 100 );
TestMDRange_3D< TEST_EXECSPACE >::test_reduce3( 100, 10, 100 );
#endif
}
Expand Down
17 changes: 3 additions & 14 deletions core/unit_test/TestViewCopy.hpp
Expand Up @@ -56,17 +56,13 @@ struct TestViewCopy {

using InExecSpace = ExecSpace;

static void test_view_copy()
static void test_view_copy(const int dim0, const int dim1, const int dim2)
{
#if defined( KOKKOS_ENABLE_CUDA ) || defined( KOKKOS_ENABLE_ROCM )
// ExecSpace = CudaUVM, CudaHostPinned
// This test will fail at runtime with an illegal memory access if something goes wrong
// Test 1: deep_copy from host_mirror_space to ExecSpace and ExecSpace back to host_mirror_space
{
const int dim0 = 4;
const int dim1 = 2;
const int dim2 = 3;

typedef Kokkos::View<double****,InExecSpace> Rank4ViewType;
Rank4ViewType view_4;
view_4 = Rank4ViewType("view_4", dim0, dim1, dim2, dim2);
Expand All @@ -88,10 +84,6 @@ struct TestViewCopy {

// Test 2: deep_copy from Cuda to ExecSpace and ExecSpace back to Cuda
{
const int dim0 = 4;
const int dim1 = 2;
const int dim2 = 3;

typedef Kokkos::View<double****,InExecSpace> Rank4ViewType;
Rank4ViewType view_4;
view_4 = Rank4ViewType("view_4", dim0, dim1, dim2, dim2);
Expand All @@ -118,10 +110,6 @@ struct TestViewCopy {

// Test 3: deep_copy from host_space to ExecSpace and ExecSpace back to host_space
{
const int dim0 = 4;
const int dim1 = 2;
const int dim2 = 3;

typedef Kokkos::View<double****,InExecSpace> Rank4ViewType;
Rank4ViewType view_4;
view_4 = Rank4ViewType("view_4", dim0, dim1, dim2, dim2);
Expand Down Expand Up @@ -149,7 +137,8 @@ struct TestViewCopy {

TEST_F( TEST_CATEGORY , view_copy_tests ) {
//Only include this file to be compiled with CudaUVM and CudaHostPinned
TestViewCopy< TEST_EXECSPACE >::test_view_copy();
TestViewCopy< TEST_EXECSPACE >::test_view_copy(4,2,3);
TestViewCopy< TEST_EXECSPACE >::test_view_copy(4,2,0);
}

} // namespace Test

0 comments on commit 36a6603

Please sign in to comment.