Skip to content

Commit

Permalink
Apply clang-format to tests and libcugraph_etl.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice committed Dec 8, 2022
1 parent fcc67f3 commit fe54072
Show file tree
Hide file tree
Showing 30 changed files with 191 additions and 167 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ repos:
- id: yesqa
additional_dependencies:
- flake8==3.8.4
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: v11.1.0
# hooks:
# - id: clang-format
# types_or: [c, c++, cuda]
# args: ["-fallback-style=none", "-style=file", "-i"]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v11.1.0
hooks:
- id: clang-format
types_or: [c, c++, cuda]
args: ["-fallback-style=none", "-style=file", "-i"]
- repo: local
hooks:
- id: copyright-check
Expand Down
4 changes: 2 additions & 2 deletions cpp/libcugraph_etl/include/hash/concurrent_unordered_map.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

/*
/*
* FIXME: This file is copied from cudf because CuCollections doesnt support concurrent
* insert/find for 8 byte key-value pair size. The plan is to migrate to
* insert/find for 8 byte key-value pair size. The plan is to migrate to
* using the cuco when the feature is supported. At that point this file can be deleted.
*/
#pragma once
Expand Down
4 changes: 2 additions & 2 deletions cpp/libcugraph_etl/src/renumbering.cu
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ struct renumber_functor {

cudaStream_t exec_strm = handle.get_stream();

auto mr = rmm::mr::new_delete_resource();
size_t hist_size = sizeof(accum_type) * 32;
auto mr = rmm::mr::new_delete_resource();
size_t hist_size = sizeof(accum_type) * 32;
accum_type* hist_insert_counter = static_cast<accum_type*>(mr.allocate(hist_size));
*hist_insert_counter = 0;

Expand Down
4 changes: 3 additions & 1 deletion cpp/tests/c_api/betweenness_centrality_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ int generic_betweenness_centrality_test(vertex_t* h_src,
ret_code = cugraph_betweenness_centrality(
p_handle, p_graph, num_vertices_to_sample, NULL, FALSE, FALSE, FALSE, &p_result, &ret_error);
#if 1
TEST_ASSERT(test_ret_value, ret_code != CUGRAPH_SUCCESS, "cugraph_betweenness_centrality should have failed");
TEST_ASSERT(test_ret_value,
ret_code != CUGRAPH_SUCCESS,
"cugraph_betweenness_centrality should have failed");
#else
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));
TEST_ASSERT(
Expand Down
6 changes: 3 additions & 3 deletions cpp/tests/c_api/bfs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ int test_bfs_exceptions()
size_t depth_limit = 1;
size_t num_seeds = 1;

vertex_t src[] = {0, 1, 1, 2, 2, 2, 3, 4};
vertex_t dst[] = {1, 3, 4, 0, 1, 3, 5, 5};
weight_t wgt[] = {0.1f, 2.1f, 1.1f, 5.1f, 3.1f, 4.1f, 7.2f, 3.2f};
vertex_t src[] = {0, 1, 1, 2, 2, 2, 3, 4};
vertex_t dst[] = {1, 3, 4, 0, 1, 3, 5, 5};
weight_t wgt[] = {0.1f, 2.1f, 1.1f, 5.1f, 3.1f, 4.1f, 7.2f, 3.2f};
int64_t seeds[] = {0};

int test_ret_value = 0;
Expand Down
3 changes: 2 additions & 1 deletion cpp/tests/c_api/core_number_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int generic_core_number_test(vertex_t* h_src,
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_test_graph failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

ret_code = cugraph_core_number(p_handle, p_graph, K_CORE_DEGREE_TYPE_IN, FALSE, &p_result, &ret_error);
ret_code =
cugraph_core_number(p_handle, p_graph, K_CORE_DEGREE_TYPE_IN, FALSE, &p_result, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "cugraph_core_number failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/c_api/create_sg_graph_envelope_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ int test_create_sg_graph_simple()
typedef float weight_t;

cugraph_error_code_t ret_code = CUGRAPH_SUCCESS;
size_t num_edges = 8;
size_t num_vertices = 6;
size_t num_edges = 8;
size_t num_vertices = 6;

vertex_t h_src[] = {0, 1, 1, 2, 2, 2, 3, 4};
vertex_t h_dst[] = {1, 3, 4, 0, 1, 3, 5, 5};
Expand Down
14 changes: 7 additions & 7 deletions cpp/tests/c_api/edge_betweenness_centrality.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ typedef int32_t edge_t;
typedef float weight_t;

int generic_edge_betweenness_centrality_test(vertex_t* h_src,
vertex_t* h_dst,
weight_t* h_wgt,
weight_t* h_result,
size_t num_vertices,
size_t num_edges,
bool_t store_transposed,
size_t num_vertices_to_sample)
vertex_t* h_dst,
weight_t* h_wgt,
weight_t* h_result,
size_t num_vertices,
size_t num_edges,
bool_t store_transposed,
size_t num_vertices_to_sample)
{
int test_ret_value = 0;

Expand Down
12 changes: 7 additions & 5 deletions cpp/tests/c_api/egonet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ int generic_egonet_test(vertex_t* h_src,
weight_t M[num_vertices][num_vertices];

for (int i = 0; (i < num_seeds) && (test_ret_value == 0); ++i) {
for (int r = 0 ; r < num_vertices ; ++r)
for (int c = 0 ; c < num_vertices ; ++c)
for (int r = 0; r < num_vertices; ++r)
for (int c = 0; c < num_vertices; ++c)
M[r][c] = 0;

for (size_t e = h_expected_offsets[i] ; e < h_expected_offsets[i+1] ; ++e)
for (size_t e = h_expected_offsets[i]; e < h_expected_offsets[i + 1]; ++e)
M[h_expected_src[e]][h_expected_dst[e]] = 1;

for (size_t e = h_result_offsets[i] ; (e < h_result_offsets[i+1]) && (test_ret_value == 0) ; ++e) {
TEST_ASSERT(test_ret_value, (M[h_result_src[e]][h_result_dst[e]] > 0), "found different edges");
for (size_t e = h_result_offsets[i]; (e < h_result_offsets[i + 1]) && (test_ret_value == 0);
++e) {
TEST_ASSERT(
test_ret_value, (M[h_result_src[e]][h_result_dst[e]] > 0), "found different edges");
}
}

Expand Down
12 changes: 10 additions & 2 deletions cpp/tests/c_api/hits_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,16 @@ int generic_hits_test(vertex_t* h_src,
p_handle = cugraph_create_resource_handle(NULL);
TEST_ASSERT(test_ret_value, p_handle != NULL, "resource handle creation failed.");

ret_code = create_test_graph(
p_handle, h_src, h_dst, h_wgt, num_edges, store_transposed, renumber, FALSE, &p_graph, &ret_error);
ret_code = create_test_graph(p_handle,
h_src,
h_dst,
h_wgt,
num_edges,
store_transposed,
renumber,
FALSE,
&p_graph,
&ret_error);

TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_test_graph failed.");
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));
Expand Down
4 changes: 3 additions & 1 deletion cpp/tests/c_api/mg_betweenness_centrality_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ int generic_betweenness_centrality_test(const cugraph_resource_handle_t* handle,
ret_code = cugraph_betweenness_centrality(
handle, p_graph, num_vertices_to_sample, NULL, FALSE, FALSE, FALSE, &p_result, &ret_error);
#if 1
TEST_ASSERT(test_ret_value, ret_code != CUGRAPH_SUCCESS, "cugraph_betweenness_centrality should have failed");
TEST_ASSERT(test_ret_value,
ret_code != CUGRAPH_SUCCESS,
"cugraph_betweenness_centrality should have failed");
#else
TEST_ASSERT(
test_ret_value, ret_code == CUGRAPH_SUCCESS, "cugraph_betweenness_centrality failed.");
Expand Down
3 changes: 2 additions & 1 deletion cpp/tests/c_api/mg_core_number_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int generic_core_number_test(const cugraph_resource_handle_t* p_handle,
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_test_graph failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

ret_code = cugraph_core_number(p_handle, p_graph, K_CORE_DEGREE_TYPE_IN, FALSE, &p_result, &ret_error);
ret_code =
cugraph_core_number(p_handle, p_graph, K_CORE_DEGREE_TYPE_IN, FALSE, &p_result, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "cugraph_core_number failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/c_api/mg_create_graph_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "c_test_utils.h" /* RUN_TEST */
#include "c_test_utils.h" /* RUN_TEST */
#include "mg_test_utils.h" /* RUN_TEST */

#include <math.h>
Expand Down
16 changes: 8 additions & 8 deletions cpp/tests/c_api/mg_edge_betweenness_centrality.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ typedef int32_t edge_t;
typedef float weight_t;

int generic_edge_betweenness_centrality_test(const cugraph_resource_handle_t* handle,
vertex_t* h_src,
vertex_t* h_dst,
weight_t* h_wgt,
weight_t* h_result,
size_t num_vertices,
size_t num_edges,
bool_t store_transposed,
size_t num_vertices_to_sample)
vertex_t* h_src,
vertex_t* h_dst,
weight_t* h_wgt,
weight_t* h_result,
size_t num_vertices,
size_t num_edges,
bool_t store_transposed,
size_t num_vertices_to_sample)
{
int test_ret_value = 0;

Expand Down
18 changes: 9 additions & 9 deletions cpp/tests/c_api/mg_egonet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ int generic_egonet_test(const cugraph_resource_handle_t* resource_handle,
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_test_graph failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

if (rank != 0) {
num_seeds = 0;
}
if (rank != 0) { num_seeds = 0; }

ret_code =
cugraph_type_erased_device_array_create(resource_handle, num_seeds, INT32, &seeds, &ret_error);
Expand Down Expand Up @@ -134,15 +132,17 @@ int generic_egonet_test(const cugraph_resource_handle_t* resource_handle,
weight_t M[num_vertices][num_vertices];

for (int i = 0; (i < num_seeds) && (test_ret_value == 0); ++i) {
for (int r = 0 ; r < num_vertices ; ++r)
for (int c = 0 ; c < num_vertices ; ++c)
for (int r = 0; r < num_vertices; ++r)
for (int c = 0; c < num_vertices; ++c)
M[r][c] = 0;

for (size_t e = h_expected_offsets[i] ; e < h_expected_offsets[i+1] ; ++e)
for (size_t e = h_expected_offsets[i]; e < h_expected_offsets[i + 1]; ++e)
M[h_expected_src[e]][h_expected_dst[e]] = 1;

for (size_t e = h_result_offsets[i] ; (e < h_result_offsets[i+1]) && (test_ret_value == 0) ; ++e) {
TEST_ASSERT(test_ret_value, (M[h_result_src[e]][h_result_dst[e]] > 0), "found different edges");
for (size_t e = h_result_offsets[i]; (e < h_result_offsets[i + 1]) && (test_ret_value == 0);
++e) {
TEST_ASSERT(
test_ret_value, (M[h_result_src[e]][h_result_dst[e]] > 0), "found different edges");
}
}

Expand All @@ -159,7 +159,7 @@ int generic_egonet_test(const cugraph_resource_handle_t* resource_handle,
return test_ret_value;
}

int test_egonet(const cugraph_resource_handle_t *resource_handle)
int test_egonet(const cugraph_resource_handle_t* resource_handle)
{
size_t num_edges = 9;
size_t num_vertices = 6;
Expand Down
14 changes: 3 additions & 11 deletions cpp/tests/c_api/mg_eigenvector_centrality_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,12 @@ int test_eigenvector_centrality(const cugraph_resource_handle_t* handle)
0.1f, 2.1f, 1.1f, 5.1f, 3.1f, 4.1f, 7.2f, 3.2f, 0.1f, 2.1f, 1.1f, 5.1f, 3.1f, 4.1f, 7.2f, 3.2f};
weight_t h_result[] = {0.236374, 0.292046, 0.458369, 0.605472, 0.190544, 0.495814};

double epsilon = 1e-6;
double epsilon = 1e-6;
size_t max_iterations = 200;

// Eigenvector centrality wants store_transposed = TRUE
return generic_eigenvector_centrality_test(handle,
h_src,
h_dst,
h_wgt,
h_result,
num_vertices,
num_edges,
TRUE,
epsilon,
max_iterations);
return generic_eigenvector_centrality_test(
handle, h_src, h_dst, h_wgt, h_result, num_vertices, num_edges, TRUE, epsilon, max_iterations);
}

/******************************************************************************/
Expand Down
23 changes: 10 additions & 13 deletions cpp/tests/c_api/mg_induced_subgraph_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ int generic_induced_subgraph_test(const cugraph_resource_handle_t* handle,

cugraph_induced_subgraph_result_t* result = NULL;

data_type_id_t vertex_tid = INT32;
data_type_id_t size_t_tid = SIZE_T;
size_t num_subgraph_vertices = h_subgraph_offsets[num_subgraph_offsets-1];
data_type_id_t vertex_tid = INT32;
data_type_id_t size_t_tid = SIZE_T;
size_t num_subgraph_vertices = h_subgraph_offsets[num_subgraph_offsets - 1];

ret_code = create_mg_test_graph(
handle, h_src, h_dst, h_wgt, num_edges, store_transposed, FALSE, &graph, &ret_error);
Expand All @@ -69,7 +69,7 @@ int generic_induced_subgraph_test(const cugraph_resource_handle_t* handle,

if (cugraph_resource_handle_get_rank(handle) != 0) {
num_subgraph_vertices = 0;
for (int i = 0 ; i < num_subgraph_offsets ; ++i) {
for (int i = 0; i < num_subgraph_offsets; ++i) {
h_subgraph_offsets[i] = 0;
}
}
Expand All @@ -78,11 +78,8 @@ int generic_induced_subgraph_test(const cugraph_resource_handle_t* handle,
handle, num_subgraph_offsets, size_t_tid, &subgraph_offsets, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "subgraph_offsets create failed.");

ret_code = cugraph_type_erased_device_array_create(handle,
num_subgraph_vertices,
vertex_tid,
&subgraph_vertices,
&ret_error);
ret_code = cugraph_type_erased_device_array_create(
handle, num_subgraph_vertices, vertex_tid, &subgraph_vertices, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "subgraph_offsets create failed.");

subgraph_offsets_view = cugraph_type_erased_device_array_view(subgraph_offsets);
Expand All @@ -102,7 +99,7 @@ int generic_induced_subgraph_test(const cugraph_resource_handle_t* handle,
graph,
subgraph_offsets_view,
subgraph_vertices_view,
//FALSE,
// FALSE,
TRUE,
&result,
&ret_error);
Expand All @@ -115,9 +112,9 @@ int generic_induced_subgraph_test(const cugraph_resource_handle_t* handle,
cugraph_type_erased_device_array_view_t* extracted_wgt;
cugraph_type_erased_device_array_view_t* extracted_graph_offsets;

extracted_src = cugraph_induced_subgraph_get_sources(result);
extracted_dst = cugraph_induced_subgraph_get_destinations(result);
extracted_wgt = cugraph_induced_subgraph_get_edge_weights(result);
extracted_src = cugraph_induced_subgraph_get_sources(result);
extracted_dst = cugraph_induced_subgraph_get_destinations(result);
extracted_wgt = cugraph_induced_subgraph_get_edge_weights(result);
extracted_graph_offsets = cugraph_induced_subgraph_get_subgraph_offsets(result);

size_t extracted_size = cugraph_type_erased_device_array_view_size(extracted_src);
Expand Down
6 changes: 3 additions & 3 deletions cpp/tests/c_api/mg_katz_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ int generic_katz_test(const cugraph_resource_handle_t* handle,
cugraph_error_code_t ret_code = CUGRAPH_SUCCESS;
cugraph_error_t* ret_error;

cugraph_graph_t* p_graph = NULL;
cugraph_centrality_result_t* p_result = NULL;
cugraph_graph_t* p_graph = NULL;
cugraph_centrality_result_t* p_result = NULL;
cugraph_type_erased_device_array_view_t* betas_view = NULL;

ret_code = create_mg_test_graph(
Expand All @@ -71,7 +71,7 @@ int generic_katz_test(const cugraph_resource_handle_t* handle,
cugraph_type_erased_device_array_view_t* vertices;
cugraph_type_erased_device_array_view_t* centralities;

vertices = cugraph_centrality_result_get_vertices(p_result);
vertices = cugraph_centrality_result_get_vertices(p_result);
centralities = cugraph_centrality_result_get_values(p_result);

vertex_t h_vertices[num_vertices];
Expand Down
21 changes: 14 additions & 7 deletions cpp/tests/c_api/mg_pagerank_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,18 @@ int generic_pagerank_test(const cugraph_resource_handle_t* handle,

TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_mg_test_graph failed.");

ret_code = cugraph_pagerank(
handle, p_graph, NULL, NULL, NULL, NULL, alpha, epsilon, max_iterations, FALSE, &p_result, &ret_error);
ret_code = cugraph_pagerank(handle,
p_graph,
NULL,
NULL,
NULL,
NULL,
alpha,
epsilon,
max_iterations,
FALSE,
&p_result,
&ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "cugraph_pagerank failed.");

// NOTE: Because we get back vertex ids and pageranks, we can simply compare
Expand Down Expand Up @@ -90,7 +100,7 @@ int generic_pagerank_test(const cugraph_resource_handle_t* handle,
return test_ret_value;
}

int generic_personalized_pagerank_test(const cugraph_resource_handle_t *handle,
int generic_personalized_pagerank_test(const cugraph_resource_handle_t* handle,
vertex_t* h_src,
vertex_t* h_dst,
weight_t* h_wgt,
Expand Down Expand Up @@ -126,9 +136,7 @@ int generic_personalized_pagerank_test(const cugraph_resource_handle_t *handle,
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "create_test_graph failed.");
TEST_ALWAYS_ASSERT(ret_code == CUGRAPH_SUCCESS, cugraph_error_message(ret_error));

if (cugraph_resource_handle_get_rank(handle) != 0) {
num_personalization_vertices = 0;
}
if (cugraph_resource_handle_get_rank(handle) != 0) { num_personalization_vertices = 0; }

ret_code = cugraph_type_erased_device_array_create(
handle, num_personalization_vertices, vertex_tid, &personalization_vertices, &ret_error);
Expand Down Expand Up @@ -201,7 +209,6 @@ int generic_personalized_pagerank_test(const cugraph_resource_handle_t *handle,
return test_ret_value;
}


int test_pagerank(const cugraph_resource_handle_t* handle)
{
size_t num_edges = 8;
Expand Down
Loading

0 comments on commit fe54072

Please sign in to comment.