📄 test_ldpc_sse2.c
字号:
/*************************************************************************** test_ldpc_sse2.c - Module for testing optimized ldpc-codes ------------------- begin : 2003 authors : ysrini and ggupta emails : e-mail ***************************************************************************//*************************************************************************** Changes ------- date - name - description 03/08/x - ysrini - start 04/03/03 - ineiti - added a small comment **************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/char desc[] ="Description:\n""This test compares the speed of the non-optimized LDPC code with\n""the LDPC decoder implemented in SSE2. First it outputs the performances\n""of the non-optimized LDPC code for codes with rate 0.25, 0.5 and 0.75.\n""Each code is tested at 5 different SNR and the respective errors are\n""printed. At the end of each code-rate, the average time for decoding\n""is outputted.\n""After that, the optimized LDPC code is used for the same tests, that is,\n""rate 0.25, 0.5 and 0.75 at 5 different SNRs.\n""The speed-up should be between 5 and 8, depending on the code-rate.\n""If you have an old computer that doesn't support SSE2, this will of course\n""not work!\n\n";#include "spc.h"#include "std.h"#include "chain.h"#define DBG_LVL 4struct chain_t *test_chain;void *start_it( void *arg ){ int i, sigma, sse2; swr_sdb_id rand, encode, mod, decode, block, send_data, received_data, mafi_id, midamble; for ( sse2=1; sse2<=1; sse2++ ){ // make one chain without sse2, the other with it if ( !sse2 ){ PR( "\nSending with non-optimized LDPC-coder\n" ); test_chain = swr_chain_create( NEW_SPC_VAR( "random", rand ), NEW_SPC_VAR( "test_data_send", send_data ), NEW_SPC_VAR( "ldpc_encode", encode ), NEW_SPC_VAR( "mapper", mod ), NEW_SPC_VAR( "midamble", midamble ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter", mafi_id ), NEW_SPC_VAR( "ldpc_decode", decode ), NEW_SPC_VAR( "test_data_rcv", received_data ), CHAIN_END ); } else { PR( "\nSending with SSE2-optimized LDPC-coder\n" ); test_chain = swr_chain_create( NEW_SPC_VAR( "random", rand ), NEW_SPC_VAR( "test_data_send", send_data ), NEW_SPC_VAR( "ldpc_encode_sse2", encode ), NEW_SPC_VAR( "mapper", mod ), NEW_SPC_VAR( "midamble", midamble ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter", mafi_id ), NEW_SPC_VAR( "ldpc_decode_sse2", decode ), NEW_SPC_VAR( "test_data_rcv", received_data ), CHAIN_END ); } swr_conn_add(send_data, 1, received_data, 1); // swr_sdb_set_config_int( midamble, "amplitude", 16384 ); // division by sqrt(2) is now done directly in the module // swr_sdb_set_config_int( mod, "amplitude", 16384 ); swr_sdb_set_config_int( decode, "iterations", 40 ); swr_sdb_set_config_int( decode, "channel_type", 2 ); // Here we take the channel_param from mafi. I.e. a/variance // is not 1/15 but computed in ldpc_decode with the values taken from midamble_rcv swr_sdb_set_config_int( decode, "mafi", mafi_id ); for ( i=1; i<=3; i++ ){ swr_sdb_set_config_int( encode, "ldpc_code_id", i ); swr_sdb_set_config_int( decode, "ldpc_code_id", i ); // Tell the random-module to produce a block of random-data which will // be propagated to the encode and decode module and finish in the sink. PR( "Sending with code %i\n", i ); swr_sdb_clear_profile( decode ); for ( sigma=100; sigma <= 900; sigma += 200 ){ swr_sdb_set_config_double( block, "sigma", sigma ); swr_sdb_set_config_int( received_data, "clear", 1 ); swr_sdb_send_msg( rand, SUBS_MSG_USER, NULL, -1 ); PR( "Transmitted %i bits and got %i errors with SNR =%g\n", swr_sdb_get_stats_int( received_data, "total" ), swr_sdb_get_stats_int( received_data, "error" ), swr_sdb_get_stats_double(mafi_id, "snr") ); } swr_sdb_show_profile( decode ); } swr_chain_destroy( test_chain ); } // After this call, the chain has been walked through usleep( 1000000 ); return 0;}swr_spc_id_t spm_id;struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void){ PR_CL( desc ); test_chain = NULL; if ( swr_thread_init( &start, start_it, NULL ) < 0 ) goto first_no_stack; return 0;first_no_stack: PR_DBG( 0, "Couldn't allocate stack\n" ); return -1;}void um_module_exit( void ){ swr_thread_free( &start, NULL );}module_init( um_module_init );module_exit( um_module_exit );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -