Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chhwang committed Sep 7, 2023
1 parent f44a225 commit 69858ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
23 changes: 13 additions & 10 deletions ark/gpu/gpu_comm_sw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ void GpuCommSw::Impl::configure(
continue;
}
// Create an MR
NetIbMr *mr = this->net_ib_mgr->reg_mr((void *)addr, ib_sid_max_bytes[sid]);
NetIbMr *mr =
this->net_ib_mgr->reg_mr((void *)addr, ib_sid_max_bytes[sid]);
this->sid_mrs[sid] = mr;
comm_ib_info.sid_mris[sid] = mr->get_info();
}
Expand Down Expand Up @@ -282,7 +283,7 @@ void GpuCommSw::Impl::configure(

std::string item_name = "comm_ib_info_" + std::to_string(remote_rank);
state = this->ipc_socket->add_item(item_name, &comm_ib_info,
sizeof(comm_ib_info));
sizeof(comm_ib_info));
if (state != IpcSocket::State::SUCCESS) {
LOG(ERROR, "Failed to post ", item_name);
}
Expand All @@ -296,9 +297,9 @@ void GpuCommSw::Impl::configure(

GpuCommIbInfo remote_comm_ib_info;

state = this->ipc_socket->query_item(
get_host(remote_host_id), port, item_name, &remote_comm_ib_info,
sizeof(remote_comm_ib_info), true);
state = this->ipc_socket->query_item(get_host(remote_host_id), port,
item_name, &remote_comm_ib_info,
sizeof(remote_comm_ib_info), true);
if (state != IpcSocket::State::SUCCESS) {
LOG(ERROR, "Failed to query ", item_name);
}
Expand All @@ -309,7 +310,8 @@ void GpuCommSw::Impl::configure(
LOG(ERROR, "NetIbQp::rtr failed");
}
LOG(DEBUG, "RANK ", this->rank, " QP ", qp->get_info().qpn,
" <--> RANK ", remote_rank, " QP ", remote_comm_ib_info.qp_info.qpn);
" <--> RANK ", remote_rank, " QP ",
remote_comm_ib_info.qp_info.qpn);
ret = qp->rts();
if (ret != 0) {
LOG(ERROR, "NetIbQp::rts failed");
Expand Down Expand Up @@ -338,8 +340,9 @@ void GpuCommSw::Impl::configure(

int dummy = 0;
std::string item_name = "comm_ib_done_" + std::to_string(this->rank);
state = this->ipc_socket->query_item(
get_host(remote_host_id), port, item_name, &dummy, sizeof(dummy), true);
state = this->ipc_socket->query_item(get_host(remote_host_id), port,
item_name, &dummy, sizeof(dummy),
true);
if (state != IpcSocket::State::SUCCESS) {
LOG(ERROR, "Failed to query ", item_name);
}
Expand Down Expand Up @@ -581,8 +584,8 @@ GpuMem *GpuCommSw::Impl::get_sc_rc_mem(const int gid)
}
GpuMem *sm = this->sc_rc_mems[gid];
if (sm == nullptr) {
this->remote_sc_rc_mems_storage.emplace_back(std::make_unique<GpuMem>(
2 * MAX_NUM_SID * sizeof(int)));
this->remote_sc_rc_mems_storage.emplace_back(
std::make_unique<GpuMem>(2 * MAX_NUM_SID * sizeof(int)));
sm = this->remote_sc_rc_mems_storage.back().get();
this->sc_rc_mems[gid] = sm;
}
Expand Down
19 changes: 11 additions & 8 deletions ark/gpu/gpu_mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Licensed under the MIT license.

#include <cassert>
#include <fstream>
#include <cstring>
#include <string>
#include <fcntl.h>
#include <fstream>
#include <string>
#include <sys/mman.h>
#include <unistd.h>

Expand All @@ -17,7 +17,7 @@

#define GPU_PAGE_SHIFT 16
#define GPU_PAGE_SIZE (1ULL << GPU_PAGE_SHIFT)
#define GPU_PAGE_OFFSET (GPU_PAGE_SIZE-1)
#define GPU_PAGE_OFFSET (GPU_PAGE_SIZE - 1)
#define GPU_PAGE_MASK (~GPU_PAGE_OFFSET)

namespace ark {
Expand Down Expand Up @@ -68,7 +68,8 @@ static int mem_expose(ExposalInfo *info, GpuPtr addr, uint64_t bytes)
uint64_t npage = bytes >> GPU_PAGE_SHIFT;
// +1 can happen as we alloc 64KB more for safe alignment.
if (npage != lock.page_count && npage + 1 != lock.page_count) {
LOG(ERROR, "Unexpected number of pages: ", npage, " vs ", lock.page_count);
LOG(ERROR, "Unexpected number of pages: ", npage, " vs ",
lock.page_count);
}
npage = lock.page_count;
int state_bytes = sizeof(gpudma_state_t) + npage * sizeof(uint64_t);
Expand All @@ -87,8 +88,8 @@ static int mem_expose(ExposalInfo *info, GpuPtr addr, uint64_t bytes)
info->npage = npage;
free(state);
// Create mmap of all pages.
info->mmap =
mmap(0, npage << GPU_PAGE_SHIFT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, info->phys);
info->mmap = mmap(0, npage << GPU_PAGE_SHIFT, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, info->phys);
if (info->mmap == MAP_FAILED) {
return errno;
}
Expand Down Expand Up @@ -159,7 +160,8 @@ void GpuMem::init(size_t bytes)
}

// Aligned address.
addr_ = (CUdeviceptr)(((uint64_t)raw_addr_ + GPU_PAGE_OFFSET) & GPU_PAGE_MASK);
addr_ =
(CUdeviceptr)(((uint64_t)raw_addr_ + GPU_PAGE_OFFSET) & GPU_PAGE_MASK);

ExposalInfo exp_info;
int err = mem_expose(&exp_info, addr_, bytes + GPU_PAGE_SIZE);
Expand Down Expand Up @@ -197,7 +199,8 @@ void GpuMem::init(const GpuMem::Info &info)
}

// Aligned address.
addr_ = (CUdeviceptr)(((uint64_t)raw_addr_ + GPU_PAGE_OFFSET) & GPU_PAGE_MASK);
addr_ =
(CUdeviceptr)(((uint64_t)raw_addr_ + GPU_PAGE_OFFSET) & GPU_PAGE_MASK);

mmap_ = map_pa_to_va(info.phys_addr, info.bytes);
if (mmap_ == nullptr) {
Expand Down

0 comments on commit 69858ba

Please sign in to comment.