forked from rapidsai/cugraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from betochimas/branch-22.06
Merging in 22.06 branch w/ sg katz branch for eigen
- Loading branch information
Showing
39 changed files
with
1,103 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
cmake_version: | ||
- ">=3.20.1,<3.23" | ||
- ">=3.20.1,!=3.23.0" | ||
|
||
doxygen_version: | ||
- ">=1.8.11" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* 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 <cugraph_c/graph.h> | ||
#include <cugraph_c/resource_handle.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Opaque labeling result type | ||
*/ | ||
typedef struct { | ||
int32_t align_; | ||
} cugraph_labeling_result_t; | ||
|
||
/** | ||
* @brief Get the vertex ids from the labeling result | ||
* | ||
* @param [in] result The result from a labeling algorithm | ||
* @return type erased array of vertex ids | ||
*/ | ||
cugraph_type_erased_device_array_view_t* cugraph_labeling_result_get_vertices( | ||
cugraph_labeling_result_t* result); | ||
|
||
/** | ||
* @brief Get the label values from the labeling result | ||
* | ||
* @param [in] result The result from a labeling algorithm | ||
* @return type erased array of label values | ||
*/ | ||
cugraph_type_erased_device_array_view_t* cugraph_labeling_result_get_labels( | ||
cugraph_labeling_result_t* result); | ||
|
||
/** | ||
* @brief Free labeling result | ||
* | ||
* @param [in] result The result from a labeling algorithm | ||
*/ | ||
void cugraph_labeling_result_free(cugraph_labeling_result_t* result); | ||
|
||
/** | ||
* @brief Labels each vertex in the input graph with its (weakly-connected-)component ID | ||
* | ||
* The input graph must be symmetric. Component IDs can be arbitrary integers (they can be | ||
* non-consecutive and are not ordered by component size or any other criterion). | ||
* | ||
* @param [in] handle Handle for accessing resources | ||
* @param [in] graph Pointer to graph | ||
* @param [in] do_expensive_check A flag to run expensive checks for input arguments (if set to | ||
* `true`). | ||
* @param [out] result Opaque pointer to labeling results | ||
* @param [out] error Pointer to an error object storing details of any error. Will | ||
* be populated if error code is not CUGRAPH_SUCCESS | ||
*/ | ||
cugraph_error_code_t cugraph_weakly_connected_components(const cugraph_resource_handle_t* handle, | ||
cugraph_graph_t* graph, | ||
bool_t do_expensive_check, | ||
cugraph_labeling_result_t** result, | ||
cugraph_error_t** error); | ||
|
||
/** | ||
* @brief Labels each vertex in the input graph with its (strongly-connected-)component ID | ||
* | ||
* The input graph may be asymmetric. Component IDs can be arbitrary integers (they can be | ||
* non-consecutive and are not ordered by component size or any other criterion). | ||
* | ||
* @param [in] handle Handle for accessing resources | ||
* @param [in] graph Pointer to graph | ||
* @param [in] do_expensive_check A flag to run expensive checks for input arguments (if set to | ||
* `true`). | ||
* @param [out] result Opaque pointer to labeling results | ||
* @param [out] error Pointer to an error object storing details of any error. Will | ||
* be populated if error code is not CUGRAPH_SUCCESS | ||
*/ | ||
cugraph_error_code_t cugraph_strongly_connected_components(const cugraph_resource_handle_t* handle, | ||
cugraph_graph_t* graph, | ||
bool_t do_expensive_check, | ||
cugraph_labeling_result_t** result, | ||
cugraph_error_t** error); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include <cugraph_c/labeling_algorithms.h> | ||
|
||
#include <c_api/labeling_result.hpp> | ||
|
||
extern "C" cugraph_type_erased_device_array_view_t* cugraph_labeling_result_get_vertices( | ||
cugraph_labeling_result_t* result) | ||
{ | ||
auto internal_pointer = reinterpret_cast<cugraph::c_api::cugraph_labeling_result_t*>(result); | ||
return reinterpret_cast<cugraph_type_erased_device_array_view_t*>( | ||
internal_pointer->vertex_ids_->view()); | ||
} | ||
|
||
extern "C" cugraph_type_erased_device_array_view_t* cugraph_labeling_result_get_labels( | ||
cugraph_labeling_result_t* result) | ||
{ | ||
auto internal_pointer = reinterpret_cast<cugraph::c_api::cugraph_labeling_result_t*>(result); | ||
return reinterpret_cast<cugraph_type_erased_device_array_view_t*>( | ||
internal_pointer->labels_->view()); | ||
} | ||
|
||
extern "C" void cugraph_labeling_result_free(cugraph_labeling_result_t* result) | ||
{ | ||
auto internal_pointer = reinterpret_cast<cugraph::c_api::cugraph_labeling_result_t*>(result); | ||
delete internal_pointer->vertex_ids_; | ||
delete internal_pointer->labels_; | ||
delete internal_pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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 <c_api/array.hpp> | ||
|
||
namespace cugraph { | ||
namespace c_api { | ||
|
||
struct cugraph_labeling_result_t { | ||
cugraph_type_erased_device_array_t* vertex_ids_; | ||
cugraph_type_erased_device_array_t* labels_; | ||
}; | ||
|
||
} // namespace c_api | ||
} // namespace cugraph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include <cugraph_c/labeling_algorithms.h> | ||
|
||
#include <c_api/abstract_functor.hpp> | ||
#include <c_api/graph.hpp> | ||
#include <c_api/labeling_result.hpp> | ||
#include <c_api/resource_handle.hpp> | ||
#include <c_api/utils.hpp> | ||
|
||
#include <cugraph/algorithms.hpp> | ||
#include <cugraph/detail/shuffle_wrappers.hpp> | ||
#include <cugraph/detail/utility_wrappers.hpp> | ||
#include <cugraph/graph_functions.hpp> | ||
|
||
#include <optional> | ||
|
||
namespace { | ||
|
||
struct scc_functor : public cugraph::c_api::abstract_functor { | ||
raft::handle_t const& handle_; | ||
cugraph::c_api::cugraph_graph_t* graph_{}; | ||
bool do_expensive_check_{}; | ||
cugraph::c_api::cugraph_labeling_result_t* result_{}; | ||
|
||
scc_functor(::cugraph_resource_handle_t const* handle, | ||
::cugraph_graph_t* graph, | ||
bool do_expensive_check) | ||
: abstract_functor(), | ||
handle_(*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_), | ||
graph_(reinterpret_cast<cugraph::c_api::cugraph_graph_t*>(graph)), | ||
do_expensive_check_(do_expensive_check) | ||
{ | ||
} | ||
|
||
template <typename vertex_t, | ||
typename edge_t, | ||
typename weight_t, | ||
bool store_transposed, | ||
bool multi_gpu> | ||
void operator()() | ||
{ | ||
if constexpr (!cugraph::is_candidate<vertex_t, edge_t, weight_t>::value) { | ||
unsupported(); | ||
} else { | ||
// SCC expects store_transposed == false | ||
if constexpr (store_transposed) { | ||
error_code_ = cugraph::c_api:: | ||
transpose_storage<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>( | ||
handle_, graph_, error_.get()); | ||
if (error_code_ != CUGRAPH_SUCCESS) return; | ||
} | ||
|
||
error_code_ = CUGRAPH_NOT_IMPLEMENTED; | ||
error_->error_message_ = "SCC Not currently implemented"; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
extern "C" cugraph_error_code_t cugraph_strongly_connected_components( | ||
const cugraph_resource_handle_t* handle, | ||
cugraph_graph_t* graph, | ||
bool_t do_expensive_check, | ||
cugraph_labeling_result_t** result, | ||
cugraph_error_t** error) | ||
{ | ||
scc_functor functor(handle, graph, do_expensive_check); | ||
|
||
return cugraph::c_api::run_algorithm(graph, functor, result, error); | ||
} |
Oops, something went wrong.