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

Add MG support to the C API #2110

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
19d8258
add MG support to the C API
ChuckHastings Mar 11, 2022
76819af
fix clang-format issues
ChuckHastings Mar 11, 2022
0307dad
update copyright date
ChuckHastings Mar 11, 2022
7209dc0
Updated pylibcugraph for C API changes to resource handle.
rlratzel Mar 11, 2022
ae8b037
tabs->spaces
rlratzel Mar 11, 2022
fee1344
Merge remote-tracking branch 'upstream/branch-22.04' into fea_c_api_m…
rlratzel Mar 12, 2022
4b75e18
Updated latest branch-22.04 pylibcugraph code for compatibility with …
rlratzel Mar 12, 2022
932881e
remove references to gmock (unnecessary)
ChuckHastings Mar 14, 2022
5bc0bdf
remove gmock from link information
ChuckHastings Mar 14, 2022
fda72f0
Removed gmock from libcugraph recipe, pinned gtest to 1.10.0 in libcu…
rlratzel Mar 15, 2022
08cf507
Added FIXME comment about gtest version pin.
rlratzel Mar 15, 2022
505b3b5
Adding gmock back since it appears to be needed by cmake step.
rlratzel Mar 15, 2022
fb689d2
Another attempt at removing gmock.
rlratzel Mar 15, 2022
cc46438
Adding back gmock, which seems to be needed by other cmake files.
rlratzel Mar 15, 2022
2929f18
Updated CI GPU build script to (hopefully) ensure matching cudf/libcu…
rlratzel Mar 15, 2022
67209d0
Merge branch 'remove_gmock_references' into fea_c_api_mg_implementation
rlratzel Mar 15, 2022
fff6eab
Merge remote-tracking branch 'upstream/branch-22.04' into fea_c_api_m…
rlratzel Mar 15, 2022
4c0e123
make changes based on PR comments
ChuckHastings Mar 15, 2022
b1ee1d7
Merge branch 'fea_c_api_mg_implementation' of github.com:chuckhasting…
ChuckHastings Mar 15, 2022
24fe735
fix copyright year
ChuckHastings Mar 15, 2022
b605603
include stdint.h since we're using int32_t now to define alignment mo…
ChuckHastings Mar 15, 2022
87b1279
Added testing label and FIXME.
rlratzel Mar 16, 2022
25967b7
Merge branch 'fea_c_api_mg_implementation' of https://github.com/chuc…
rlratzel Mar 16, 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
7 changes: 6 additions & 1 deletion ci/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ conda activate rapids
export PATH=$(conda info --base)/envs/rapids/bin:$PATH

gpuci_logger "Install dependencies"
# Assume libcudf will be installed via cudf. This is done to prevent the
# following:
# libcudf = 22.04.00a220315, cudf = 22.04.00a220308
# where cudf 220308 was chosen possibly because it has fewer/different
# dependencies and the corresponding recipes think they're compatible when they
# may not be.
gpuci_mamba_retry install -y \
"libcudf=${MINOR_VERSION}" \
"cudf=${MINOR_VERSION}" \
"librmm=${MINOR_VERSION}" \
"rmm=${MINOR_VERSION}" \
Expand Down
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ endif()

add_library(cugraph_c SHARED
src/c_api/cugraph_api.cpp
src/c_api/resource_handle.cpp
src/c_api/array.cpp
src/c_api/error.cpp
src/c_api/graph_sg.cpp
Expand Down
3 changes: 2 additions & 1 deletion cpp/cmake/thirdparty/get_raft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ function(find_and_configure_raft)
GIT_TAG ${PKG_PINNED_TAG}
SOURCE_SUBDIR cpp
OPTIONS
"BUILD_TESTS OFF"
"RAFT_COMPILE_LIBRARIES OFF"
"BUILD_TESTS OFF"
"BUILD_BENCH OFF"
seunghwak marked this conversation as resolved.
Show resolved Hide resolved
)

if(raft_ADDED)
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cugraph_c/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#pragma once

#include <cugraph_c/cugraph_api.h>
#include <cugraph_c/error.h>
#include <cugraph_c/graph.h>
#include <cugraph_c/resource_handle.h>

#ifdef __cplusplus
extern "C" {
Expand Down
10 changes: 5 additions & 5 deletions cpp/include/cugraph_c/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@

#pragma once

#include <cugraph_c/cugraph_api.h>
#include <cugraph_c/resource_handle.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
int align_;
int32_t align_;
} cugraph_type_erased_device_array_t;

typedef struct {
int align_;
int32_t align_;
} cugraph_type_erased_device_array_view_t;

typedef struct {
int align_;
int32_t align_;
} cugraph_type_erased_host_array_t;

typedef struct {
int align_;
int32_t align_;
} cugraph_type_erased_host_array_view_t;

/**
Expand Down
22 changes: 2 additions & 20 deletions cpp/include/cugraph_c/cugraph_api.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 @@ -17,6 +17,7 @@
#pragma once

#include <cugraph_c/error.h>
#include <cugraph_c/resource_handle.h>

#include <cuda_runtime_api.h>
#include <stddef.h>
Expand All @@ -26,21 +27,8 @@
extern "C" {
#endif

typedef enum bool_ { FALSE = 0, TRUE = 1 } bool_t;

typedef int8_t byte_t;

typedef enum data_type_id_ { INT32 = 0, INT64, FLOAT32, FLOAT64, NTYPES } data_type_id_t;

/* sizes in Bytes for data_type_id_t*/
extern int data_type_sz[];

