Skip to content

Commit

Permalink
Fixed deprecated D2 and testing of it
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-kelley committed Mar 16, 2020
1 parent 4f15726 commit 6a1c5e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cm_generate_makefile.bash
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ cd ${KOKKOS_INSTALL_PATH}
echo ""
echo cmake $COMPILER_CMD -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${KOKKOS_LDFLAGS}" -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PATH} ${KOKKOS_DEVICE_CMD} ${KOKKOS_ARCH_CMD} -DKokkos_ENABLE_TESTS=${KOKKOS_DO_TESTS} -DKokkos_ENABLE_EXAMPLES=${KOKKOS_DO_EXAMPLES} ${KOKKOS_OPTION_CMD} ${KOKKOS_CUDA_OPTION_CMD} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_EXTENSIONS=OFF ${STANDARD_CMD} ${KOKKOS_BUILDTYPE_CMD} ${KOKKOS_HWLOC_CMD} ${KOKKOS_HWLOC_PATH_CMD} ${KOKKOS_MEMKIND_CMD} ${KOKKOS_MEMKIND_PATH_CMD} ${KOKKOS_PATH}
echo ""
cmake $COMPILER_CMD -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS//\"}" -DCMAKE_EXE_LINKER_FLAGS="${KOKKOS_LDFLAGS//\"}" -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PATH} ${KOKKOS_DEVICE_CMD} ${KOKKOS_ARCH_CMD} -DKokkos_ENABLE_TESTS=${KOKKOS_DO_TESTS} -DKokkos_ENABLE_EXAMPLES=${KOKKOS_DO_EXAMPLES} ${KOKKOS_OPTION_CMD} ${KOKKOS_CUDA_OPTION_CMD} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_EXTENSIONS=OFF ${STANDARD_CMD} ${KOKKOS_BUILDTYPE_CMD} ${KOKKOS_HWLOC_CMD} ${KOKKOS_HWLOC_PATH_CMD} ${KOKKOS_MEMKIND_CMD} ${KOKKOS_MEMKIND_PATH_CMD} ${KOKKOS_PATH}
cmake $COMPILER_CMD -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS//\"}" -DCMAKE_EXE_LINKER_FLAGS="${KOKKOS_LDFLAGS//\"}" -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PATH} ${KOKKOS_DEVICE_CMD} ${KOKKOS_ARCH_CMD} -DKokkos_ENABLE_TESTS=${KOKKOS_DO_TESTS} -DKokkos_ENABLE_EXAMPLES=${KOKKOS_DO_EXAMPLES} ${KOKKOS_OPTION_CMD} ${KOKKOS_CUDA_OPTION_CMD} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_EXTENSIONS=OFF ${STANDARD_CMD} ${KOKKOS_BUILDTYPE_CMD} ${KOKKOS_HWLOC_CMD} ${KOKKOS_HWLOC_PATH_CMD} ${KOKKOS_MEMKIND_CMD} ${KOKKOS_MEMKIND_PATH_CMD} ${KOKKOS_PATH} -DKokkos_ENABLE_DEPRECATED_CODE=ON

