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

Setting 8-bit or 16-bit precision for aff3ct library - Turbo FEC #17

Open
jdayana opened this issue Jul 8, 2021 · 0 comments
Open

Setting 8-bit or 16-bit precision for aff3ct library - Turbo FEC #17

jdayana opened this issue Jul 8, 2021 · 0 comments

Comments

@jdayana
Copy link

jdayana commented Jul 8, 2021

Hi,

I am interested in replicating the following command run by aff3ct.exe in a simple program that utilizes the aff3ct library (using the Factory module):

$ ./aff3ct-2.3.5.exe -p "8" --sim-type "BFER" -C "TURBO" -K "6144" -e "500" -m "0.0" -M "1.01" --enc-sub-std "LTE" --dec-sub-implem "VERY_FAST" --dec-sub-simd "INTER" -i "6"
# ----------------------------------------------------
# ---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----
# ----------------------------------------------------
# Parameters:
# * Simulation ------------------------------------
#    ** Type                   = BFER
#    ** Type of bits           = int8
#    ** Type of reals          = float32
#    ** Type of quant. reals   = int8
#    ** Date (UTC)             = 2021-07-08 04:00:32
#    ** Git version            = v2.3.5
#    ** Code type (C)          = TURBO
#    ** Noise range            = 0 -> 1 dB
#    ** Noise type (E)         = EBN0
#    ** Seed                   = 0
#    ** Statistics             = off
#    ** Debug mode             = off
#    ** Multi-threading (t)    = 8 thread(s)
#    ** Coset approach (c)     = no
#    ** Coded monitoring       = no
#    ** Bad frames tracking    = off
#    ** Bad frames replay      = off
#    ** Bit rate               = 0.333116 (512/1537)
#    ** Inter frame level      = 16
# * Source ----------------------------------------
#    ** Type                   = RAND
#    ** Implementation         = STD
#    ** Info. bits (K_info)    = 6144
# * Codec -----------------------------------------
#    ** Type                   = TURBO
#    ** Info. bits (K)         = 6144
#    ** Codeword size (N_cw)   = 18444
#    ** Frame size (N)         = 18444
#    ** Code rate              = 0.333116 (512/1537)
# * Encoder ---------------------------------------
#    ** Type                   = TURBO
#    ** Systematic             = yes
#    ** Tail length            = 12
#    Encoder --------------------------------------
#    ** Type                   = RSC
#    ** Systematic             = yes
#    ** Tail length            = 6
#    ** Buffered               = on
#    ** Standard               = LTE
#    ** Polynomials            = {013,015}
# * Decoder ---------------------------------------
#    ** Type (D)               = TURBO
#    ** Implementation         = FAST
#    ** Systematic             = yes
#    ** Num. of iterations (i) = 6
#    ** CRC start iteration    = 2
#    ** Enable json            = off
#    ** Self-corrected         = off
#    Scaling factor -------------------------------
#    ** Enabled                = no
#    Flip and check -------------------------------
#    ** Enabled                = no
#    Decoder --------------------------------------
#    ** Type (D)               = BCJR
#    ** Implementation         = VERY_FAST
#    ** Systematic             = yes
#    ** Standard               = LTE
#    ** Polynomials            = {013,015}
#    ** SIMD strategy          = INTER
#    ** Max type               = MAX
# * Interleaver -----------------------------------
#    ** Type                   = LTE
# * Modem -----------------------------------------
#    ** Type                   = BPSK
#    ** Implementation         = STD
#    ** Bits per symbol        = 1
#    ** Sigma square           = on
# * Channel ---------------------------------------
#    ** Type                   = AWGN
#    ** Implementation         = STD
#    ** Complex                = off
#    ** Add users              = off
# * Quantizer -------------------------------------
#    ** Type                   = POW2
#    ** Implementation         = STD
#    ** Fixed-point config.    = {6, 2}
# * Monitor ---------------------------------------
#    ** Lazy reduction         = off
#    ** Frame error count (e)  = 500
#    ** Compute mutual info    = no
# * Terminal --------------------------------------
#    ** Show Sigma             = off
#    ** Enabled                = yes
#    ** Frequency (ms)         = 500
#
# The simulation is running...
# -----------------------||-----------------------------------------------------------||-----------------------
#   Signal Noise Ratio   ||      Bit Error Rate (BER) and Frame Error Rate (FER)      ||   Global throughput
#          (SNR)         ||                                                           ||   and elapsed time
# -----------------------||-----------------------------------------------------------||-----------------------
# -----------|-----------||-----------|-----------|-----------|-----------|-----------||-----------|-----------
#      Es/N0 |     Eb/N0 ||       FRA |        BE |        FE |       BER |       FER ||   SIM_THR |     ET/RT
#       (dB) |      (dB) ||           |           |           |           |           ||    (Mb/s) |  (hhmmss)
# -----------|-----------||-----------|-----------|-----------|-----------|-----------||-----------|-----------
       -4.77 |      0.00 ||       720 |    906620 |       720 | 2.05e-001 | 1.00e+000 ||     8.875 |  00h00'00
       -4.67 |      0.10 ||       688 |    816473 |       688 | 1.93e-001 | 1.00e+000 ||    20.766 |  00h00'00
       -4.57 |      0.20 ||       720 |    784450 |       720 | 1.77e-001 | 1.00e+000 ||    21.590 |  00h00'00
       -4.47 |      0.30 ||       704 |    678355 |       704 | 1.57e-001 | 1.00e+000 ||    21.277 |  00h00'00
       -4.37 |      0.40 ||       704 |    533472 |       702 | 1.23e-001 | 9.97e-001 ||    21.333 |  00h00'00
       -4.27 |      0.50 ||       688 |    333837 |       648 | 7.90e-002 | 9.42e-001 ||    20.838 |  00h00'00
       -4.17 |      0.60 ||       944 |    183746 |       651 | 3.17e-002 | 6.90e-001 ||    22.556 |  00h00'00
       -4.07 |      0.70 ||      1776 |     76032 |       562 | 6.97e-003 | 3.16e-001 ||    23.045 |  00h00'00
       -3.97 |      0.80 ||      7856 |     32108 |       516 | 6.65e-004 | 6.57e-002 ||    24.401 |  00h00'01
       -3.87 |      0.90 ||     66064 |     12786 |       502 | 3.15e-005 | 7.60e-003 ||    24.497 |  00h00'16
       -3.77 |      1.00 ||    644176 |      3563 |       500 | 9.00e-007 | 7.76e-004 ||    24.366 |  00h02'42
