Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python API updates to enable explicit control of internal graph_t creation and deletion #2023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
55ecf5c
Start of GPUGraphData class and test, added 'experimental' decorator.
rlratzel Jan 17, 2022
9814793
Initial pylibcugraph cython files for cugraph_c API, still WIP.
rlratzel Jan 17, 2022
ca784da
pylibcugraph C API cython code cythonizes and compiles, new bindings …
rlratzel Jan 17, 2022
56e189f
Added initial RAII-style cdef classes (not building yet).
rlratzel Jan 18, 2022
f3d2c49
Renamed files under _cugraph_c to drop the leading underscore since i…
rlratzel Jan 18, 2022
2ea5408
Refactored experimental() to use a separate function for returning th…
rlratzel Jan 19, 2022
7420e84
Removed experimental decorator in favor of simple wrapper function an…
rlratzel Jan 19, 2022
da468a4
More progress on SGGraph (just need C API to do device-to-device arra…
rlratzel Jan 20, 2022
7eded4c
Merge remote-tracking branch 'upstream/branch-22.02' into branch-22.0…
rlratzel Jan 20, 2022
2c2f85b
flake8 fixes.
rlratzel Jan 20, 2022
ab387c1
flake8 fix, updated copyright dates.
rlratzel Jan 20, 2022
e7c3fc8
Merge remote-tracking branch 'upstream/branch-22.02' into branch-22.0…
rlratzel Jan 20, 2022
6ad71c8
Test refactoring.
rlratzel Jan 20, 2022
c35740e
Added start of pagerank bindings, renamed all .pxd files that are 1:1…
rlratzel Jan 21, 2022
4595b80
Merge remote-tracking branch 'upstream/branch-22.02' into branch-22.0…
rlratzel Jan 21, 2022
4acd8aa
Test refactoring to better handle fixtures that provide inputs and as…
rlratzel Jan 21, 2022
b340d7a
flake8 fixes.
rlratzel Jan 21, 2022
7d5806b
Updated copyright year.
rlratzel Jan 21, 2022
1c2fc02
add view semantic for arrays. Add copy between device arrays
ChuckHastings Jan 21, 2022
5c3414e
Merge branch 'branch-22.02' into mods_for_pylibcugraph
ChuckHastings Jan 22, 2022
d25eefe
update copyright
ChuckHastings Jan 22, 2022
8f8c1c9
Updated pagerank test to include expected results, added comments.
rlratzel Jan 22, 2022
dfee323
flake8 fixes.
rlratzel Jan 22, 2022
a0f8af6
Merge remote-tracking branch 'upstream/branch-22.02' into branch-22.0…
rlratzel Jan 22, 2022
8d16bdc
Merge branch 'branch-22.02' into mods_for_pylibcugraph
ChuckHastings Jan 22, 2022
7257c05
fix clang-format issues
ChuckHastings Jan 22, 2022
ed72209
More refactoring to make it clear which cython files are strictly for…
rlratzel Jan 22, 2022
b7131ad
Updated sssp placeholder test to have expected results, added initial…
rlratzel Jan 23, 2022
786a54a
Refactored to add a util function for checking input types, started a…
rlratzel Jan 23, 2022
41d5270
More work converting return types, added cython directive to use pyth…
rlratzel Jan 23, 2022
a90b0d8
Merge remote-tracking branch 'ChuckHastings/mods_for_pylibcugraph' in…
rlratzel Jan 23, 2022
c32eee7
Updates for C API changes to support view types.
rlratzel Jan 24, 2022
931e6e1
generate the view correctly for extract paths
ChuckHastings Jan 24, 2022
2c0cda6
should use raft::copy in the device copy
ChuckHastings Jan 24, 2022
f316686
Merge branch 'branch-22.02' into mods_for_pylibcugraph
ChuckHastings Jan 24, 2022
720ffa5
fix clang-format issues
ChuckHastings Jan 24, 2022
e47c803
fix a few bugs that Rick found
ChuckHastings Jan 25, 2022
258d508
Merge remote-tracking branch 'ChuckHastings/mods_for_pylibcugraph' in…
rlratzel Jan 25, 2022
dd27db1
Initial passing pagerank tests.
rlratzel Jan 25, 2022
90c3a04
Test refactoring, finished initial SSSP and updated tests.
rlratzel Jan 25, 2022
76c1c75
flake8 fixes.
rlratzel Jan 25, 2022
1b1bce1
Clarified comment.
rlratzel Jan 25, 2022
a5d5daf
Merge remote-tracking branch 'upstream/branch-22.02' into branch-22.0…
rlratzel Jan 26, 2022
96aa3cc
Added documentation.
rlratzel Jan 26, 2022
0824dca
bug fix
seunghwak Jan 26, 2022
48b5c51
Added docstring content, added checks to ensure unsupported params ar…
rlratzel Jan 26, 2022
7dc94de
Merge branch 'bug_transpose_storage' into mods_for_pylibcugraph
ChuckHastings Jan 26, 2022
cf5b25e
update tests to reflect bug fix for transpose
ChuckHastings Jan 26, 2022
6748668
add FIXME to code that is current ifdeffed out
ChuckHastings Jan 26, 2022
357d2b8
Merge remote-tracking branch 'ChuckHastings/mods_for_pylibcugraph' in…
rlratzel Jan 26, 2022
d2b9176
Added FIXMEs based on review feedback, fixed typo in docstring.
rlratzel Jan 26, 2022
60549ba
Fixed inconsistency in param name/doc string, added FIXME for more te…
rlratzel Jan 26, 2022
404f3fc
Added FIXMEs
rlratzel Jan 26, 2022
f761712
Fixed param name after changing it in the API.
rlratzel Jan 26, 2022
22667c6
Minor update to docstring example to match param update.
rlratzel Jan 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions cpp/include/cugraph_c/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct {
* @param [in] result The result from pagerank
* @return type erased array of vertex ids
*/
cugraph_type_erased_device_array_t* cugraph_pagerank_result_get_vertices(
cugraph_type_erased_device_array_view_t* cugraph_pagerank_result_get_vertices(
cugraph_pagerank_result_t* result);

/**
Expand All @@ -46,7 +46,7 @@ cugraph_type_erased_device_array_t* cugraph_pagerank_result_get_vertices(
* @param [in] result The result from pagerank
* @return type erased array of pagerank values
*/
cugraph_type_erased_device_array_t* cugraph_pagerank_result_get_pageranks(
cugraph_type_erased_device_array_view_t* cugraph_pagerank_result_get_pageranks(
cugraph_pagerank_result_t* result);

/**
Expand Down Expand Up @@ -84,7 +84,7 @@ void cugraph_pagerank_result_free(cugraph_pagerank_result_t* result);
cugraph_error_code_t cugraph_pagerank(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_t* precomputed_vertex_out_weight_sums,
const cugraph_type_erased_device_array_view_t* precomputed_vertex_out_weight_sums,
double alpha,
double epsilon,
size_t max_iterations,
Expand Down Expand Up @@ -127,10 +127,10 @@ cugraph_error_code_t cugraph_pagerank(
cugraph_error_code_t cugraph_personalized_pagerank(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_t* precomputed_vertex_out_weight_sums,
const cugraph_type_erased_device_array_view_t* precomputed_vertex_out_weight_sums,
// FIXME: Make this const, copy it if I need to temporarily modify internally
cugraph_type_erased_device_array_t* personalization_vertices,
const cugraph_type_erased_device_array_t* personalization_values,
cugraph_type_erased_device_array_view_t* personalization_vertices,
const cugraph_type_erased_device_array_view_t* personalization_values,
double alpha,
double epsilon,
size_t max_iterations,
Expand All @@ -155,7 +155,7 @@ typedef struct {
* @param [in] result The result from bfs or sssp
* @return type erased array of vertex ids
*/
cugraph_type_erased_device_array_t* cugraph_paths_result_get_vertices(
cugraph_type_erased_device_array_view_t* cugraph_paths_result_get_vertices(
cugraph_paths_result_t* result);

/**
Expand All @@ -164,7 +164,7 @@ cugraph_type_erased_device_array_t* cugraph_paths_result_get_vertices(
* @param [in] result The result from bfs or sssp
* @return type erased array of distances
*/
cugraph_type_erased_device_array_t* cugraph_paths_result_get_distances(
cugraph_type_erased_device_array_view_t* cugraph_paths_result_get_distances(
cugraph_paths_result_t* result);

/**
Expand All @@ -175,7 +175,7 @@ cugraph_type_erased_device_array_t* cugraph_paths_result_get_distances(
* compute_predecessors was FALSE in the call to bfs or sssp that
* produced this result.
*/
cugraph_type_erased_device_array_t* cugraph_paths_result_get_predecessors(
cugraph_type_erased_device_array_view_t* cugraph_paths_result_get_predecessors(
cugraph_paths_result_t* result);

/**
Expand Down Expand Up @@ -216,7 +216,7 @@ cugraph_error_code_t cugraph_bfs(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
// FIXME: Make this const, copy it if I need to temporarily modify internally
cugraph_type_erased_device_array_t* sources,
cugraph_type_erased_device_array_view_t* sources,
bool_t direction_optimizing,
size_t depth_limit,
bool_t compute_predecessors,
Expand Down Expand Up @@ -280,13 +280,14 @@ typedef struct {
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_extract_paths(const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_t* sources,
const cugraph_paths_result_t* paths_result,
const cugraph_type_erased_device_array_t* destinations,
cugraph_extract_paths_result_t** result,
cugraph_error_t** error);
cugraph_error_code_t cugraph_extract_paths(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_view_t* sources,
const cugraph_paths_result_t* paths_result,
const cugraph_type_erased_device_array_view_t* destinations,
cugraph_extract_paths_result_t** result,
cugraph_error_t** error);

/**
* @brief Get the max path length from extract_paths result
Expand All @@ -302,7 +303,7 @@ size_t cugraph_extract_paths_result_get_max_path_length(cugraph_extract_paths_re
* @param [in] result The result from extract_paths
* @return type erased array pointing to the matrix in device memory
*/
cugraph_type_erased_device_array_t* cugraph_extract_paths_result_get_paths(
cugraph_type_erased_device_array_view_t* cugraph_extract_paths_result_get_paths(
cugraph_extract_paths_result_t* result);

/**
Expand Down
168 changes: 140 additions & 28 deletions cpp/include/cugraph_c/array.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand All @@ -26,25 +26,33 @@ typedef struct {
int align_;
} cugraph_type_erased_device_array_t;

typedef struct {
int align_;
} cugraph_type_erased_device_array_view_t;

typedef struct {
int align_;
} cugraph_type_erased_host_array_t;

typedef struct {
int align_;
} cugraph_type_erased_host_array_view_t;

/**
* @brief Create a type erased device array
*
* @param [in] handle Handle for accessing resources
* @param [in] dtype The type of array to create
* @param [in] n_elems The number of elements in the array
* @param [in] dtype The type of array to create
* @param [out] array Pointer to the location to store the pointer to the device array
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_type_erased_device_array_create(
const cugraph_resource_handle_t* handle,
data_type_id_t dtype,
size_t n_elems,
data_type_id_t dtype,
cugraph_type_erased_device_array_t** array,
cugraph_error_t** error);

Expand All @@ -55,44 +63,89 @@ cugraph_error_code_t cugraph_type_erased_device_array_create(
*/
void cugraph_type_erased_device_array_free(cugraph_type_erased_device_array_t* p);

#if 0
// FIXME: Not implemented, need to discuss if this can work. We will either implement
// this later or delete it from the interface once we resolve how to handle this
/**
* @brief Get the size of a type erased device array
* @brief Release the raw pointer of the type erased device array
*
* The caller is now responsible for freeing the device pointer
*
* @param [in] p Pointer to the type erased device array
* @return Pointer (device memory) for the data in the array
*/
void* cugraph_type_erased_device_array_release(cugraph_type_erased_device_array_t* p);
#endif

/**
* @brief Create a type erased device array view from
* a type erased device array
*
* @param [in] array Pointer to the type erased device array
* @return Pointer to the view of the host array
*/
cugraph_type_erased_device_array_view_t* cugraph_type_erased_device_array_view(
cugraph_type_erased_device_array_t* array);

/**
* @brief Create a type erased device array view from
* a raw device pointer.
*
* @param [in] pointer Raw device pointer
* @param [in] n_elems The number of elements in the array
* @param [in] dtype The type of array to create
* @return Pointer to the view of the host array
*/
cugraph_type_erased_device_array_view_t* cugraph_type_erased_device_array_view_create(
void* pointer, size_t n_elems, data_type_id_t dtype);

/**
* @brief Destroy a type erased device array view
*
* @param [in] p Pointer to the type erased device array view
*/
void cugraph_type_erased_device_array_view_free(cugraph_type_erased_device_array_view_t* p);

/**
* @brief Get the size of a type erased device array view
*
* @param [in] p Pointer to the type erased device array view
* @return The number of elements in the array
*/
size_t cugraph_type_erased_device_array_size(const cugraph_type_erased_device_array_t* p);
size_t cugraph_type_erased_device_array_view_size(const cugraph_type_erased_device_array_view_t* p);

/**
* @brief Get the type of a type erased device array
* @brief Get the type of a type erased device array view
*
* @param [in] p Pointer to the type erased device array
* @param [in] p Pointer to the type erased device array view
* @return The type of the elements in the array
*/
data_type_id_t cugraph_type_erased_device_array_type(const cugraph_type_erased_device_array_t* p);
data_type_id_t cugraph_type_erased_device_array_view_type(
const cugraph_type_erased_device_array_view_t* p);

/**
* @brief Get the raw pointer of the type erased device array
* @brief Get the raw pointer of the type erased device array view
*
* @param [in] p Pointer to the type erased device array
* @param [in] p Pointer to the type erased device array view
* @return Pointer (device memory) for the data in the array
*/
const void* cugraph_type_erased_device_array_pointer(const cugraph_type_erased_device_array_t* p);
const void* cugraph_type_erased_device_array_view_pointer(
const cugraph_type_erased_device_array_view_t* p);

/**
* @brief Create a type erased host array
*
* @param [in] handle Handle for accessing resources
* @param [in] dtype The type of array to create
* @param [in] n_elems The number of elements in the array
* @param [in] dtype The type of array to create
* @param [out] array Pointer to the location to store the pointer to the host array
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_type_erased_host_array_create(const cugraph_resource_handle_t* handle,
data_type_id_t dtype,
size_t n_elems,
data_type_id_t dtype,
cugraph_type_erased_host_array_t** array,
cugraph_error_t** error);

Expand All @@ -103,43 +156,86 @@ cugraph_error_code_t cugraph_type_erased_host_array_create(const cugraph_resourc
*/
void cugraph_type_erased_host_array_free(cugraph_type_erased_host_array_t* p);

#if 0
// FIXME: Not implemented, need to discuss if this can work. We will either implement
// this later or delete it from the interface once we resolve how to handle this
/**
* @brief Get the size of a type erased host array
* @brief Release the raw pointer of the type erased host array
*
* The caller is now responsible for freeing the host pointer
*
* @param [in] p Pointer to the type erased host array
* @return Pointer (host memory) for the data in the array
*/
void* cugraph_type_erased_host_array_release(cugraph_type_erased_host_array_t* p);
#endif

/**
* @brief Create a type erased host array view from
* a type erased host array
*
* @param [in] array Pointer to the type erased host array
* @return Pointer to the view of the host array
*/
cugraph_type_erased_host_array_view_t* cugraph_type_erased_host_array_view(
cugraph_type_erased_host_array_t* array);

/**
* @brief Create a type erased host array view from
* a raw host pointer.
*
* @param [in] pointer Raw host pointer
* @param [in] n_elems The number of elements in the array
* @param [in] dtype The type of array to create
* @return pointer to the view of the host array
*/
cugraph_type_erased_host_array_view_t* cugraph_type_erased_host_array_view_create(
void* pointer, size_t n_elems, data_type_id_t dtype);

/**
* @brief Destroy a type erased host array view
*
* @param [in] p Pointer to the type erased host array view
*/
void cugraph_type_erased_host_array_view_free(cugraph_type_erased_host_array_view_t* p);

/**
* @brief Get the size of a type erased host array view
*
* @param [in] p Pointer to the type erased host array view
* @return The number of elements in the array
*/
size_t cugraph_type_erased_host_array_size(const cugraph_type_erased_host_array_t* p);
size_t cugraph_type_erased_host_array_size(const cugraph_type_erased_host_array_view_t* p);

/**
* @brief Get the type of a type erased host array
* @brief Get the type of a type erased host array view
*
* @param [in] p Pointer to the type erased host array
* @param [in] p Pointer to the type erased host array view
* @return The type of the elements in the array
*/
data_type_id_t cugraph_type_erased_host_array_type(const cugraph_type_erased_host_array_t* p);
data_type_id_t cugraph_type_erased_host_array_type(const cugraph_type_erased_host_array_view_t* p);

/**
* @brief Get the raw pointer of the type erased host array
* @brief Get the raw pointer of the type erased host array view
*
* @param [in] p Pointer to the type erased host array
* @param [in] p Pointer to the type erased host array view
* @return Pointer (host memory) for the data in the array
*/
void* cugraph_type_erased_host_array_pointer(const cugraph_type_erased_host_array_t* p);
void* cugraph_type_erased_host_array_pointer(const cugraph_type_erased_host_array_view_t* p);

/**
* @brief Copy data from host to a type erased device array
* @brief Copy data from host to a type erased device array view
*
* @param [in] handle Handle for accessing resources
* @param [out] dst Pointer to the type erased device array
* @param [out] dst Pointer to the type erased device array view
* @param [in] h_src Pointer to host array to copy into device memory
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_type_erased_device_array_copy_from_host(
cugraph_error_code_t cugraph_type_erased_device_array_view_copy_from_host(
const cugraph_resource_handle_t* handle,
cugraph_type_erased_device_array_t* dst,
cugraph_type_erased_device_array_view_t* dst,
const byte_t* h_src,
cugraph_error_t** error);

Expand All @@ -148,15 +244,31 @@ cugraph_error_code_t cugraph_type_erased_device_array_copy_from_host(
*
* @param [in] handle Handle for accessing resources
* @param [out] h_dst Pointer to host array
* @param [in] src Pointer to the type erased device array to copy from
* @param [in] src Pointer to the type erased device array view source
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_type_erased_device_array_copy_to_host(
cugraph_error_code_t cugraph_type_erased_device_array_view_copy_to_host(
const cugraph_resource_handle_t* handle,
byte_t* h_dst,
const cugraph_type_erased_device_array_t* src,
const cugraph_type_erased_device_array_view_t* src,
cugraph_error_t** error);

/**
* @brief Copy data between two type erased device array views
*
* @param [in] handle Handle for accessing resources
* @param [out] dst Pointer to type erased device array view destination
* @param [in] src Pointer to type erased device array view source
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_type_erased_device_array_view_copy(
const cugraph_resource_handle_t* handle,
cugraph_type_erased_device_array_view_t* dst,
const cugraph_type_erased_device_array_view_t* src,
cugraph_error_t** error);

#ifdef __cplusplus
Expand Down
Loading