@@ -132,6 +132,7 @@ struct two_hop_neighbors_functor : public cugraph::c_api::abstract_functor {
132
132
bool multi_gpu>
133
133
void operator ()()
134
134
{
135
+ printf (" \n in two_hop_neighbors \n " );
135
136
if constexpr (!cugraph::is_candidate<vertex_t , edge_t , weight_t >::value) {
136
137
unsupported ();
137
138
} else {
@@ -157,11 +158,17 @@ struct two_hop_neighbors_functor : public cugraph::c_api::abstract_functor {
157
158
start_vertices_->as_type <vertex_t const >(),
158
159
start_vertices_->size_ ,
159
160
handle_.get_stream ());
161
+
162
+ raft::print_device_vector (" b_start_vertices" , start_vertices.data (), start_vertices.size (), std::cout);
160
163
161
164
if constexpr (multi_gpu) {
162
165
start_vertices = cugraph::shuffle_ext_vertices (handle_, std::move (start_vertices));
163
166
}
164
167
168
+ raft::print_device_vector (" number_map" , number_map->data (), number_map->size (), std::cout);
169
+
170
+
171
+
165
172
cugraph::renumber_ext_vertices<vertex_t , multi_gpu>(
166
173
handle_,
167
174
start_vertices.data (),
@@ -170,6 +177,8 @@ struct two_hop_neighbors_functor : public cugraph::c_api::abstract_functor {
170
177
graph_view.local_vertex_partition_range_first (),
171
178
graph_view.local_vertex_partition_range_last (),
172
179
do_expensive_check_);
180
+
181
+ raft::print_device_vector (" a_start_vertices" , start_vertices.data (), start_vertices.size (), std::cout);
173
182
174
183
} else {
175
184
start_vertices.resize (graph_view.local_vertex_partition_range_size (), handle_.get_stream ());
@@ -260,6 +269,176 @@ struct count_multi_edges_functor : public cugraph::c_api::abstract_functor {
260
269
}
261
270
}
262
271
};
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+ #if 0
292
+ struct has_vertex_functor : public cugraph::c_api::abstract_functor {
293
+ raft::handle_t const& handle_{};
294
+ cugraph::c_api::cugraph_graph_t* graph_{nullptr};
295
+ cugraph::c_api::cugraph_type_erased_device_array_view_t const* vertex_{nullptr};
296
+ bool result_{};
297
+ bool do_expensive_check_{false};
298
+
299
+ has_vertex_functor(::cugraph_resource_handle_t const* handle,
300
+ ::cugraph_graph_t* graph,
301
+ ::cugraph_type_erased_device_array_view_t const* vertex,
302
+ bool do_expensive_check)
303
+ : abstract_functor(),
304
+ handle_(*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_),
305
+ graph_(reinterpret_cast<cugraph::c_api::cugraph_graph_t*>(graph)),
306
+ vertex_(
307
+ reinterpret_cast<cugraph::c_api::cugraph_type_erased_device_array_view_t const*>(
308
+ vertex)),
309
+ do_expensive_check_(do_expensive_check)
310
+ {
311
+ }
312
+
313
+ template <typename vertex_t,
314
+ typename edge_t,
315
+ typename weight_t,
316
+ typename edge_type_type_t,
317
+ bool store_transposed,
318
+ bool multi_gpu>
319
+ void operator()()
320
+ {
321
+ if constexpr (!cugraph::is_candidate<vertex_t, edge_t, weight_t>::value) {
322
+ unsupported();
323
+ } else {
324
+ // k_hop_nbrs expects store_transposed == false
325
+ if constexpr (store_transposed) {
326
+ error_code_ = cugraph::c_api::
327
+ transpose_storage<vertex_t, edge_t, weight_t, store_transposed, multi_gpu>(
328
+ handle_, graph_, error_.get());
329
+ if (error_code_ != CUGRAPH_SUCCESS) return;
330
+ }
331
+
332
+ auto graph =
333
+ reinterpret_cast<cugraph::graph_t<vertex_t, edge_t, false, multi_gpu>*>(graph_->graph_);
334
+
335
+ auto graph_view = graph->view();
336
+ auto number_map = reinterpret_cast<rmm::device_uvector<vertex_t>*>(graph_->number_map_);
337
+
338
+ rmm::device_uvector<vertex_t> vertex(0, handle_.get_stream());
339
+
340
+
341
+ vertex.resize(vertex_->size_, handle_.get_stream());
342
+ raft::copy(vertex.data(),
343
+ vertex_->as_type<vertex_t const>(),
344
+ vertex_->size_,
345
+ handle_.get_stream());
346
+
347
+ if constexpr (multi_gpu) {
348
+ vertex = cugraph::shuffle_ext_vertices(handle_, std::move(vertex));
349
+ }
350
+
351
+ //raft::print_device_vector("number_map", number_map->data(), number_map->size(), std::cout);
352
+
353
+ cugraph::renumber_ext_vertices<vertex_t, multi_gpu>(
354
+ handle_,
355
+ vertex.data(),
356
+ vertex.size(),
357
+ number_map->data(),
358
+ graph_view.local_vertex_partition_range_first(),
359
+ graph_view.local_vertex_partition_range_last(),
360
+ do_expensive_check_);
361
+
362
+ // Perform binary search to see if vertex exist
363
+
364
+
365
+
366
+
367
+
368
+ auto [offsets, dst] = cugraph::k_hop_nbrs(
369
+ handle_,
370
+ graph_view,
371
+ raft::device_span<vertex_t const>{vertex.data(), vertex.size()},
372
+ size_t{2},
373
+ do_expensive_check_);
374
+
375
+ auto src = cugraph::c_api::expand_sparse_offsets(
376
+ raft::device_span<size_t const>{offsets.data(), offsets.size()},
377
+ vertex_t{0},
378
+ handle_.get_stream());
379
+
380
+ // convert ids back to srcs: src[i] = vertex[src[i]]
381
+ cugraph::unrenumber_local_int_vertices(handle_,
382
+ src.data(),
383
+ src.size(),
384
+ vertex.data(),
385
+ vertex_t{0},
386
+ graph_view.local_vertex_partition_range_size(),
387
+ do_expensive_check_);
388
+
389
+ cugraph::unrenumber_int_vertices<vertex_t, multi_gpu>(
390
+ handle_,
391
+ src.data(),
392
+ src.size(),
393
+ number_map->data(),
394
+ graph_view.vertex_partition_range_lasts(),
395
+ do_expensive_check_);
396
+
397
+ cugraph::unrenumber_int_vertices<vertex_t, multi_gpu>(
398
+ handle_,
399
+ dst.data(),
400
+ dst.size(),
401
+ number_map->data(),
402
+ graph_view.vertex_partition_range_lasts(),
403
+ do_expensive_check_);
404
+
405
+ result_ = new cugraph::c_api::cugraph_vertex_pairs_t{
406
+ new cugraph::c_api::cugraph_type_erased_device_array_t(src, graph_->vertex_type_),
407
+ new cugraph::c_api::cugraph_type_erased_device_array_t(dst, graph_->vertex_type_)};
408
+ }
409
+ }
410
+ };
411
+ #endif
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
263
442
264
443
} // namespace
265
444
@@ -339,3 +518,18 @@ extern "C" cugraph_error_code_t cugraph_count_multi_edges(const cugraph_resource
339
518
340
519
return cugraph::c_api::run_algorithm (graph, functor, result, error);
341
520
}
521
+
522
+ #if 0
523
+ extern "C" cugraph_error_code_t cugraph_has_vertex(
524
+ const cugraph_resource_handle_t* handle,
525
+ cugraph_graph_t* graph,
526
+ const cugraph_type_erased_device_array_view_t* vertex,
527
+ bool_t do_expensive_check,
528
+ bool_t* result,
529
+ cugraph_error_t** error)
530
+ {
531
+ has_vertex_functor functor(handle, graph, vertex, do_expensive_check);
532
+
533
+ return cugraph::c_api::run_algorithm(graph, functor, result, error);
534
+ }
535
+ #endif
0 commit comments