# Install kokkos library
make install -j $KOKKOS_MAKEINSTALL_J
Expand Down
10 changes: 5 additions & 5 deletions src/graph/KokkosGraph_Distance2Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ void graph_compute_distance2_color(KernelHandle *handle,
using lno_t = typename KernelHandle::nnz_lno_t;
using size_type = typename KernelHandle::size_type;
using memory_space = typename KernelHandle::HandleTempMemorySpace;
static_assert(std::is_same<typename lno_row_view_t_::const_value_type, typename lno_col_view_t_ ::const_value_type>::value,
"Row and col maps must have the same value type (size_type).");
static_assert(std::is_same<typename lno_nnz_view_t_::const_value_type, typename lno_colnnz_view_t_::const_value_type>::value,
"Row and col entries must have the same value type (nnz_lno_t).");
//Internally, coloring accesses the graph through unmanaged views
//These are explicitly nonconst so that copies of adj for edge-filtering
//(which must be mutable) can use the same type.
Expand All @@ -293,10 +297,6 @@ void graph_compute_distance2_color(KernelHandle *handle,
memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
using InternalColinds = Kokkos::View<const lno_t*, Kokkos::LayoutLeft,
memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
static_assert(std::is_same<typename row_map::const_value_type, typename col_map::const_value_type>::value,
"Row and col maps must have the same value type (size_type).");
static_assert(std::is_same<typename row_entries::const_value_type, typename col_entries::const_value_type>::value,
"Row and col entries must have the same value type (nnz_lno_t).");
if(row_entries.extent(0) != col_entries.extent(0))
{
throw std::runtime_error("row_entries and col_entries must represent transposes of each other, but they have different lengths");
Expand All @@ -312,7 +312,7 @@ void graph_compute_distance2_color(KernelHandle *handle,
InternalRowmap colmap_internal(col_map.data(), col_map.extent(0));
InternalColinds colentries_internal(col_entries.data(), col_entries.extent(0));
Impl::GraphColorDistance2<typename KernelHandle::GraphColorDistance2HandleType, InternalRowmap, InternalColinds, true>
gc(num_rows, num_cols, row_entries.extent(0), row_map, row_entries, col_map, col_entries, gch_d2);
gc(num_rows, num_cols, row_map, row_entries, col_map, col_entries, gch_d2);
gc.compute_distance2_color();
gch_d2->add_to_overall_coloring_time(timer.seconds());
gch_d2->set_coloring_time(timer.seconds());
Expand Down
16 changes: 11 additions & 5 deletions unit_test/graph/Test_Graph_graph_color_distance2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ void test_bipartite(lno_t numRows, lno_t numCols, size_type nnz, lno_t bandwidth
}
}

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE
template<typename scalar_unused, typename lno_t, typename size_type, typename device>
void test_old_d2(lno_t numRows, lno_t numCols, size_type nnz, lno_t bandwidth, lno_t row_size_variance)
{
Expand Down Expand Up @@ -304,8 +305,8 @@ void test_old_d2(lno_t numRows, lno_t numCols, size_type nnz, lno_t bandwidth, l
KernelHandle kh;
kh.create_distance2_graph_coloring_handle(algo);
// Compute the one-sided bipartite coloring.
bipartite_color_rows<KernelHandle, c_rowmap_t, c_entries_t>
(&kh, numRows, numCols, G.row_map, G.entries);
graph_compute_distance2_color<KernelHandle, c_rowmap_t, c_entries_t, rowmap_t, entries_t>
(&kh, numRows, numCols, G.row_map, G.entries, t_rowmap, t_entries);
execution_space().fence();
auto coloring_handle = kh.get_distance2_graph_coloring_handle();
auto colors = coloring_handle->get_vertex_colors();
Expand All @@ -319,17 +320,22 @@ void test_old_d2(lno_t numRows, lno_t numCols, size_type nnz, lno_t bandwidth, l
kh.destroy_distance2_graph_coloring_handle();
}
}
#define DO_DEPRECATED_TEST(SCALAR, ORDINAL, OFFSET, DEVICE) \
test_old_d2<SCALAR, ORDINAL, OFFSET, DEVICE>(2000, 4000, 3000 * 20, 800, 10); \
test_old_d2<SCALAR, ORDINAL, OFFSET, DEVICE>(4000, 2000, 3000 * 20, 800, 10);
#else
#define DO_DEPRECATED_TEST(SCALAR, ORDINAL, OFFSET, DEVICE)
#endif

#define EXECUTE_TEST(SCALAR, ORDINAL, OFFSET, DEVICE) \
TEST_F(TestCategory, graph##_##graph_color_distance2##_##SCALAR##_##ORDINAL##_##OFFSET##_##DEVICE) \
{ \
test_dist2_coloring<SCALAR, ORDINAL, OFFSET, DEVICE>(10000, 10000 * 10, 1000, 10); \
test_dist2_coloring<SCALAR, ORDINAL, OFFSET, DEVICE>(5000, 5000 * 20, 1000, 10); \
test_dist2_coloring<SCALAR, ORDINAL, OFFSET, DEVICE>(50, 50 * 10, 40, 10); \
} \
TEST_F(TestCategory, graph##_##graph_color_deprecated_distance2##_##SCALAR##_##ORDINAL##_##OFFSET##_##DEVICE) \
{ \
test_old_d2<SCALAR, ORDINAL, OFFSET, DEVICE>(2000, 4000, 3000 * 20, 800, 10); \
test_old_d2<SCALAR, ORDINAL, OFFSET, DEVICE>(4000, 2000, 3000 * 20, 800, 10); \
DO_DEPRECATED_TEST(SCALAR, ORDINAL, OFFSET, DEVICE) \
} \
TEST_F(TestCategory, graph##_##graph_color_bipartite_row##_##SCALAR##_##ORDINAL##_##OFFSET##_##DEVICE) \
{ \
Expand Down

0 comments on commit 6a1c5e3

Please sign in to comment.