Skip to content

Commit

Permalink
Not enable peer access in case of the GPUs are located over QPI
Browse files Browse the repository at this point in the history
  • Loading branch information
buaaliyi committed Nov 12, 2015
1 parent 19028e7 commit 065d9f5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/caffe/parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,18 @@ P2PSync<Dtype>::P2PSync(shared_ptr<Solver<Dtype> > root_solver,
int access;
CUDA_CHECK(cudaDeviceCanAccessPeer(&access, self, peer));
if (access) {
CUDA_CHECK(cudaDeviceEnablePeerAccess(peer, 0));
cudaDeviceProp a, b;
CUDA_CHECK(cudaGetDeviceProperties(&a, self));
CUDA_CHECK(cudaGetDeviceProperties(&b, peer));
const int pci_bus_id_offset = 0x80;
if (std::max(a.pciBusID, b.pciBusID) < pci_bus_id_offset ||
std::min(a.pciBusID, b.pciBusID) >= pci_bus_id_offset) {
CUDA_CHECK(cudaDeviceEnablePeerAccess(peer, 0));
} else {
LOG(INFO) << "This will result in poor memcpy performance over QPI, if enables p2p access"
<< " from GPU " << self << " (pciBusID " << a.pciBusID << ")"
<< " to GPU " << peer << " (pciBusID " << b.pciBusID << ")";
}
} else {
LOG(INFO)<< "GPU " << self << " does not have p2p access to GPU " << peer;
}
Expand Down Expand Up @@ -262,7 +273,14 @@ P2PSync<Dtype>::~P2PSync() {
int access;
CUDA_CHECK(cudaDeviceCanAccessPeer(&access, self, peer));
if (access) {
CUDA_CHECK(cudaDeviceDisablePeerAccess(peer));
cudaDeviceProp a, b;
CUDA_CHECK(cudaGetDeviceProperties(&a, self));
CUDA_CHECK(cudaGetDeviceProperties(&b, peer));
const int pci_bus_id_offset = 0x80;
if (std::max(a.pciBusID, b.pciBusID) < pci_bus_id_offset ||
std::min(a.pciBusID, b.pciBusID) >= pci_bus_id_offset) {
CUDA_CHECK(cudaDeviceDisablePeerAccess(peer));
}
}
}

Expand Down

0 comments on commit 065d9f5

Please sign in to comment.