# End of the simulation.

I am able to run my code for the 32-bit precision case as this is the default. It seems that there isn't any option to set the precision to the 8-bit and 16-bit case as I am not able to pass in the precision or quantizer parameters to the factory module. I have also tried changing the data type in the template but got prompted with an error when I execute the code. I would appreciate if I can receive some assistance regarding this matter.

As reference:

	char  arg0[] = "FactoryProject.exe";
	// Encoder parameters
	char  E1Name[] = "-K";
	char  E1Value[] = "6144";			// info bits
	char  E2Name[] = "--enc-sub-std";
	char  E2Value[] = "LTE";		// standard: CCSDS, LTE
	char  E3Name[] = "--enc-sub-type";
	char  E3Value[] = "RSC";		// encoder type: AZCW, COSET, NO, RSC, USER
	char  E4Name[] = "--enc-type";
	char  E4Value[] = "TURBO";
	// Decoder parameters
	char  D1Name[] = "--dec-implem";
	char  D1Value[] = "FAST";		// algo implementation: FAST, NAIVE, STD
	char  D2Name[] = "--dec-ite";
	char  D2Value[] = "6";			// no. of iterations
	char  D3Name[] = "--dec-sf-type";
	char  D3Value[] = "LTE";		// scaling factor: ADAPTIVE, ARRAY, CST, LTE, LTE_VEC
	char  D4Name[] = "--dec-sub-implem";
	char  D4Value[] = "VERY_FAST";		// algo implementation: FAST, GENERIC, NAIVE, STD, VERY_FAST
	char  D5Name[] = "--dec-sub-max";
	char  D5Value[] = "MAX";		// MAX implementation for the nodes: MAX, MAXL, MAXS
	char  D6Name[] = "--dec-sub-type";
	char  D6Value[] = "BCJR";		// decode algo: BCJR, CHASE, ML
	char  D7Name[] = "--dec-type";
	char  D7Value[] = "TURBO";		// decode algo: CHASE, ML, TURBO
	char  D8Name[] = "--dec-sub-simd";
	char  D8Value[] = "INTER";
	char  fName[] = "-F"; // noOfFrames
	char  fValue[] = "4";
	// precision
	char  P1Name[] = "-p";
	char  P1Value[] = "32";
	char  Q1Name[] = "--qnt-type";
	char  Q1Value[] = "POW2";
	char  Q2Name[] = "--qnt-bits";
	char  Q2Value[] = "6";
	char  Q3Name[] = "--qnt-dec";
	char  Q3Value[] = "2"; // 2 for 8-bit, 3 for 16-bit
	char* argList[] = { &arg0[0], &E1Name[0], &E1Value[0], &E2Name[0], &E2Value[0], &E3Name[0], &E3Value[0], &E4Name[0], &E4Value[0], &D1Name[0], &D1Value[0], &D2Name[0], &D2Value[0],
						&D3Name[0], &D3Value[0], &D4Name[0], &D4Value[0], &D5Name[0], &D5Value[0], &D6Name[0], &D6Value[0], &D7Name[0], &D7Value[0], 
						&D8Name[0], &D8Value[0],  // simd
						//&P1Name[0], &P1Value[0],  // precision
						//&Q1Name[0], &Q1Value[0], &Q2Name[0], &Q2Value[0], &Q3Name[0], &Q3Value[0],  // quantizer
						&fName[0], &fValue[0],      // number of frames
						NULL };

	const int n_frames = 4;

	const int   K = 6144;				// number of information bits
	const int   N = K * 3 + 12;		// codeword size
	int   seed = static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count());	// PRNG seed for the AWGN channel
	float ebn0_min = 1.0f;				// minimum SNR value
	float ebn0_max = 1.01f;				// maximum SNR value
	float ebn0_step = 1.0f;				// SNR step
	float R = (float)K / (float)N;		// code rate (R=K/N)

	std::vector<tB>	ref_bits = std::vector<tB>(K * n_frames);
	std::vector<tB>	enc_bits = std::vector<tB>(N * n_frames);
	std::vector<tR>	symbols = std::vector<tR>(N * n_frames);
	std::vector<tR>	noisy_symbols = std::vector<tR>(N * n_frames);
	std::vector<tR>	LLRs = std::vector<tR>(N * n_frames);
	std::vector<tB>	dec_bits = std::vector<tB>(K * n_frames);

	std::unique_ptr<module::Source_random<tB>>		source;		// template <typename B = int>
	std::unique_ptr<module::Modem_BPSK<tB, tR, tR>>	modem;		// template <typename B = int, typename R = float, typename Q = R>
	std::unique_ptr<module::Channel_AWGN_LLR<tR>>	channel;	// template <typename R = float>

	std::unique_ptr<tools::Sigma<tR>>               noise;     // a sigma noise type		// template <typename R = float>
	// create a sigma noise type
	noise = std::unique_ptr<tools::Sigma<>>(new tools::Sigma<float>());

	source = std::unique_ptr<module::Source_random          <tB>>(new module::Source_random			<tB>(K, 0, n_frames));
	modem = std::unique_ptr<module::Modem_BPSK              <tB, tR, tR>>(new module::Modem_BPSK	<tB, tR, tR>(N, *noise, false, n_frames));
	channel = std::unique_ptr<module::Channel_AWGN_LLR      <tR>>(new module::Channel_AWGN_LLR		<tR>(N, seed, false, *noise, n_frames));

	std::unique_ptr<factory::Codec_turbo::parameters> p_codec;
	p_codec = std::unique_ptr<factory::Codec_turbo::parameters>(new factory::Codec_turbo::parameters());

	auto p_launcher = std::unique_ptr<factory::Launcher::parameters>(new factory::Launcher::parameters());

	std::vector<factory::Factory::parameters*> params_list = { p_codec.get() };
	int   noOfArgs = (int)(sizeof(argList) / sizeof(argList[0])) - 1;
	factory::Command_parser cp(noOfArgs, argList, params_list, true);
	if (cp.parsing_failed())
	{
		cp.print_help();
		cp.print_warnings();
		cp.print_errors();
		std::exit(1);
	}

	std::unique_ptr<module::Codec_SIHO<tB, tR>>   m_codec;		// template <typename B = int, typename Q = float>
	m_codec = std::unique_ptr<module::Codec_SIHO  <tB, tR>>(p_codec->build<tB, tR>());
	module::Encoder<tB>* encoder;		// template <typename B = int>
	module::Decoder_SIHO<tB, tR>* decoder;		// template <typename B = int, typename R = float>
	encoder = m_codec->get_encoder().get();			// template <typename B, typename Q> std::unique_ptr<Encoder<B>>& Codec<B, Q>::get_encoder()
	decoder = m_codec->get_decoder_siho().get();	//template <typename B, typename Q> const std::shared_ptr<Decoder_SIHO<B, Q>>& Codec_SIHO<B, Q>::get_decoder_siho()
	auto& interleaver = m_codec->get_interleaver();
	interleaver->init();

	R = (float)p_codec->enc->K / (float)p_codec->enc->N_cw; // compute the code rate

	// get the AFF3CT version
	const std::string v = "v" + std::to_string(tools::version_major()) + "." +
		std::to_string(tools::version_minor()) + "." +
		std::to_string(tools::version_release());

	std::cout << "#----------------------------------------------------------" << std::endl;
	std::cout << "# This is a basic program using the AFF3CT library (" << v << ")" << std::endl;
	std::cout << "# Feel free to improve it as you want to fit your needs." << std::endl;
	std::cout << "#----------------------------------------------------------" << std::endl;
	std::cout << "#" << std::endl;

	std::cout << "# Simulation parameters: " << std::endl;
	factory::Header::print_parameters(params_list); // display the headers (= print the AFF3CT parameters on the screen)
	std::cout << "#" << std::endl;
	cp.print_warnings();

	// loop over the various SNRs
	for (auto ebn0 = ebn0_min; ebn0 < ebn0_max; ebn0 += ebn0_step)
	{
		int num_errors_ttl = 0;

		// compute the current sigma for the channel noise
		const auto esn0 = tools::ebn0_to_esn0(ebn0, R);
		const auto sigma = tools::esn0_to_sigma(esn0);

		noise->set_noise(sigma, ebn0, esn0);

		// update the sigma of the modem and the channel
		modem->set_noise(*noise);
		channel->set_noise(*noise);

		source->generate(ref_bits);
		encoder->encode(ref_bits, enc_bits);
		modem->modulate(enc_bits, symbols);
		channel->add_noise(symbols, noisy_symbols);
		modem->demodulate(noisy_symbols, LLRs);
		decoder->decode_siho(LLRs, dec_bits);

	}

	std::cout << "# End of the simulation" << std::endl;

Also:

aff3ct (Windows 64-bit, g++-6.2, SSE4.1) v2.3.5
Compilation options:
  - Precision:         8/16/32/64-bit
  - Polar bit packing: on
  - Polar bounds:      off
  - Terminal colors:   on
  - Backtrace:         off
  - External strings:  on
  - MPI:               off
  - GSL:               off
  - MKL:               off
  - SystemC:           off
Copyright (c) 2016-2019 - MIT license.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I hope to hear back from you.

Thanks,
Dayana

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant