Commit 7359d562 authored by Sydney Hauke's avatar Sydney Hauke

Merge branch 'awgn_without_mkl' into 'master'

Remove dependency to MKL library

See merge request !1
parents 420f5256 71712683
......@@ -7,7 +7,6 @@ cmake_policy(SET CMP0012 NEW)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
find_package(OpenMP REQUIRED)
find_package(MKL REQUIRED)
find_package (Threads REQUIRED)
find_package(ldpc-dvbs2-decoder REQUIRED)
......@@ -18,10 +17,10 @@ set(CodeRateValues
set_property(CACHE CodeRate PROPERTY STRINGS ${CodeRateValues})
message(STATUS "CodeRate=${CodeRate}")
set(CMAKE_CXX_FLAGS "-g -W -Wall -O3")
set(CMAKE_CXX_FLAGS "-g -std=c++11 -W -Wall -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finline -funroll-loops")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -opt-prefetch -unroll-aggressive")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -DMKL_ILP64 -msse4a -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse4a -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
......@@ -29,7 +28,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}
set(_sources
src/CBitGenerator/CBitGenerator.cpp
src/CChanel/CChanel.cpp
src/CChanel/CChanelAWGN_MKL.cpp
src/CChanel/CChanelAWGN.cpp
src/CDecoder/template/CDecoder.cpp
src/CDecoder/template/CDecoder_fixed.cpp
src/CDecoder/template/CDecoder_fixed_SSE.cpp
......@@ -60,14 +59,11 @@ set(_sources
add_executable(main.icc ${_sources})
target_include_directories(main.icc PRIVATE src ${MKL_INCLUDE_DIRS})
target_include_directories(main.icc PRIVATE src)
target_compile_definitions(main.icc PRIVATE "-D${CodeRate}")
target_link_libraries(main.icc PUBLIC
"-Wl,--start-group"
${MKL_LIBRARIES}
"-Wl,--end-group"
gomp
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
......
......@@ -14,17 +14,10 @@ Originally, this source code piece is part of a much larger project
that enables us to experiment LDPC decoding algorithm, data format, etc.
It explains why some piece of code are useless for you ;-)
In order to compile the LDPC decoder, you currently have to use Intel C++
compiler. Indeed, the ANWG channel model is implemented using the MKL library
function.
Source code compilation:
########################
Please ensure that the MKL Library and OpenMP are installed.
Export the MKL library path:
`export MKL_ROOT=<path_to_intel_SDK>/compilers_and_libraries_2019.2.187/linux/mkl`
Please ensure that OpenMP is installed.
```
mkdir build
......
......@@ -18,12 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CChanelAWGN_MKL.h"
#ifndef VSL_METHOD_SGAUSSIAN_BOXMULLER2
#define VSL_METHOD_SGAUSSIAN_BOXMULLER2 1
#endif
#include "CChanelAWGN.h"
//
// RACINE CARREE SSE OPTIMISEE A L'AIDE DE LA FONCTION
......@@ -34,7 +29,7 @@
// return _mm256_mul_ps( a, _mm256_rsqrt_ps( a ) );
//}
double CChanelAWGN_MKL::inv_erf(int v){
double CChanelAWGN::inv_erf(int v){
if (v == 3) {
return 0.86312;
}else if(v == 4){
......@@ -55,7 +50,7 @@ double CChanelAWGN_MKL::inv_erf(int v){
return -1;
}
double CChanelAWGN_MKL::get_R(){
double CChanelAWGN::get_R(){
return R;
}
......@@ -75,24 +70,15 @@ double CChanelAWGN_MKL::get_R(){
static int thread_id = 0;
CChanelAWGN_MKL::CChanelAWGN_MKL(CTrame *t, int _BITS_LLR, bool QPSK, bool Es_N0)
CChanelAWGN::CChanelAWGN(CTrame *t, int _BITS_LLR, bool QPSK, bool Es_N0)
: CChanel(t, _BITS_LLR, QPSK, Es_N0){
int status = vslNewStream( &stream, VSL_BRNG_MT2203 + thread_id++ /*VSL_BRNG_MT2203*/, rand() );
if( status != VSL_STATUS_OK ){
printf("(EE) Error during vslNewStream execution\n");
printf("(EE) thread_id = %d\n", thread_id);
exit( 0 );
}
noise = (float*)new __m128[_frames * _data / 4];
}
CChanelAWGN_MKL::~CChanelAWGN_MKL(){
vslDeleteStream( &stream );
delete noise;
CChanelAWGN::~CChanelAWGN(){
thread_id--;
}
void CChanelAWGN_MKL::configure(double _Eb_N0){
void CChanelAWGN::configure(double _Eb_N0){
rendement = (float) (_vars) / (float) (_data);
if (es_n0) {
......@@ -125,18 +111,22 @@ void CChanelAWGN_MKL::configure(double _Eb_N0){
#define QPSK 0.707106781
#define BPSK 1.0
void CChanelAWGN_MKL::generate() {
void CChanelAWGN::generate() {
std::random_device rd{};
std::mt19937 gen{rd()};
std::normal_distribution<> nd{0.0f, SigB};
float pv = (qpsk) ? QPSK : BPSK; // ON CHOISIT LE TYPE DE CODAGE DU SIGNAL
float mv = (qpsk) ? -QPSK : -BPSK; // BPSK OU QPSK (CODAGES LES + SIMPLES)
int nbData = (_frames*_data);
vsRngGaussian( VSL_METHOD_SGAUSSIAN_BOXMULLER2, stream, nbData, (float*)noise, 0.0f, SigB );
//
// ON LAISSE ICC DEROULER LA BOUCLE AINSI C'EST SSE ET AVX COMPATIBLE (4 TIBO)
//
for (int z = 0; z < _frames*_data; z++) {
float y = (t_coded_bits[z] == 1 ? pv : mv) + noise[z];
for (int z = 0; z < nbData; z++) {
float y = (t_coded_bits[z] == 1 ? pv : mv) + nd(gen);
t_noise_data[z] = y * norm_factor;
}
......
......@@ -18,32 +18,31 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLASS_CChanelAWGN_MKL
#define CLASS_CChanelAWGN_MKL
#ifndef CLASS_CChanelAWGN
#define CLASS_CChanelAWGN
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <random>
#include <cmath>
#include "CChanel.h"
#include <xmmintrin.h>
#include <tmmintrin.h>
#include <smmintrin.h>
#include <immintrin.h>
#include "mkl.h"
#define small_pi 3.1415926536
#define _2pi (2.0 * small_pi)
class CChanelAWGN_MKL : public CChanel
class CChanelAWGN : public CChanel
{
private:
double inv_erf(int v);
float* noise;
VSLStreamStatePtr stream;
public:
CChanelAWGN_MKL(CTrame *t, int _BITS_LLR, bool QPSK, bool Es_N0);
~CChanelAWGN_MKL();
CChanelAWGN(CTrame *t, int _BITS_LLR, bool QPSK, bool Es_N0);
~CChanelAWGN();
virtual void configure(double _Eb_N0);
virtual double get_R();
......
......@@ -25,10 +25,10 @@
#include <stdio.h>
#include <math.h>
#include "./CChanel.h"
#include "./CChanelAWGN_MKL.h"
#include "./CChanelAWGN.h"
CChanel* CreateChannel(string arch, int channelType, CTrame *trame, bool QPSK_CHANNEL, bool Es_N0) {
return new CChanelAWGN_MKL(trame, 4, QPSK_CHANNEL, Es_N0);
return new CChanelAWGN(trame, 4, QPSK_CHANNEL, Es_N0);
}
......
macro(package_add_test TESTNAME)
add_executable(${TESTNAME} ${ARGN})
target_link_libraries(${TESTNAME} gtest gtest_main)
target_include_directories(${TESTNAME} PRIVATE ${PROJECT_SOURCE_DIR}/src ${MKL_INCLUDE_DIRS})
target_include_directories(${TESTNAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_compile_definitions(${TESTNAME} PRIVATE "-D${CodeRate}")
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME})
set_target_properties(${TESTNAME} PROPERTIES FOLDER tests)
......
......@@ -7,14 +7,9 @@ This repository contains:
## Dependencies
* OpenMP
* Intel MKL library
## Build
First and foremost, you must export an MKL\_ROOT environnement variable containing the path to the MKL library:
`export MKL_ROOT=<path_to_intel_SDK>/compilers_and_libraries_2019.2.187/linux/mkl`
Then,
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment