Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Use new kodo-rlnc
Browse files Browse the repository at this point in the history
  • Loading branch information
petya2164 committed Jun 21, 2018
1 parent 2896b5d commit 3dbd670
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 137 deletions.
85 changes: 33 additions & 52 deletions butterfly/butterfly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
#include <ctime>
#include <string>

#include "../simulator/simulator.hpp"

#include <gauge/gauge.hpp>
#include <gauge/python_printer.hpp>
#include <gauge/console_printer.hpp>
#include <gauge/csv_printer.hpp>

#include <boost/random/mersenne_twister.hpp>

#include <kodo_rlnc/full_vector_codes.hpp>
#include <fifi/api/field.hpp>

#include <kodo_rlnc/coders.hpp>

#include "../simulator/simulator.hpp"

// Helper function to convert to string
template<class T>
Expand All @@ -26,16 +28,6 @@ std::string to_string(T t)
return ss.str();
}

// The encoders and decoders that we use from the Kodo library
typedef kodo_rlnc::full_vector_encoder<fifi::binary> Encoder;
typedef kodo_rlnc::full_vector_decoder<fifi::binary> Decoder;

typedef kodo_rlnc::full_vector_encoder<fifi::binary8> Encoder8;
typedef kodo_rlnc::full_vector_decoder<fifi::binary8> Decoder8;

typedef kodo_rlnc::full_vector_encoder<fifi::binary16> Encoder16;
typedef kodo_rlnc::full_vector_decoder<fifi::binary16> Decoder16;

// The simple butterfly simulation for the following topology:
// +--------+
// +------+ source +------+
Expand Down Expand Up @@ -65,12 +57,17 @@ typedef kodo_rlnc::full_vector_decoder<fifi::binary16> Decoder16;
//
// The simulator uses the gauge benchmarking tool for
// driving and providing options to the simulations.
template<class Encoder, class Decoder>
template
<
fifi::api::field Field,
class Encoder,
class Decoder
>
class butterfly : public gauge::benchmark
{
public:

using factory_type = basic_factory<Encoder,Decoder>;
using factory_type = basic_factory<Encoder, Decoder>;

public:

Expand Down Expand Up @@ -191,11 +188,9 @@ class butterfly : public gauge::benchmark
/// configurations.
void get_options(gauge::po::variables_map& options)
{
auto symbols =
options["symbols"].as<uint32_t>();
auto symbols = options["symbols"].as<uint32_t>();

auto symbol_size =
options["symbol_size"].as<uint32_t>();
auto symbol_size = options["symbol_size"].as<uint32_t>();

auto recode = options["recode"].as<bool>();

Expand All @@ -207,8 +202,7 @@ class butterfly : public gauge::benchmark
add_configuration(cs);

m_factory = std::make_shared<factory_type>(
symbols, symbol_size, m_generator);

Field, symbols, symbol_size, m_generator);
}

protected:
Expand All @@ -220,7 +214,6 @@ class butterfly : public gauge::benchmark
std::shared_ptr<tick_scheduler> m_scheduler;

std::shared_ptr<factory_type> m_factory;

};

BENCHMARK_OPTION(butterfly)
Expand All @@ -239,52 +232,40 @@ BENCHMARK_OPTION(butterfly)
("recode", gauge::po::value<bool>()->default_value(true),
"Set true if the relay(s) should recode packets");


gauge::runner::instance().register_options(options);
}

typedef butterfly<Encoder, Decoder> butterfly_fixture;
using butterfly_fixture = butterfly<
fifi::api::field::binary,
kodo_rlnc::encoder,
kodo_rlnc::decoder>;

BENCHMARK_F_INLINE(butterfly_fixture, Butterfly, binary, 10)
{
RUN
{

while (!(m_s1->is_complete() && m_s2->is_complete()))
{
m_scheduler->tick();
}

}
}

// typedef butterfly_simulation<Encoder8, Decoder8> butterfly_fixture8;

// BENCHMARK_F_INLINE(butterfly_fixture8, Butterfly, binary8, 10)
// {
// RUN{
using butterfly_fixture8 = butterfly<
fifi::api::field::binary8,
kodo_rlnc::encoder,
kodo_rlnc::decoder>;

// while(!m_sink->is_complete())
// {
// m_scheduler->tick();
// }

// }
// }

// typedef butterfly_simulation<Encoder16, Decoder16> butterfly_fixture16;

// BENCHMARK_F_INLINE(butterfly_fixture16, Butterfly, binary16, 10)
// {
// RUN{

// while(!m_sink->is_complete())
// {
// m_scheduler->tick();
// }

// }
// }
BENCHMARK_F_INLINE(butterfly_fixture8, Butterfly, binary8, 10)
{
RUN
{
while (!(m_s1->is_complete() && m_s2->is_complete()))
{
m_scheduler->tick();
}
}
}

int main(int argc, const char* argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion butterfly/wscript_build
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bld.program(
source=['butterfly.cpp'],
target='butterfly',
includes='..',
use=['kodo_rlnc_includes', 'gauge'])
use=['kodo_rlnc', 'gauge'])
60 changes: 21 additions & 39 deletions relay_simulations/relay_simulations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
#include <ctime>
#include <string>

#include "../simulator/simulator.hpp"

#include <gauge/gauge.hpp>
#include <gauge/python_printer.hpp>
#include <gauge/console_printer.hpp>
#include <gauge/csv_printer.hpp>

#include <kodo_rlnc/full_vector_codes.hpp>
#include <fifi/api/field.hpp>

#include <kodo_rlnc/coders.hpp>

#include "../simulator/simulator.hpp"

// Helper function to convert to string
template<class T>
Expand All @@ -24,16 +26,6 @@ std::string to_string(T t)
return ss.str();
}

// The encoders and decoders that we use from the Kodo library
typedef kodo_rlnc::full_vector_encoder<fifi::binary> Encoder;
typedef kodo_rlnc::full_vector_decoder<fifi::binary> Decoder;

typedef kodo_rlnc::full_vector_encoder<fifi::binary8> Encoder8;
typedef kodo_rlnc::full_vector_decoder<fifi::binary8> Decoder8;

typedef kodo_rlnc::full_vector_encoder<fifi::binary16> Encoder16;
typedef kodo_rlnc::full_vector_decoder<fifi::binary16> Decoder16;

// The simple relay simulation for the following topology:
//
// .------------------------------------.
Expand All @@ -55,12 +47,17 @@ typedef kodo_rlnc::full_vector_decoder<fifi::binary16> Decoder16;
//
// The simulator uses the gauge benchmarking tool for
// driving and providing options to the simulations.
template<class Encoder, class Decoder>
template
<
fifi::api::field Field,
class Encoder,
class Decoder
>
class relay_simulation : public gauge::benchmark
{
public:

typedef basic_factory<Encoder,Decoder> factory_type;
using factory_type = basic_factory<Encoder, Decoder>;

public:

Expand Down Expand Up @@ -210,8 +207,7 @@ class relay_simulation : public gauge::benchmark
add_configuration(cs);

m_factory = std::make_shared<factory_type>(
symbols, symbol_size, m_generator);

Field, symbols, symbol_size, m_generator);
}

protected:
Expand Down Expand Up @@ -293,52 +289,38 @@ BENCHMARK_OPTION(relay_line)
("recode", default_recode,
"Set true if the relay(s) should recode packets");


gauge::runner::instance().register_options(options);
}

typedef relay_simulation<Encoder, Decoder> relay_fixture;
using relay_fixture = relay_simulation<
fifi::api::field::binary,
kodo_rlnc::encoder,
kodo_rlnc::decoder>;

BENCHMARK_F_INLINE(relay_fixture, Relay, binary, 10)
{
RUN
{

while (!m_sink->is_complete())
{
m_scheduler->tick();
}

}
}

typedef relay_simulation<Encoder8, Decoder8> relay_fixture8;
using relay_fixture8 = relay_simulation<
fifi::api::field::binary8,
kodo_rlnc::encoder,
kodo_rlnc::decoder>;

BENCHMARK_F_INLINE(relay_fixture8, Relay, binary8, 10)
{
RUN
{

while (!m_sink->is_complete())
{
m_scheduler->tick();
}

}
}

typedef relay_simulation<Encoder16, Decoder16> relay_fixture16;

BENCHMARK_F_INLINE(relay_fixture16, Relay, binary16, 10)
{
RUN
{

while (!m_sink->is_complete())
{
m_scheduler->tick();
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion relay_simulations/wscript_build
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bld.program(
source=['relay_simulations.cpp'],
target='relay_simulations',
includes='..',
use=['kodo_rlnc_includes', 'gauge'])
use=['kodo_rlnc', 'gauge'])
22 changes: 6 additions & 16 deletions simulator/basic_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#pragma once

#include <fifi/api/field.hpp>

/// Helper class which makes it a bit more convenient to build
/// the elements of a basic simulation
Expand All @@ -13,19 +14,13 @@ class basic_factory
{
public:

basic_factory(uint32_t symbols, uint32_t symbol_size,
boost::random::mt19937& random_generator) :
m_decoder_factory(symbols, symbol_size),
m_encoder_factory(symbols, symbol_size),
basic_factory(
fifi::api::field field, uint32_t symbols, uint32_t symbol_size,
boost::random::mt19937& random_generator) :
m_decoder_factory(field, symbols, symbol_size),
m_encoder_factory(field, symbols, symbol_size),
m_random_generator(random_generator)
{
uint32_t max_block_size =
m_encoder_factory.max_block_size();

m_data.resize(max_block_size);

for (auto& d : m_data)
d = rand() % 256;
}

std::shared_ptr<basic_channel>
Expand Down Expand Up @@ -62,8 +57,6 @@ class basic_factory
build_source(const std::string& id)
{
auto encoder = m_encoder_factory.build();
encoder->set_const_symbols(storage::storage(m_data));

auto source = std::make_shared< basic_source<Encoder> >(id, encoder);

return source;
Expand Down Expand Up @@ -91,9 +84,6 @@ class basic_factory
/// Factory for building encoders
typename Encoder::factory m_encoder_factory;

/// Data for the encoders
std::vector<uint8_t> m_data;

/// The random generator
boost::random::mt19937& m_random_generator;
};
Loading

0 comments on commit 3dbd670

Please sign in to comment.