diff options
author | 2016-04-10 10:15:54 +0300 | |
---|---|---|
committer | 2016-04-10 12:37:21 +0300 | |
commit | c48c89a97ad070b8f79ac746b6b83aab1cc6f177 (patch) | |
tree | b7842d488afe01f29e0f218b9dc9db85bb03afa9 /src/stateless/cp | |
parent | f39e572d1fbbf17aa7c9e071b9c056ab85f894a5 (diff) |
multicore scheduling
Diffstat (limited to 'src/stateless/cp')
-rw-r--r-- | src/stateless/cp/trex_stream.cpp | 3 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 13 | ||||
-rw-r--r-- | src/stateless/cp/trex_streams_compiler.cpp | 43 |
3 files changed, 37 insertions, 22 deletions
diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp index 6e4478d6..4325858c 100644 --- a/src/stateless/cp/trex_stream.cpp +++ b/src/stateless/cp/trex_stream.cpp @@ -135,7 +135,8 @@ TrexStream::TrexStream(uint8_t type, m_enabled = false; m_self_start = false; - m_delay_next_stream_sec = 0; + m_mc_phase_pre_sec = 0; + m_mc_phase_post_sec = 0; m_pkt.binary = NULL; m_pkt.len = 0; diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index e4ce914e..1914026b 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -401,6 +401,7 @@ public: set_multi_burst(burst_total_pkts,1,0.0); } + /* create new stream */ TrexStream * clone(bool full = false) const { @@ -422,7 +423,11 @@ public: } dp->m_isg_usec = m_isg_usec; - dp->m_delay_next_stream_sec = m_delay_next_stream_sec; + + /* multi core phase paramters */ + dp->m_mc_phase_pre_sec = m_mc_phase_pre_sec; + dp->m_mc_phase_post_sec = m_mc_phase_post_sec; + dp->m_next_stream_id = m_next_stream_id; dp->m_enabled = m_enabled; @@ -457,7 +462,7 @@ public: return ( (m_burst_total_pkts / get_pps()) * 1000 * 1000); } - double get_ipg() { + double get_ipg_sec() { return (1.0 / get_pps()); } @@ -502,7 +507,9 @@ public: /* config fields */ - double m_delay_next_stream_sec; + double m_mc_phase_pre_sec; + double m_mc_phase_post_sec; + double m_isg_usec; int m_next_stream_id; diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp index da2b9c9b..c4ae0bed 100644 --- a/src/stateless/cp/trex_streams_compiler.cpp +++ b/src/stateless/cp/trex_streams_compiler.cpp @@ -586,6 +586,11 @@ TrexStreamsCompiler::compile_stream_on_all_cores(TrexStream *stream, int per_core_burst_total_pkts = (stream->m_burst_total_pkts / dp_core_count); int burst_remainder = (stream->m_burst_total_pkts % dp_core_count); + bool has_remainder = (burst_remainder > 0); + int remainder_left = burst_remainder; + + double base_ipg_sec = factor * stream->get_ipg_sec(); + /* for each core - creates its own version of the stream */ for (uint8_t i = 0; i < dp_core_count; i++) { @@ -594,30 +599,32 @@ TrexStreamsCompiler::compile_stream_on_all_cores(TrexStream *stream, /* fix stream ID */ dp_stream->fix_dp_stream_id(new_id, new_next_id); + /* some phase */ + dp_stream->m_mc_phase_pre_sec = base_ipg_sec * i; + /* each core gets a share of the packets */ dp_stream->m_burst_total_pkts = per_core_burst_total_pkts; + + /* rate is slower * dp_core_count */ + dp_stream->update_rate_factor(factor / dp_core_count); + - /* core 0 also gets the remainder */ - if (i == 0) { - dp_stream->m_burst_total_pkts += burst_remainder; - } - - /* for continous the rate is divided by the cores */ - if (stream->m_type == TrexStream::stCONTINUOUS) { - dp_stream->update_rate_factor(factor / dp_core_count); + /* allocate the rest of the packets */ + if (has_remainder) { + if (remainder_left > 0) { + dp_stream->m_burst_total_pkts++; + remainder_left--; + dp_stream->m_mc_phase_post_sec = base_ipg_sec * remainder_left; + } else { + /* a delay slot if no packets left */ + dp_stream->m_mc_phase_post_sec = base_ipg_sec * (dp_core_count - 1 - i + burst_remainder); + } + } else { - /* rate is according to the share of the packetes the core got */ - dp_stream->update_rate_factor(factor * (dp_stream->m_burst_total_pkts / double(stream->m_burst_total_pkts))); + /* if no remainder (or continous) simply add a reverse phase */ + dp_stream->m_mc_phase_post_sec = base_ipg_sec * (dp_core_count - 1 - i); } - - - //dp_stream->m_pkt.binary[14 + 20] = 0; - //dp_stream->m_pkt.binary[14 + 21] = i; - - /* some phase */ - dp_stream->m_isg_usec += (stream->get_ipg() * i) * 1e6; - dp_stream->m_delay_next_stream_sec = stream->get_ipg() * (dp_core_count - 1 - i); core_streams[i] = dp_stream; } |