Skip to content

Commit

Permalink
renamed Buffer, CircularBuffer, Profiler and related files and structs
Browse files Browse the repository at this point in the history
  • Loading branch information
RalphSteinhagen committed Oct 11, 2023
1 parent 8c54244 commit c4a44db
Show file tree
Hide file tree
Showing 27 changed files with 267 additions and 271 deletions.
22 changes: 11 additions & 11 deletions blocks/basic/include/gnuradio-4.0/basic/data_sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define GNURADIO_DATA_SINK_HPP

#include <gnuradio-4.0/Block.hpp>
#include <gnuradio-4.0/circular_buffer.hpp>
#include <gnuradio-4.0/CircularBuffer.hpp>
#include <gnuradio-4.0/dataset.hpp>
#include <gnuradio-4.0/history_buffer.hpp>
#include <gnuradio-4.0/HistoryBuffer.hpp>
#include <gnuradio-4.0/tag.hpp>

#include <any>
Expand Down Expand Up @@ -309,7 +309,7 @@ class data_sink : public Block<data_sink<T>> {
static constexpr std::size_t _listener_buffer_size = 65536;
std::deque<std::unique_ptr<abstract_listener>> _listeners;
std::mutex _listener_mutex;
std::optional<gr::history_buffer<T>> _history;
std::optional<gr::HistoryBuffer<T>> _history;
bool _has_signal_info_from_settings = false;

public:
Expand All @@ -323,10 +323,10 @@ class data_sink : public Block<data_sink<T>> {

struct poller {
// TODO consider whether reusing port<T> here makes sense
gr::circular_buffer<T> buffer = gr::circular_buffer<T>(_listener_buffer_size);
gr::CircularBuffer<T> buffer = gr::CircularBuffer<T>(_listener_buffer_size);
decltype(buffer.new_reader()) reader = buffer.new_reader();
decltype(buffer.new_writer()) writer = buffer.new_writer();
gr::circular_buffer<tag_t> tag_buffer = gr::circular_buffer<tag_t>(1024);
gr::CircularBuffer<tag_t> tag_buffer = gr::CircularBuffer<tag_t>(1024);
decltype(tag_buffer.new_reader()) tag_reader = tag_buffer.new_reader();
decltype(tag_buffer.new_writer()) tag_writer = tag_buffer.new_writer();
std::size_t samples_read = 0; // reader thread
Expand Down Expand Up @@ -363,12 +363,12 @@ class data_sink : public Block<data_sink<T>> {
};

struct dataset_poller {
gr::circular_buffer<DataSet<T>> buffer = gr::circular_buffer<DataSet<T>>(_listener_buffer_size);
decltype(buffer.new_reader()) reader = buffer.new_reader();
decltype(buffer.new_writer()) writer = buffer.new_writer();
gr::CircularBuffer<DataSet<T>> buffer = gr::CircularBuffer<DataSet<T>>(_listener_buffer_size);
decltype(buffer.new_reader()) reader = buffer.new_reader();
decltype(buffer.new_writer()) writer = buffer.new_writer();

std::atomic<bool> finished = false;
std::atomic<std::size_t> drop_count = 0;
std::atomic<bool> finished = false;
std::atomic<std::size_t> drop_count = 0;

[[nodiscard]] bool
process(std::invocable<std::span<DataSet<T>>> auto fnc) {
Expand Down Expand Up @@ -572,7 +572,7 @@ class data_sink : public Block<data_sink<T>> {

// transitional, do not reallocate/copy, but create a shared buffer with size N,
// and a per-listener history buffer where more than N samples is needed.
auto new_history = gr::history_buffer<T>(new_size);
auto new_history = gr::HistoryBuffer<T>(new_size);
if (_history) {
new_history.push_back_bulk(_history->begin(), _history->end());
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/basic/test/qa_data_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <fmt/ranges.h>

#include <gnuradio-4.0/Block.hpp>
#include <gnuradio-4.0/buffer.hpp>
#include <gnuradio-4.0/Buffer.hpp>
#include <gnuradio-4.0/Graph.hpp>
#include <gnuradio-4.0/reflection.hpp>
#include <gnuradio-4.0/Scheduler.hpp>
Expand Down
28 changes: 14 additions & 14 deletions blocks/filter/include/gnuradio-4.0/filter/time_domain_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <numeric>

#include <gnuradio-4.0/Block.hpp>
#include <gnuradio-4.0/history_buffer.hpp>
#include <gnuradio-4.0/HistoryBuffer.hpp>

namespace gr::filter {

Expand All @@ -17,15 +17,15 @@ struct fir_filter : Block<fir_filter<T>, Doc<R""(
The transfer function of an FIR filter is given by:
H(z) = b[0] + b[1]*z^-1 + b[2]*z^-2 + ... + b[N]*z^-N
)"">> {
PortIn<T> in;
PortOut<T> out;
std::vector<T> b{}; // feedforward coefficients
history_buffer<T> inputHistory{ 32 };
PortIn<T> in;
PortOut<T> out;
std::vector<T> b{}; // feedforward coefficients
HistoryBuffer<T> inputHistory{ 32 };

void
settings_changed(const property_map & /*old_settings*/, const property_map &new_settings) noexcept {
if (new_settings.contains("b") && b.size() >= inputHistory.capacity()) {
inputHistory = history_buffer<T>(std::bit_ceil(b.size()));
inputHistory = HistoryBuffer<T>(std::bit_ceil(b.size()));
}
}

Expand All @@ -51,19 +51,19 @@ struct iir_filter : Block<iir_filter<T, form>, Doc<R""(
b are the feed-forward coefficients (N.B. b[0] denoting the newest and b[-1] the previous sample)
a are the feedback coefficients
)"">> {
PortIn<T> in;
PortOut<T> out;
std::vector<T> b{ 1 }; // feed-forward coefficients
std::vector<T> a{ 1 }; // feedback coefficients
history_buffer<T> inputHistory{ 32 };
history_buffer<T> outputHistory{ 32 };
PortIn<T> in;
PortOut<T> out;
std::vector<T> b{ 1 }; // feed-forward coefficients
std::vector<T> a{ 1 }; // feedback coefficients
HistoryBuffer<T> inputHistory{ 32 };
HistoryBuffer<T> outputHistory{ 32 };

void
settings_changed(const property_map & /*old_settings*/, const property_map &new_settings) noexcept {
const auto new_size = std::max(a.size(), b.size());
if ((new_settings.contains("b") || new_settings.contains("a")) && (new_size >= inputHistory.capacity() || new_size >= inputHistory.capacity())) {
inputHistory = history_buffer<T>(std::bit_ceil(new_size));
outputHistory = history_buffer<T>(std::bit_ceil(new_size));
inputHistory = HistoryBuffer<T>(std::bit_ceil(new_size));
outputHistory = HistoryBuffer<T>(std::bit_ceil(new_size));
}
}

Expand Down
2 changes: 1 addition & 1 deletion blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <gnuradio-4.0/Block.hpp>
#include <gnuradio-4.0/dataset.hpp>
#include <gnuradio-4.0/history_buffer.hpp>
#include <gnuradio-4.0/HistoryBuffer.hpp>

#include <gnuradio-4.0/algorithm/fourier/fft.hpp>
#include <gnuradio-4.0/algorithm/fourier/fft_common.hpp>
Expand Down
8 changes: 4 additions & 4 deletions core/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ function (add_gr_benchmark BM_NAME)
target_link_libraries(${BM_NAME} PRIVATE gnuradio-core refl-cpp fmt gr-basic gr-testing)
endfunction()

add_gr_benchmark(bm_buffer)
add_gr_benchmark(bm_history_buffer)
add_gr_benchmark(bm_profiler)
add_gr_benchmark(bm_scheduler)
add_gr_benchmark(bm_Buffer)
add_gr_benchmark(bm_HistoryBuffer)
add_gr_benchmark(bm_Profiler)
add_gr_benchmark(bm_Scheduler)
add_gr_benchmark(bm_node_api)
add_gr_benchmark(bm_fft)
target_link_libraries(bm_fft PRIVATE gr-fourier)
Expand Down
10 changes: 5 additions & 5 deletions core/benchmarks/bm_buffer.cpp → core/benchmarks/bm_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <fmt/format.h>

#include <gnuradio-4.0/buffer.hpp> // new buffer header interface
#include <gnuradio-4.0/buffer_skeleton.hpp>
#include <gnuradio-4.0/circular_buffer.hpp>
#include <gnuradio-4.0/Buffer.hpp> // new buffer header interface
#include <gnuradio-4.0/BufferSkeleton.hpp>
#include <gnuradio-4.0/CircularBuffer.hpp>

#include <gnuradio-4.0/meta/utils.hpp>

Expand Down Expand Up @@ -149,11 +149,11 @@ inline const boost::ut::suite _buffer_tests = [] {
}
};
if (nP == 1) {
using BufferType = circular_buffer<int32_t, std::dynamic_extent, ProducerType::Single>;
using BufferType = CircularBuffer<int32_t, std::dynamic_extent, ProducerType::Single>;
Buffer auto buffer = is_posix ? BufferType(size) : BufferType(size, allocator);
invoke(buffer);
} else {
using BufferType = circular_buffer<int32_t, std::dynamic_extent, ProducerType::Multi>;
using BufferType = CircularBuffer<int32_t, std::dynamic_extent, ProducerType::Multi>;
Buffer auto buffer = is_posix ? BufferType(size) : BufferType(size, allocator);
invoke(buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <fmt/format.h>

#include <gnuradio-4.0/circular_buffer.hpp>
#include <gnuradio-4.0/history_buffer.hpp>
#include <gnuradio-4.0/CircularBuffer.hpp>
#include <gnuradio-4.0/HistoryBuffer.hpp>
#include <gnuradio-4.0/meta/utils.hpp>

inline const boost::ut::suite _buffer_tests = [] {
Expand All @@ -17,9 +17,9 @@ inline const boost::ut::suite _buffer_tests = [] {
using namespace gr;

{
circular_buffer<int, std::dynamic_extent, ProducerType::Multi> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();
CircularBuffer<int, std::dynamic_extent, ProducerType::Multi> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();

"circular_buffer<int>(32) - multiple producer"_benchmark.repeat<n_repetitions>(samples) = [&writer, &reader] {
static int counter = 0;
Expand All @@ -34,9 +34,9 @@ inline const boost::ut::suite _buffer_tests = [] {
};
}
{
circular_buffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();
CircularBuffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();

"circular_buffer<int>(32) - single producer via lambda"_benchmark.repeat<n_repetitions>(samples) = [&writer, &reader] {
static int counter = 0;
Expand All @@ -51,9 +51,9 @@ inline const boost::ut::suite _buffer_tests = [] {
};
}
{
circular_buffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();
CircularBuffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();

"circular_buffer<int>(32) - single producer via reserve"_benchmark.repeat<n_repetitions>(samples) = [&writer, &reader] {
static int counter = 0;
Expand All @@ -73,7 +73,7 @@ inline const boost::ut::suite _buffer_tests = [] {
* left intentionally some space to improve the circular_buffer<T> implementation here
*/
{
history_buffer<int> buffer(32);
HistoryBuffer<int> buffer(32);

"history_buffer<int>(32)"_benchmark.repeat<n_repetitions>(samples) = [&buffer] {
static int counter = 0;
Expand All @@ -87,7 +87,7 @@ inline const boost::ut::suite _buffer_tests = [] {
};
}
{
history_buffer<int> buffer(32);
HistoryBuffer<int> buffer(32);

"history_buffer<int, 32>"_benchmark.repeat<n_repetitions>(samples) = [&buffer] {
static int counter = 0;
Expand All @@ -102,9 +102,9 @@ inline const boost::ut::suite _buffer_tests = [] {
}

{
circular_buffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();
CircularBuffer<int> buffer(32);
auto writer = buffer.new_writer();
auto reader = buffer.new_reader();

"circular_buffer<int>(32) - no checks"_benchmark.repeat<n_repetitions>(samples) = [&writer, &reader] {
static int counter = 0;
Expand All @@ -119,7 +119,7 @@ inline const boost::ut::suite _buffer_tests = [] {
};
}
{
history_buffer<int, 32> buffer;
HistoryBuffer<int, 32> buffer;

"history_buffer<int, 32> - no checks"_benchmark.repeat<n_repetitions>(samples) = [&buffer] {
static int counter = 0;
Expand All @@ -131,7 +131,7 @@ inline const boost::ut::suite _buffer_tests = [] {
};
}
{
history_buffer<int> buffer(32);
HistoryBuffer<int> buffer(32);

"history_buffer<int>(32) - no checks"_benchmark.repeat<n_repetitions>(samples) = [&buffer] {
static int counter = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <benchmark.hpp>

#include <gnuradio-4.0/profiler.hpp>
#include <gnuradio-4.0/Profiler.hpp>

using namespace gr::profiling;

Expand All @@ -24,16 +24,16 @@ run_without_profiler() {
fmt::print("The sum of sums is {} and it took {}ms\n", r, std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
}

template<Profiler P>
template<ProfilerLike TProfiler>
inline void
run_with_profiler(P &p) {
run_with_profiler(TProfiler &p) {
const auto start = detail::clock::now();
auto &handler = p.for_this_thread();
auto &handler = p.forThisThread();

[[maybe_unused]] auto whole_calculation_event = handler.start_complete_event("whole_calculation");
[[maybe_unused]] auto whole_calculation_event = handler.startCompleteEvent("whole_calculation");
long long r = 0;
for (std::size_t i = 0; i < 1000; ++i) {
auto async_event = handler.start_async_event("iteration", {}, { { "arg1", 2 }, { "arg2", "hello" } });
auto async_event = handler.startAsyncEvent("iteration", {}, { { "arg1", 2 }, { "arg2", "hello" } });
for (std::size_t j = 0; j < 1000; ++j) {
std::vector<int> v(10000);
std::iota(v.begin(), v.end(), 1);
Expand All @@ -50,10 +50,10 @@ run_with_profiler(P &p) {
using namespace boost::ut;
using namespace benchmark;

profiler prof;
Profiler prof;
"default profiler"_benchmark.repeat<N_ITER>(N_SAMPLES) = [&p = prof] { run_with_profiler(p); };

null::profiler null_prof;
null::Profiler null_prof;
"null profiler"_benchmark.repeat<N_ITER>(N_SAMPLES) = [&p = null_prof] { run_with_profiler(p); };

"no profiler"_benchmark.repeat<N_ITER>(N_SAMPLES) = [] { run_without_profiler(); };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <benchmark.hpp>

#include <gnuradio-4.0/Graph.hpp>
#include <gnuradio-4.0/profiler.hpp>
#include <gnuradio-4.0/Profiler.hpp>
#include <gnuradio-4.0/Scheduler.hpp>

#include <gnuradio-4.0/testing/bm_test_helper.hpp>
Expand Down Expand Up @@ -139,7 +139,7 @@ exec_bm(auto &scheduler, const std::string &test_case) {
gr::scheduler::BreadthFirst<multiThreaded> sched4_mt(test_graph_bifurcated<float>(N_NODES), pool);
"bifurcated graph - BFS scheduler (multi-threaded)"_benchmark.repeat<N_ITER>(N_SAMPLES) = [&sched4_mt]() { exec_bm(sched4_mt, "bifurcated-graph BFS-sched (multi-threaded)"); };

gr::scheduler::BreadthFirst<multiThreaded, profiler> sched4_mt_prof(test_graph_bifurcated<float>(N_NODES), pool);
gr::scheduler::BreadthFirst<multiThreaded, Profiler> sched4_mt_prof(test_graph_bifurcated<float>(N_NODES), pool);
"bifurcated graph - BFS scheduler (multi-threaded) with profiling"_benchmark.repeat<N_ITER>(N_SAMPLES) = [&sched4_mt_prof]() {
exec_bm(sched4_mt_prof, "bifurcated-graph BFS-sched (multi-threaded) with profiling");
};
Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "BlockTraits.hpp"
#include "Port.hpp"
#include "sequence.hpp"
#include "Sequence.hpp"
#include "tag.hpp"
#include "thread/thread_pool.hpp"

Expand Down
File renamed without changes.
Loading

0 comments on commit c4a44db

Please sign in to comment.