/* C stub declarations */

typedef struct cugraph_resource_handle_ {
int align_;
} cugraph_resource_handle_t;

typedef struct cugraph_graph_envelope_ {
int align_;
} cugraph_graph_envelope_t;
Expand Down Expand Up @@ -160,12 +148,6 @@ cugraph_error_code_t cugraph_update_host_buffer(const cugraph_resource_handle_t*
byte_t* ptr_h_dst,
const cugraph_device_buffer_t* ptr_src);

/* raft::handle_t allocator (for now; possibly a more encompassing handle in the future)*/
cugraph_resource_handle_t* cugraph_create_resource_handle(void);

/* raft::handle_t deallocator*/
void cugraph_free_resource_handle(cugraph_resource_handle_t* p_handle);

#ifdef __cplusplus
}
#endif
6 changes: 4 additions & 2 deletions cpp/include/cugraph_c/error.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 @@ -16,6 +16,8 @@

#pragma once

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -31,7 +33,7 @@ typedef enum cugraph_error_code_ {
} cugraph_error_code_t;

typedef struct cugraph_error_ {
int align_;
int32_t align_;
} cugraph_error_t;

/**
Expand Down
28 changes: 13 additions & 15 deletions cpp/include/cugraph_c/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ extern "C" {
#endif

typedef struct {
int align_;
int32_t align_;
} cugraph_graph_t;

typedef struct {
bool_t is_symmetric;
bool_t is_multigraph;
} cugraph_graph_properties_t;

// FIXME: Add support for specifying isloated vertices
/**
* @brief Construct an SG graph
*
Expand Down Expand Up @@ -73,6 +74,7 @@ cugraph_error_code_t cugraph_sg_graph_create(const cugraph_resource_handle_t* ha
// but didn't want to confuse with original cugraph_free_graph
void cugraph_sg_graph_free(cugraph_graph_t* graph);

// FIXME: Add support for specifying isloated vertices
/**
* @brief Construct an MG graph
*
Expand All @@ -94,20 +96,16 @@ void cugraph_sg_graph_free(cugraph_graph_t* graph);
* be populated if error code is not CUGRAPH_SUCCESS
* @return error code
*/
cugraph_error_code_t cugraph_mg_graph_create(
const cugraph_resource_handle_t* handle,
const cugraph_graph_properties_t* properties,
const cugraph_type_erased_device_array_view_t* src,
const cugraph_type_erased_device_array_view_t* dst,
const cugraph_type_erased_device_array_view_t* weights,
const cugraph_type_erased_host_array_view_t* vertex_partition_offsets,
const cugraph_type_erased_host_array_view_t* segment_offsets,
bool_t store_transposed,
size_t num_vertices,
size_t num_edges,
bool_t check,
cugraph_graph_t** graph,
cugraph_error_t** error);
cugraph_error_code_t cugraph_mg_graph_create(const cugraph_resource_handle_t* handle,
const cugraph_graph_properties_t* properties,
const cugraph_type_erased_device_array_view_t* src,
const cugraph_type_erased_device_array_view_t* dst,
const cugraph_type_erased_device_array_view_t* weights,
bool_t store_transposed,
size_t num_edges,
bool_t check,
cugraph_graph_t** graph,
cugraph_error_t** error);
seunghwak marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Destroy an MG graph
Expand Down
76 changes: 76 additions & 0 deletions cpp/include/cugraph_c/resource_handle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 governing permissions and
* limitations under the License.
*/

#pragma once

#include <cugraph_c/error.h>

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum bool_ { FALSE = 0, TRUE = 1 } bool_t;

typedef int8_t byte_t;

typedef enum data_type_id_ { INT32 = 0, INT64, FLOAT32, FLOAT64, NTYPES } data_type_id_t;

/* sizes in Bytes for data_type_id_t*/
extern size_t data_type_sz[];

typedef struct cugraph_resource_handle_ {
int32_t align_;
} cugraph_resource_handle_t;

// FIXME: Don't really want a raft handle here. We really want to be able to
// configure the resource handle ourselves. But that requires a bunch
// of logic that's currently only available in python.
/**
* @brief Construct a resource handle
*
* @param [in] raft_handle Handle for accessing resources
* If NULL, we will create a raft handle
* internally
*
* @return A graph resource handle
*/
cugraph_resource_handle_t* cugraph_create_resource_handle(void* raft_handle);

/**
* @brief get rank from resource handle
*
* If the resource handle has been configured for multi-gpu, this will return
* the rank for this worker. If the resource handle has not been configured for
* multi-gpu this will always return 0.
*
* @param [in] handle Handle for accessing resources
* @return rank
*/
int cugraph_resource_handle_get_rank(const cugraph_resource_handle_t* handle);

/**
* @brief Free resources in the resource handle
*
* @param [in] handle Handle for accessing resources
*/
void cugraph_free_resource_handle(cugraph_resource_handle_t* handle);

#ifdef __cplusplus
}
#endif
Loading