-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governin_from_mtxg permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <utilities/base_fixture.hpp> | ||
#include <utilities/test_graphs.hpp> | ||
#include <utilities/test_utilities.hpp> | ||
#include <utilities/thrust_wrapper.hpp> | ||
|
||
#include <cugraph/algorithms.hpp> | ||
#include <cugraph/graph.hpp> | ||
#include <cugraph/graph_functions.hpp> | ||
#include <cugraph/graph_view.hpp> | ||
#include <cugraph/utilities/high_res_timer.hpp> | ||
|
||
#include <raft/core/handle.hpp> | ||
#include <raft/util/cudart_utils.hpp> | ||
#include <rmm/device_uvector.hpp> | ||
#include <rmm/mr/device/cuda_memory_resource.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <algorithm> | ||
#include <iterator> | ||
#include <limits> | ||
#include <numeric> | ||
#include <random> | ||
#include <vector> | ||
|
||
|
||
struct Ktruss_Usecase { | ||
int32_t k{10}; | ||
bool check_correctness{true}; | ||
}; | ||
|
||
template <typename input_usecase_t> | ||
class Tests_Ktruss | ||
: public ::testing::TestWithParam<std::tuple<Ktruss_Usecase, input_usecase_t>> { | ||
public: | ||
Tests_Ktruss() {} | ||
|
||
static void SetUpTestCase() {} | ||
static void TearDownTestCase() {} | ||
|
||
virtual void SetUp() {} | ||
virtual void TearDown() {} | ||
|
||
template <typename vertex_t, typename edge_t> | ||
void run_current_test( | ||
std::tuple<Ktruss_Usecase const&, input_usecase_t const&> const& param) | ||
{ | ||
constexpr bool renumber = false; | ||
|
||
using weight_t = float; | ||
|
||
auto [ktruss_usecase, input_usecase] = param; | ||
|
||
raft::handle_t handle{}; | ||
HighResTimer hr_timer{}; | ||
|
||
if (cugraph::test::g_perf) { | ||
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement | ||
hr_timer.start("MG Construct graph"); | ||
} | ||
|
||
cugraph::graph_t<vertex_t, edge_t, false, false> graph(handle); | ||
std::optional<rmm::device_uvector<vertex_t>> d_renumber_map_labels{std::nullopt}; | ||
std::tie(graph, std::ignore, d_renumber_map_labels) = | ||
cugraph::test::construct_graph<vertex_t, edge_t, weight_t, false, false>( | ||
handle, input_usecase, false, renumber, false, true); | ||
|
||
if (cugraph::test::g_perf) { | ||
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement | ||
hr_timer.stop(); | ||
hr_timer.display_and_clear(std::cout); | ||
} | ||
|
||
auto graph_view = graph.view(); | ||
|
||
if (cugraph::test::g_perf) { | ||
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement | ||
hr_timer.start("Ktruss"); | ||
} | ||
|
||
cugraph::ktruss<vertex_t, edge_t, false>( | ||
handle, | ||
graph_view, | ||
ktruss_usecase.k, | ||
false); | ||
|
||
if (cugraph::test::g_perf) { | ||
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement | ||
hr_timer.stop(); | ||
hr_timer.display_and_clear(std::cout); | ||
} | ||
|
||
} | ||
}; | ||
|
||
using Tests_Ktruss_File = Tests_Ktruss<cugraph::test::File_Usecase>; | ||
|
||
// FIXME: add tests for type combinations | ||
TEST_P(Tests_Ktruss_File, CheckInt32Int32) | ||
{ | ||
run_current_test<int32_t, int32_t>(override_File_Usecase_with_cmd_line_arguments(GetParam())); | ||
} | ||
|
||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
file_test, | ||
Tests_Ktruss_File, | ||
::testing::Combine( | ||
// enable correctness checks | ||
::testing::Values(Ktruss_Usecase{2}), | ||
::testing::Values(cugraph::test::File_Usecase("/home/nfs/jnke/debug_jaccard/cugraph/datasets/dummy.mtx")))); | ||
|
||
CUGRAPH_TEST_PROGRAM_MAIN() |