From 070b68e86466494b7df2b1484c09fdc768008e3d Mon Sep 17 00:00:00 2001 From: Charles Hastings Date: Tue, 8 Dec 2020 19:54:29 -0800 Subject: [PATCH] update mechanism for detecting we're on Pascal or earlier GPU --- cpp/src/community/louvain.cu | 38 ++++++++++------------- cpp/tests/experimental/louvain_test.cu | 42 ++++++++++++++------------ 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/cpp/src/community/louvain.cu b/cpp/src/community/louvain.cu index 1044211a0ce..5066bf494ce 100644 --- a/cpp/src/community/louvain.cu +++ b/cpp/src/community/louvain.cu @@ -15,19 +15,8 @@ */ #include - -// "FIXME": remove the guards after support for Pascal will be dropped; -// -// Disable louvain(experimenta::graph_view_t,...) -// versions for GPU architectures < 700 -//(this is because cuco/static_map.cuh would not -// compile on those) -// -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700 #include -#else #include -#endif namespace cugraph { @@ -58,13 +47,22 @@ std::pair louvain( { CUGRAPH_EXPECTS(clustering != nullptr, "Invalid input argument: clustering is null"); -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700 - CUGRAPH_FAIL("Louvain not supported on Pascal and older architectures"); -#else - experimental::Louvain> - runner(handle, graph_view); - return runner(clustering, max_level, resolution); -#endif + // "FIXME": remove this check + // + // Disable louvain(experimental::graph_view_t,...) + // versions for GPU architectures < 700 + // (cuco/static_map.cuh depends on features not supported on or before Pascal) + // + cudaDeviceProp device_prop; + CUDA_CHECK(cudaGetDeviceProperties(&device_prop, 0)); + + if (device_prop.major < 7) { + CUGRAPH_FAIL("Louvain not supported on Pascal and older architectures"); + } else { + experimental::Louvain> + runner(handle, graph_view); + return runner(clustering, max_level, resolution); + } } } // namespace detail @@ -78,11 +76,7 @@ std::pair louvain(raft::handle_t const &h { CUGRAPH_EXPECTS(clustering != nullptr, "Invalid input argument: clustering is null"); -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700 - CUGRAPH_FAIL("Louvain not supported on Pascal and older architectures"); -#else return detail::louvain(handle, graph, clustering, max_level, resolution); -#endif } // Explicit template instantations diff --git a/cpp/tests/experimental/louvain_test.cu b/cpp/tests/experimental/louvain_test.cu index ce8fb55b1d8..9ed636cd682 100644 --- a/cpp/tests/experimental/louvain_test.cu +++ b/cpp/tests/experimental/louvain_test.cu @@ -17,18 +17,15 @@ #include #include -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700 +#include +#include +#include + #include -#else #include -#endif #include -#include -#include -#include - #include #include @@ -64,21 +61,28 @@ class Tests_Louvain : public ::testing::TestWithParam { template void run_current_test(Louvain_Usecase const& configuration) { -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700 - CUGRAPH_FAIL("Louvain not supported on Pascal and older architectures"); -#else - raft::handle_t handle{}; - - std::cout << "read graph file: " << configuration.graph_file_full_path << std::endl; + // "FIXME": remove this check + // + // Disable louvain(experimental::graph_view_t,...) + // versions for GPU architectures < 700 + // (cuco/static_map.cuh depends on features not supported on or before Pascal) + // + cudaDeviceProp device_prop; + CUDA_CHECK(cudaGetDeviceProperties(&device_prop, 0)); + + if (device_prop.major < 7) { + std::cout << "Louvain not supported on Pascal and older architectures" << std::endl; + } else { + raft::handle_t handle{}; - auto graph = - cugraph::test::read_graph_from_matrix_market_file( - handle, configuration.graph_file_full_path, configuration.test_weighted); + auto graph = + cugraph::test::read_graph_from_matrix_market_file( + handle, configuration.graph_file_full_path, configuration.test_weighted); - auto graph_view = graph.view(); + auto graph_view = graph.view(); - louvain(graph_view); -#endif + louvain(graph_view); + } } template