Skip to content

Commit

Permalink
Continue pruning abseil usage: switch from absl::InlinedVector to std…
Browse files Browse the repository at this point in the history
…::vector. (#5302)

Also switched to using `IREE_ATTRIBUTE_NOINLINE` from `ABSL_ATTRIBUTE_NOINLINE`.

Generated via a pile of regex (code, includes, build deps) and manual cleanup until builds passed again.

* native modules needed some extra changes to work around calling `iree_hal_buffer_view_shape` with rank 0
  • Loading branch information
ScottTodd authored Apr 5, 2021
1 parent 71e24b6 commit ce0285f
Show file tree
Hide file tree
Showing 39 changed files with 236 additions and 234 deletions.
1 change: 0 additions & 1 deletion iree/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ cc_library(
srcs = ["signature_parser.cc"],
hdrs = ["signature_parser.h"],
deps = [
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
Expand Down
1 change: 0 additions & 1 deletion iree/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ iree_cc_library(
SRCS
"signature_parser.cc"
DEPS
absl::inlined_vector
absl::optional
absl::span
absl::strings
Expand Down
4 changes: 2 additions & 2 deletions iree/base/signature_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <cassert>
#include <map>
#include <string>
#include <vector>

#include "absl/container/inlined_vector.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "absl/types/span.h"
Expand Down Expand Up @@ -112,7 +112,7 @@ class SignatureParser {
// Parses function signatures generated by RawSignatureMangler.
class RawSignatureParser {
public:
using DimVector = absl::InlinedVector<int, 4>;
using DimVector = std::vector<int>;

enum class Type {
kBuffer = 0,
Expand Down
3 changes: 1 addition & 2 deletions iree/hal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ cc_library(
"//iree/base:threading",
"//iree/base:tracing",
"//iree/base/internal",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
"@half//:includes",
Expand All @@ -94,7 +93,7 @@ cc_test(
"//iree/base:status",
"//iree/testing:gtest",
"//iree/testing:gtest_main",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
],
)
3 changes: 1 addition & 2 deletions iree/hal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ iree_cc_library(
"string_util.cc"
"string_util.h"
DEPS
absl::inlined_vector
absl::span
absl::strings
half::includes
Expand All @@ -73,7 +72,7 @@ iree_cc_test(
"string_util_test.cc"
DEPS
::api
absl::inlined_vector
absl::span
absl::strings
iree::base::core_headers
iree::base::status
Expand Down
4 changes: 2 additions & 2 deletions iree/hal/buffer_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <cctype>
#include <cinttypes>
#include <cstdio>
#include <vector>

#include "absl/container/inlined_vector.h"
#include "absl/strings/ascii.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
Expand Down Expand Up @@ -75,7 +75,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_hal_buffer_view_parse(
}

// AxBxC...
absl::InlinedVector<iree_hal_dim_t, 6> shape(6);
std::vector<iree_hal_dim_t> shape(6);
iree_host_size_t shape_rank = 0;
iree_status_t shape_result =
iree_hal_parse_shape({shape_str.data(), shape_str.length()}, shape.size(),
Expand Down
4 changes: 2 additions & 2 deletions iree/hal/string_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <cctype>
#include <cinttypes>
#include <cstdio>
#include <vector>

#include "absl/container/inlined_vector.h"
#include "absl/strings/ascii.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
Expand All @@ -44,7 +44,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_hal_parse_shape(
return iree_ok_status(); // empty shape
}

absl::InlinedVector<iree_hal_dim_t, 6> dims;
std::vector<iree_hal_dim_t> dims;
for (auto dim_str : absl::StrSplit(str_value, 'x')) {
int dim_value = 0;
if (!absl::SimpleAtoi(dim_str, &dim_value)) {
Expand Down
6 changes: 4 additions & 2 deletions iree/hal/string_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/container/inlined_vector.h"
#include <vector>

#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "iree/base/status.h"
#include "iree/hal/api.h"
#include "iree/testing/gtest.h"
Expand All @@ -29,7 +31,7 @@ using ::testing::ElementsAre;
using ::testing::Eq;

// TODO(benvanik): move these utils to C++ bindings.
using Shape = absl::InlinedVector<iree_hal_dim_t, 6>;
using Shape = std::vector<iree_hal_dim_t>;

// Parses a serialized set of shape dimensions using the canonical shape format
// (the same as produced by FormatShape).
Expand Down
1 change: 0 additions & 1 deletion iree/hal/vulkan/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ cc_library(
"//iree/hal/vulkan/util:ref_ptr",
"//iree/schemas:spirv_executable_def_c_fbs",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
"@iree_vulkan_headers//:vulkan_headers",
Expand Down
1 change: 0 additions & 1 deletion iree/hal/vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ iree_cc_library(
::dynamic_symbols
Vulkan::Headers
absl::flat_hash_map
absl::inlined_vector
absl::span
absl::strings
iree::base::api
Expand Down
7 changes: 4 additions & 3 deletions iree/hal/vulkan/descriptor_pool_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#ifndef IREE_HAL_VULKAN_DESCRIPTOR_POOL_CACHE_H_
#define IREE_HAL_VULKAN_DESCRIPTOR_POOL_CACHE_H_

#include "absl/container/inlined_vector.h"
#include <vector>

#include "iree/hal/vulkan/dynamic_symbols.h"
#include "iree/hal/vulkan/handle_util.h"

Expand Down Expand Up @@ -43,7 +44,7 @@ class DescriptorSetGroup final {
public:
DescriptorSetGroup() = default;
DescriptorSetGroup(DescriptorPoolCache* descriptor_pool_cache,
absl::InlinedVector<DescriptorPool, 8> descriptor_pools)
std::vector<DescriptorPool> descriptor_pools)
: descriptor_pool_cache_(descriptor_pool_cache),
descriptor_pools_(std::move(descriptor_pools)) {}
DescriptorSetGroup(const DescriptorSetGroup&) = delete;
Expand All @@ -62,7 +63,7 @@ class DescriptorSetGroup final {

private:
DescriptorPoolCache* descriptor_pool_cache_;
absl::InlinedVector<DescriptorPool, 8> descriptor_pools_;
std::vector<DescriptorPool> descriptor_pools_;
};

// A "cache" (or really, pool) of descriptor pools. These pools are allocated
Expand Down
2 changes: 1 addition & 1 deletion iree/hal/vulkan/descriptor_set_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DescriptorSetArena final {
std::array<DescriptorPool, 4> descriptor_pool_buckets_;

// All pools that have been used during allocation.
absl::InlinedVector<DescriptorPool, 8> used_descriptor_pools_;
std::vector<DescriptorPool> used_descriptor_pools_;
};

} // namespace vulkan
Expand Down
19 changes: 8 additions & 11 deletions iree/hal/vulkan/direct_command_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

#include "iree/hal/vulkan/direct_command_buffer.h"

#include "absl/container/inlined_vector.h"
#include <vector>

#include "iree/base/internal/math.h"
#include "iree/base/tracing.h"
#include "iree/hal/vulkan/descriptor_set_arena.h"
Expand Down Expand Up @@ -270,8 +271,7 @@ static iree_status_t iree_hal_vulkan_direct_command_buffer_execution_barrier(
iree_hal_vulkan_direct_command_buffer_t* command_buffer =
iree_hal_vulkan_direct_command_buffer_cast(base_command_buffer);

absl::InlinedVector<VkMemoryBarrier, 8> memory_barrier_infos(
memory_barrier_count);
std::vector<VkMemoryBarrier> memory_barrier_infos(memory_barrier_count);
for (int i = 0; i < memory_barrier_count; ++i) {
const auto& memory_barrier = memory_barriers[i];
auto& info = memory_barrier_infos[i];
Expand All @@ -283,8 +283,7 @@ static iree_status_t iree_hal_vulkan_direct_command_buffer_execution_barrier(
iree_hal_vulkan_convert_access_mask(memory_barrier.target_scope);
}

absl::InlinedVector<VkBufferMemoryBarrier, 8> buffer_barrier_infos(
buffer_barrier_count);
std::vector<VkBufferMemoryBarrier> buffer_barrier_infos(buffer_barrier_count);
for (int i = 0; i < buffer_barrier_count; ++i) {
const auto& buffer_barrier = buffer_barriers[i];
auto& info = buffer_barrier_infos[i];
Expand Down Expand Up @@ -352,13 +351,12 @@ static iree_status_t iree_hal_vulkan_direct_command_buffer_wait_events(
iree_hal_vulkan_direct_command_buffer_t* command_buffer =
iree_hal_vulkan_direct_command_buffer_cast(base_command_buffer);

absl::InlinedVector<VkEvent, 4> event_handles(event_count);
std::vector<VkEvent> event_handles(event_count);
for (int i = 0; i < event_count; ++i) {
event_handles[i] = iree_hal_vulkan_native_event_handle(events[i]);
}

absl::InlinedVector<VkMemoryBarrier, 8> memory_barrier_infos(
memory_barrier_count);
std::vector<VkMemoryBarrier> memory_barrier_infos(memory_barrier_count);
for (int i = 0; i < memory_barrier_count; ++i) {
const auto& memory_barrier = memory_barriers[i];
auto& info = memory_barrier_infos[i];
Expand All @@ -370,8 +368,7 @@ static iree_status_t iree_hal_vulkan_direct_command_buffer_wait_events(
iree_hal_vulkan_convert_access_mask(memory_barrier.target_scope);
}

absl::InlinedVector<VkBufferMemoryBarrier, 8> buffer_barrier_infos(
buffer_barrier_count);
std::vector<VkBufferMemoryBarrier> buffer_barrier_infos(buffer_barrier_count);
for (int i = 0; i < buffer_barrier_count; ++i) {
const auto& buffer_barrier = buffer_barriers[i];
auto& info = buffer_barrier_infos[i];
Expand Down Expand Up @@ -542,7 +539,7 @@ static iree_status_t iree_hal_vulkan_direct_command_buffer_bind_descriptor_set(
iree_hal_vulkan_direct_command_buffer_cast(base_command_buffer);

// Vulkan takes uint32_t as the size here, unlike everywhere else.
absl::InlinedVector<uint32_t, 4> dynamic_offsets_i32(dynamic_offset_count);
std::vector<uint32_t> dynamic_offsets_i32(dynamic_offset_count);
for (int i = 0; i < dynamic_offset_count; ++i) {
dynamic_offsets_i32[i] = static_cast<uint32_t>(dynamic_offsets[i]);
}
Expand Down
13 changes: 7 additions & 6 deletions iree/hal/vulkan/emulated_semaphore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <inttypes.h>
#include <stdint.h>

#include "absl/container/inlined_vector.h"
#include <vector>

#include "iree/base/status.h"
#include "iree/base/synchronization.h"
#include "iree/base/tracing.h"
Expand Down Expand Up @@ -94,9 +95,9 @@ class EmulatedTimelineSemaphore final {
bool* out_reached_upper_value);
// Similar to the above, but also returns the fences that are known to have
// already signaled via |signaled_fences|.
iree_status_t TryToAdvanceTimeline(
uint64_t to_upper_value, bool* out_reached_upper_value,
absl::InlinedVector<VkFence, 4>* out_signaled_fences);
iree_status_t TryToAdvanceTimeline(uint64_t to_upper_value,
bool* out_reached_upper_value,
std::vector<VkFence>* out_signaled_fences);

std::atomic<uint64_t> signaled_value_;

Expand Down Expand Up @@ -344,7 +345,7 @@ iree_status_t EmulatedTimelineSemaphore::GetSignalSemaphore(

iree_status_t EmulatedTimelineSemaphore::TryToAdvanceTimeline(
uint64_t to_upper_value, bool* out_reached_upper_value) {
absl::InlinedVector<VkFence, 4> signaled_fences;
std::vector<VkFence> signaled_fences;
iree_status_t status = TryToAdvanceTimeline(
to_upper_value, out_reached_upper_value, &signaled_fences);
// Inform the queue that some fences are known to have signaled. This should
Expand All @@ -361,7 +362,7 @@ iree_status_t EmulatedTimelineSemaphore::TryToAdvanceTimeline(

iree_status_t EmulatedTimelineSemaphore::TryToAdvanceTimeline(
uint64_t to_upper_value, bool* out_reached_upper_value,
absl::InlinedVector<VkFence, 4>* out_signaled_fences) {
std::vector<VkFence>* out_signaled_fences) {
IREE_TRACE_SCOPE0("EmulatedTimelineSemaphore::TryToAdvanceTimeline");
IREE_DVLOG(3) << "EmulatedTimelineSemaphore::TryToAdvanceTimeline";
if (out_reached_upper_value) *out_reached_upper_value = false;
Expand Down
23 changes: 11 additions & 12 deletions iree/hal/vulkan/serializing_command_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ namespace {
// |wait_semaphores| and |signal_semaphores| will be filled with the binary
// `VkSemaphores` on success.
iree_status_t TryToPrepareSemaphores(
const absl::InlinedVector<SemaphoreValue, 4>& batch_wait_semaphores,
const absl::InlinedVector<SemaphoreValue, 4>& batch_signal_semaphores,
const std::vector<SemaphoreValue>& batch_wait_semaphores,
const std::vector<SemaphoreValue>& batch_signal_semaphores,
const ref_ptr<TimePointFence>& batch_fence,
absl::InlinedVector<VkSemaphore, 4>* wait_semaphores,
absl::InlinedVector<VkSemaphore, 4>* signal_semaphores,
bool* out_ready_to_submit) {
std::vector<VkSemaphore>* wait_semaphores,
std::vector<VkSemaphore>* signal_semaphores, bool* out_ready_to_submit) {
IREE_TRACE_SCOPE0("TryToPrepareSemaphores");
*out_ready_to_submit = false;

Expand Down Expand Up @@ -127,7 +126,7 @@ void PrepareSubmitInfo(absl::Span<const VkSemaphore> wait_semaphore_handles,
// args are mutated in-place after this function is called so we can't
// reference them here. If we were going to preserve this code post-Vulkan 1.2
// then we'd really want to rework all of this to properly use the arena from
// the start instead of all this InlinedVector tomfoolery.
// the start instead of all this span tomfoolery.
auto wait_semaphores =
arena->AllocateSpan<VkSemaphore>(wait_semaphore_handles.size());
for (size_t i = 0, e = wait_semaphore_handles.size(); i < e; ++i) {
Expand Down Expand Up @@ -237,14 +236,14 @@ iree_status_t SerializingCommandQueue::TryProcessDeferredSubmissions(
if (out_work_submitted) *out_work_submitted = false;

Arena arena(4 * 1024);
absl::InlinedVector<VkSubmitInfo, 4> submit_infos;
absl::InlinedVector<VkFence, 4> submit_fences;
std::vector<VkSubmitInfo> submit_infos;
std::vector<VkFence> submit_fences;
while (!deferred_submissions_.empty()) {
FencedSubmission* submission = deferred_submissions_.front();
ref_ptr<TimePointFence>& fence = submission->fence;

absl::InlinedVector<VkSemaphore, 4> wait_semaphores;
absl::InlinedVector<VkSemaphore, 4> signal_semaphores;
std::vector<VkSemaphore> wait_semaphores;
std::vector<VkSemaphore> signal_semaphores;
bool ready_to_submit = false;
IREE_RETURN_IF_ERROR(TryToPrepareSemaphores(
submission->wait_semaphores, submission->signal_semaphores, fence,
Expand Down Expand Up @@ -325,7 +324,7 @@ iree_status_t SerializingCommandQueue::WaitIdle(iree_time_t deadline_ns) {
do {
status = ProcessDeferredSubmissions();
bool has_deferred_submissions = !deferred_submissions_.empty();
absl::InlinedVector<VkFence, 8> fence_handles(pending_fences_.size());
std::vector<VkFence> fence_handles(pending_fences_.size());
for (size_t i = 0; i < pending_fences_.size(); ++i) {
fence_handles[i] = pending_fences_[i]->value();
}
Expand Down Expand Up @@ -389,7 +388,7 @@ void SerializingCommandQueue::AbortQueueSubmission() {
// yet so we don't need to reset.
deferred_submissions_.clear();

absl::InlinedVector<VkFence, 8> fence_handles(pending_fences_.size());
std::vector<VkFence> fence_handles(pending_fences_.size());
for (size_t i = 0; i < pending_fences_.size(); ++i) {
fence_handles[i] = pending_fences_[i]->value();
}
Expand Down
11 changes: 5 additions & 6 deletions iree/hal/vulkan/serializing_command_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <memory>
#include <string>
#include <vector>

#include "absl/container/inlined_vector.h"
#include "iree/base/status.h"
#include "iree/base/synchronization.h"
#include "iree/hal/api.h"
Expand Down Expand Up @@ -78,9 +78,9 @@ class SerializingCommandQueue final : public CommandQueue {
private:
// A submission batch together with the fence to singal its status.
struct FencedSubmission : public IntrusiveLinkBase<void> {
absl::InlinedVector<SemaphoreValue, 4> wait_semaphores;
absl::InlinedVector<VkCommandBuffer, 4> command_buffers;
absl::InlinedVector<SemaphoreValue, 4> signal_semaphores;
std::vector<SemaphoreValue> wait_semaphores;
std::vector<VkCommandBuffer> command_buffers;
std::vector<SemaphoreValue> signal_semaphores;
ref_ptr<TimePointFence> fence;
};

Expand All @@ -94,8 +94,7 @@ class SerializingCommandQueue final : public CommandQueue {
TimePointFencePool* fence_pool_;

// A list of fences that are submitted to GPU.
absl::InlinedVector<ref_ptr<TimePointFence>, 4> pending_fences_
IREE_GUARDED_BY(mutex_);
std::vector<ref_ptr<TimePointFence>> pending_fences_ IREE_GUARDED_BY(mutex_);
// A list of deferred submissions that haven't been submitted to GPU.
IntrusiveList<std::unique_ptr<FencedSubmission>> deferred_submissions_
IREE_GUARDED_BY(mutex_);
Expand Down
Loading

0 comments on commit ce0285f

Please sign in to comment.