MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / InitP2P

Function InitP2P

paddle/fluid/framework/compiled_program.cc:428–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428void InitP2P(const std::vector<phi::Place> &places) {
429#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
430 std::call_once(p2p_init_flag, [&]() {
431 int count = places.size();
432 if (count <= 1) return;
433
434 std::vector<int> devices;
435 for (int i = 0; i < count; i++) {
436 if (!phi::is_gpu_place(places[i])) return;
437
438 phi::GPUPlace device = places[i];
439 devices.push_back(device.GetDeviceId());
440 }
441
442 for (int i = 0; i < count; ++i) {
443 for (int j = 0; j < count; ++j) {
444 if (devices[i] == devices[j]) continue;
445 int can_access = -1;
446#ifdef PADDLE_WITH_HIP
447 hipError_t ret =
448 hipDeviceCanAccessPeer(&can_access, devices[i], devices[j]);
449 if (ret != hipSuccess || can_access != 1) {
450#else
451 cudaError_t ret =
452 cudaDeviceCanAccessPeer(&can_access, devices[i], devices[j]);
453 if (ret != cudaSuccess || can_access != 1) {
454#endif
455 LOG(WARNING) << "Cannot enable P2P access from " << devices[i]
456 << " to " << devices[j];
457 } else {
458 platform::CUDADeviceGuard guard(devices[i]);
459#ifdef PADDLE_WITH_HIP
460 hipDeviceEnablePeerAccess(devices[j], 0);
461#else
462 cudaDeviceEnablePeerAccess(devices[j], 0);
463#endif
464 }
465 }
466 }
467 VLOG(1) << "init p2p";
468 });
469#endif
470}
471
472CompiledProgram::CompiledProgram(const std::vector<phi::Place> &places,
473 const std::vector<std::string> &bcast_vars,

Callers 1

CompiledProgramMethod · 0.85

Calls 4

is_gpu_placeFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45
GetDeviceIdMethod · 0.45

Tested by

no test coverage detected