From f66a293f70365671b3dc48756b0e223b9c371f02 Mon Sep 17 00:00:00 2001 From: James Wyles Date: Wed, 12 Feb 2020 18:34:41 -0700 Subject: [PATCH 1/2] Fixing bug with dissappearing get_column_data_ptr function --- python/cugraph/community/ecg_wrapper.pyx | 3 ++- python/cugraph/community/louvain_wrapper.pyx | 5 +++-- .../cugraph/link_analysis/pagerank_wrapper.pyx | 16 +++++++++++----- python/cugraph/traversal/bfs_wrapper.pyx | 6 ++++-- python/cugraph/traversal/sssp_wrapper.pyx | 6 ++++-- python/cugraph/utilities/column_utils.pyx | 9 +++++++-- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/python/cugraph/community/ecg_wrapper.pyx b/python/cugraph/community/ecg_wrapper.pyx index e21a3f1503d..85db717ed43 100644 --- a/python/cugraph/community/ecg_wrapper.pyx +++ b/python/cugraph/community/ecg_wrapper.pyx @@ -61,7 +61,8 @@ def ecg(input_graph, min_weight=.05, ensemble_size=16): g.adjList.get_vertex_identifiers(&c_index_col) df['partition'] = cudf.Series(np.zeros(num_verts, dtype=np.int32)) - cdef uintptr_t c_ecg_ptr = get_column_data_ptr(df['partition']._column) + #cdef uintptr_t c_ecg_ptr = get_column_data_ptr(df['partition']._column) + cdef uintptr_t c_ecg_ptr = df['partition'].__cuda_array_interface__['data'][0] if g.adjList.edge_data.dtype == np.float32: c_ecg.ecg[int32_t, float] (g, min_weight, ensemble_size, c_ecg_ptr) diff --git a/python/cugraph/community/louvain_wrapper.pyx b/python/cugraph/community/louvain_wrapper.pyx index 14fc205034b..c06721c4785 100644 --- a/python/cugraph/community/louvain_wrapper.pyx +++ b/python/cugraph/community/louvain_wrapper.pyx @@ -64,8 +64,9 @@ def louvain(input_graph, max_iter=100): df['partition'] = cudf.Series(np.zeros(num_verts,dtype=np.int32)) - cdef uintptr_t c_louvain_parts_ptr = get_column_data_ptr(df['partition']._column) - + #cdef uintptr_t c_louvain_parts_ptr = get_column_data_ptr(df['partition']._column) + cdef uintptr_t c_louvain_parts_ptr = df['partition'].__cuda_array_interface__['data'][0] + cdef bool single_precision = False # this implementation is tied to cugraph.cu line 503 # cudaDataType_t val_type = graph->adjList->edge_data? diff --git a/python/cugraph/link_analysis/pagerank_wrapper.pyx b/python/cugraph/link_analysis/pagerank_wrapper.pyx index c24a506f4e5..ec72381a8e6 100644 --- a/python/cugraph/link_analysis/pagerank_wrapper.pyx +++ b/python/cugraph/link_analysis/pagerank_wrapper.pyx @@ -79,7 +79,9 @@ def pagerank(input_graph, alpha=0.85, personalization=None, max_iter=100, tol=1. #TODO FIX ME when graph class is upgraded to remove gdf_column cdef gdf_column c_identifier = get_gdf_column_view(df['vertex']) - cdef uintptr_t c_pagerank_val = get_column_data_ptr(df['pagerank']._column) + #cdef uintptr_t c_pagerank_val = get_column_data_ptr(df['pagerank']._column) + cdef uintptr_t c_pagerank_val = df['pagerank'].__cuda_array_interface__['data'][0]; + cdef uintptr_t c_pers_vtx = NULL cdef uintptr_t c_pers_val = NULL cdef sz = 0 @@ -93,11 +95,15 @@ def pagerank(input_graph, alpha=0.85, personalization=None, max_iter=100, tol=1. renumber_df['map'] = input_graph.edgelist.renumber_map renumber_df['id'] = input_graph.edgelist.renumber_map.index.astype(np.int32) personalization_values = personalization.merge(renumber_df, left_on='vertex', right_on='map', how='left').drop('map') - c_pers_vtx = get_column_data_ptr(personalization_values['id']._column) - c_pers_val = get_column_data_ptr(personalization_values['values']._column) + #c_pers_vtx = get_column_data_ptr(personalization_values['id']._column) + c_pers_vtx = personalization_values['id'].__cuda_array_interface__['data'][0] + #c_pers_val = get_column_data_ptr(personalization_values['values']._column) + c_pers_val = personalization_values['values'].__cuda_array_interface__['data'][0] else: - c_pers_vtx = get_column_data_ptr(personalization['vertex']._column) - c_pers_val = get_column_data_ptr(personalization['values']._column) + #c_pers_vtx = get_column_data_ptr(personalization['vertex']._column) + c_pers_vtx = personalization['vertex'].__cuda_array_interface__['data'][0] + #c_pers_val = get_column_data_ptr(personalization['values']._column) + c_pers_val = personalization['values'].__cuda_array_interface__['data'][0] if (df['pagerank'].dtype == np.float32): c_pagerank.pagerank[int, float](g, c_pagerank_val, sz, c_pers_vtx, c_pers_val, diff --git a/python/cugraph/traversal/bfs_wrapper.pyx b/python/cugraph/traversal/bfs_wrapper.pyx index 9ce35345141..1b94fa5cc97 100644 --- a/python/cugraph/traversal/bfs_wrapper.pyx +++ b/python/cugraph/traversal/bfs_wrapper.pyx @@ -64,8 +64,10 @@ def bfs(input_graph, start, directed=True): df['distance'] = cudf.Series(np.zeros(num_verts, dtype=np.int32)) df['predecessor'] = cudf.Series(np.zeros(num_verts, dtype=np.int32)) cdef gdf_column c_vertex_col = get_gdf_column_view(df['vertex']) - cdef uintptr_t c_distance_ptr = get_column_data_ptr(df['distance']._column) - cdef uintptr_t c_predecessors_ptr = get_column_data_ptr(df['predecessor']._column) + #cdef uintptr_t c_distance_ptr = get_column_data_ptr(df['distance']._column) + cdef uintptr_t c_distance_ptr = df['distance'].__cuda_array_interface__['data'][0] + #cdef uintptr_t c_predecessors_ptr = get_column_data_ptr(df['predecessor']._column) + cdef uintptr_t c_predecessors_ptr = df['predecessor'].__cuda_array_interface__['data'][0] g.adjList.get_vertex_identifiers(&c_vertex_col) diff --git a/python/cugraph/traversal/sssp_wrapper.pyx b/python/cugraph/traversal/sssp_wrapper.pyx index 07b1c677a0d..403de596010 100644 --- a/python/cugraph/traversal/sssp_wrapper.pyx +++ b/python/cugraph/traversal/sssp_wrapper.pyx @@ -77,8 +77,10 @@ def sssp(input_graph, source): df['distance'] = cudf.Series(np.zeros(num_verts, dtype=data_type)) df['predecessor'] = cudf.Series(np.zeros(num_verts, dtype=np.int32)) - cdef uintptr_t c_distance_ptr = get_column_data_ptr(df['distance']._column) - cdef uintptr_t c_predecessors_ptr = get_column_data_ptr(df['predecessor']._column) + #cdef uintptr_t c_distance_ptr = get_column_data_ptr(df['distance']._column) + cdef uintptr_t c_distance_ptr = df['distance'].__cuda_array_interface__['data'][0] + #cdef uintptr_t c_predecessors_ptr = get_column_data_ptr(df['predecessor']._column) + cdef uintptr_t c_predecessors_ptr = df['predecessor'].__cuda_array_interface__['data'][0] g.adjList.get_vertex_identifiers(&c_identifier_col) diff --git a/python/cugraph/utilities/column_utils.pyx b/python/cugraph/utilities/column_utils.pyx index 21b19c6e78b..62d4951fc41 100644 --- a/python/cugraph/utilities/column_utils.pyx +++ b/python/cugraph/utilities/column_utils.pyx @@ -17,7 +17,6 @@ # cython: language_level = 3 #from cugraph.structure.graph cimport * -from cudf._lib.cudf cimport get_column_data_ptr, get_column_valid_ptr from libc.stdint cimport uintptr_t from libc.stdlib cimport calloc, malloc, free @@ -25,6 +24,11 @@ import cudf import cudf._lib as libcudf import numpy as np +cdef uintptr_t get_column_data_ptr(col): + """ + Get the data pointer from a cudf.Series object + """ + return col.__cuda_array_interface__['data'][0] cdef gdf_column get_gdf_column_view(col): """ @@ -47,7 +51,8 @@ cdef gdf_column get_gdf_column_view(col): if col._column._mask is None: valid_ptr = 0 else: - valid_ptr = get_column_valid_ptr(col._column) + #valid_ptr = get_column_valid_ptr(col._column) + valid_ptr = 0 cdef uintptr_t category = 0 cdef gdf_dtype_extra_info c_extra_dtype_info = gdf_dtype_extra_info( time_unit=TIME_UNIT_NONE, From 03762298e37b089a941d4fb43ef91180d4be1f70 Mon Sep 17 00:00:00 2001 From: James Wyles Date: Wed, 12 Feb 2020 18:38:31 -0700 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade69fd89a6..81b9ad5732e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - PR #692 Add check after opening golden result files in C++ Katz Centrality tests. - PR #702 Add libcypher include path to target_include_directories +- PR #716 Fixed bug due to disappearing get_column_data_ptr function in cudf # cuGraph 0.12.0 (04 Feb 2020)