Skip to content

Commit

Permalink
Merge pull request rapidsai#716 from jwyles/bug_fix
Browse files Browse the repository at this point in the history
[REVIEW] Fixing bug with disappearing get_column_data_ptr function
  • Loading branch information
BradReesWork authored Feb 13, 2020
2 parents e0ce323 + 0376229 commit 81f776b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion python/cugraph/community/ecg_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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] (<Graph*>g, min_weight, ensemble_size, <int32_t*>c_ecg_ptr)
Expand Down
5 changes: 3 additions & 2 deletions python/cugraph/community/louvain_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
16 changes: 11 additions & 5 deletions python/cugraph/link_analysis/pagerank_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <uintptr_t>NULL
cdef uintptr_t c_pers_val = <uintptr_t>NULL
cdef sz = 0
Expand All @@ -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, <float*> c_pagerank_val, sz, <int*> c_pers_vtx, <float*> c_pers_val,
Expand Down
6 changes: 4 additions & 2 deletions python/cugraph/traversal/bfs_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions python/cugraph/traversal/sssp_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions python/cugraph/utilities/column_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
# 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

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):
"""
Expand All @@ -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,
Expand Down

0 comments on commit 81f776b

Please sign in to comment.