Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix function name and code comments errors #219

Merged
merged 11 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sxt/base/device/pinned_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace sxt::basdv {
//--------------------------------------------------------------------------------------------------
// consructor
//--------------------------------------------------------------------------------------------------
pinned_buffer::pinned_buffer() noexcept : handle_{get_pinned_buffer_pool()->aquire_handle()} {}
pinned_buffer::pinned_buffer() noexcept : handle_{get_pinned_buffer_pool()->acquire_handle()} {}

pinned_buffer::pinned_buffer(pinned_buffer&& ptr) noexcept : handle_{ptr.handle_} {
ptr.handle_ = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion sxt/base/device/pinned_buffer.t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST_CASE("we can manage pinned buffers") {
auto num_buffers = 5u;
auto pool = get_pinned_buffer_pool(num_buffers);

SECTION("we can aquire and release a pinned buffer") {
SECTION("we can acquire and release a pinned buffer") {
{
pinned_buffer buf;
REQUIRE(pool->size() == num_buffers - 1);
Expand Down
4 changes: 2 additions & 2 deletions sxt/base/device/pinned_buffer_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ pinned_buffer_pool::~pinned_buffer_pool() noexcept {
}

//--------------------------------------------------------------------------------------------------
// aquire_handle
// acquire_handle
//--------------------------------------------------------------------------------------------------
pinned_buffer_handle* pinned_buffer_pool::aquire_handle() noexcept {
pinned_buffer_handle* pinned_buffer_pool::acquire_handle() noexcept {
if (head_ == nullptr) {
head_ = new_handle();
}
Expand Down
2 changes: 1 addition & 1 deletion sxt/base/device/pinned_buffer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class pinned_buffer_pool {
pinned_buffer_pool(pinned_buffer_pool&&) = delete;
pinned_buffer_pool& operator=(const pinned_buffer_pool&) = delete;

pinned_buffer_handle* aquire_handle() noexcept;
pinned_buffer_handle* acquire_handle() noexcept;

void release_handle(pinned_buffer_handle* handle) noexcept;

Expand Down
8 changes: 4 additions & 4 deletions sxt/base/device/pinned_buffer_pool.t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ TEST_CASE("we can pool pinned buffers") {
pinned_buffer_pool pool{num_buffers};
REQUIRE(pool.size() == num_buffers);

SECTION("we can aquire and release buffers") {
auto h = pool.aquire_handle();
SECTION("we can acquire and release buffers") {
auto h = pool.acquire_handle();
REQUIRE(pool.size() == num_buffers - 1);
pool.release_handle(h);
REQUIRE(pool.size() == num_buffers);
}

SECTION("we can aquire a handle from an empty pool") {
SECTION("we can acquire a handle from an empty pool") {
pinned_buffer_pool empty_pool{0};
auto h = empty_pool.aquire_handle();
auto h = empty_pool.acquire_handle();
empty_pool.release_handle(h);
REQUIRE(empty_pool.size() == 1);
}
Expand Down
2 changes: 1 addition & 1 deletion sxt/base/device/stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace sxt::basdv {
//--------------------------------------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------------------------------------
stream::stream(int device) noexcept { handle_ = get_stream_pool()->aquire_handle(device); }
stream::stream(int device) noexcept { handle_ = get_stream_pool()->acquire_handle(device); }

stream::stream(stream&& other) noexcept { handle_ = other.release_handle(); }

Expand Down
4 changes: 2 additions & 2 deletions sxt/base/device/stream_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ stream_pool::~stream_pool() noexcept {
}

//--------------------------------------------------------------------------------------------------
// aquire_handle
// acquire_handle
//--------------------------------------------------------------------------------------------------
stream_handle* stream_pool::aquire_handle(int device) noexcept {
stream_handle* stream_pool::acquire_handle(int device) noexcept {
auto& head = heads_[device];
if (head == nullptr) {
return make_stream_handle(device);
Expand Down
4 changes: 2 additions & 2 deletions sxt/base/device/stream_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct stream_handle;
/**
* Pool of CUDA streams.
*
* This allows us to cheaply aquire streams without having to continually pay the cost
* This allows us to cheaply acquire streams without having to continually pay the cost
* of recreation. See https://stackoverflow.com/a/52934292 for reasons of why this is worthwhile.
*
* Similar to https://seastar.io/ this assumes that the application is sharded and access
Expand All @@ -46,7 +46,7 @@ class stream_pool {
stream_pool(stream_pool&&) = delete;
stream_pool& operator=(const stream_pool&) = delete;

stream_handle* aquire_handle(int device = 0) noexcept;
stream_handle* acquire_handle(int device = 0) noexcept;

void release_handle(stream_handle* handle) noexcept;

Expand Down
14 changes: 7 additions & 7 deletions sxt/base/device/stream_pool.t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ TEST_CASE("we can pool cuda streams for reuse") {
return;
}

SECTION("if we aquire a stream handle it is non-null") {
SECTION("if we acquire a stream handle it is non-null") {
stream_pool pool{1};
auto handle = pool.aquire_handle();
auto handle = pool.acquire_handle();
REQUIRE(handle != nullptr);
REQUIRE(handle->stream != nullptr);
REQUIRE(handle->next == nullptr);
Expand All @@ -39,26 +39,26 @@ TEST_CASE("we can pool cuda streams for reuse") {

SECTION("stream handles are reused") {
stream_pool pool{1};
auto handle = pool.aquire_handle();
auto handle = pool.acquire_handle();
pool.release_handle(handle);
auto handle_p = pool.aquire_handle();
auto handle_p = pool.acquire_handle();
REQUIRE(handle == handle_p);
pool.release_handle(handle_p);
}

SECTION("new handles are made if none are available") {
stream_pool pool{0};
auto handle = pool.aquire_handle();
auto handle = pool.acquire_handle();
REQUIRE(handle != nullptr);
pool.release_handle(handle);
auto handle_p = pool.aquire_handle();
auto handle_p = pool.acquire_handle();
REQUIRE(handle == handle_p);
pool.release_handle(handle_p);
}

SECTION("we can acquire handles from a thread-local pool") {
auto pool = get_stream_pool();
auto handle = pool->aquire_handle();
auto handle = pool->acquire_handle();
REQUIRE(handle != nullptr);
REQUIRE(handle->stream != nullptr);
REQUIRE(handle->next == nullptr);
Expand Down
2 changes: 1 addition & 1 deletion sxt/execution/device/computation_handle.t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST_CASE("computation_handle manages a collection of streams") {
computation_handle comp;
comp.add_stream(std::move(s));
}
auto handle = pool->aquire_handle();
auto handle = pool->acquire_handle();
REQUIRE(handle->stream == ptr);
pool->release_handle(handle);
}
Expand Down