allocate on stack

This commit is contained in:
Oliver Kowalke
2014-01-25 23:41:06 +01:00
parent 8857a31281
commit 7b6bba07c0
17 changed files with 2166 additions and 2580 deletions

View File

@@ -17,12 +17,13 @@
#include "clock.hpp"
#include "cycle.hpp"
typedef boost::coroutines::protected_stack_allocator stack_allocator;
typedef boost::coroutines::protected_stack_allocator stack_allocator;
typedef boost::coroutines::coroutine< void, stack_allocator > coroutine;
boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved;
boost::uint64_t jobs = 1000;
void fn( boost::coroutines::coroutine< void >::push_type & c)
void fn( coroutine::push_type & c)
{ while ( true) c(); }
duration_type measure_time()
@@ -30,11 +31,11 @@ duration_type measure_time()
stack_allocator stack_alloc;
// cache warum-up
boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
coroutine::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
time_point_type start( clock_type::now() );
for ( std::size_t i = 0; i < jobs; ++i) {
boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
coroutine::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
}
duration_type total = clock_type::now() - start;
total -= overhead_clock(); // overhead of measurement
@@ -49,11 +50,11 @@ cycle_type measure_cycles()
stack_allocator stack_alloc;
// cache warum-up
boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
coroutine::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
cycle_type start( cycles() );
for ( std::size_t i = 0; i < jobs; ++i) {
boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
coroutine::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc);
}
cycle_type total = cycles() - start;
total -= overhead_cycle(); // overhead of measurement