diff options
author | Tim Besard <tim.besard@gmail.com> | 2011-10-31 20:07:33 +0100 |
---|---|---|
committer | Tim Besard <tim.besard@gmail.com> | 2011-10-31 20:07:33 +0100 |
commit | f8ecbea68082f8f5cdfb088a783b2e46b63e9f23 (patch) | |
tree | 75deedefa48e5b0af097fe03f79965f1955109ac | |
parent | 122d27347290ff066635bc3005a332d9574bedb2 (diff) |
Adding busy cycles.
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Experiment.cpp | 8 | ||||
-rw-r--r-- | src/Experiment.h | 4 | ||||
-rw-r--r-- | src/Run.cpp | 48 |
4 files changed, 55 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3da4838..47ab5c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,9 @@ add_library(Timer src/Timer.h src/Timer.cpp) add_library(Types src/Types.h src/Types.cpp) -add_executable (pChase src/Main.h src/Main.cpp) -target_link_libraries(pChase Run Timer Output Experiment SpinBarrier) -target_link_libraries(pChase ${CMAKE_THREAD_LIBS_INIT}) +add_executable (chase src/Main.h src/Main.cpp) +target_link_libraries(chase Run Timer Output Experiment SpinBarrier) +target_link_libraries(chase ${CMAKE_THREAD_LIBS_INIT}) if (USE_LIBNUMA) if(LIBNUMA) target_link_libraries(pChase ${LIBNUMA}) diff --git a/src/Experiment.cpp b/src/Experiment.cpp index 75b1cab..04fb9ef 100644 --- a/src/Experiment.cpp +++ b/src/Experiment.cpp @@ -37,6 +37,7 @@ Experiment::Experiment() : bytes_per_thread (DEFAULT_BYTES_PER_THREAD), num_threads (DEFAULT_THREADS), bytes_per_test (DEFAULT_BYTES_PER_TEST), + busy_cycles (DEFAULT_BUSY_CYCLES), seconds (DEFAULT_SECONDS), iterations (DEFAULT_ITERATIONS), experiments (DEFAULT_EXPERIMENTS), @@ -66,6 +67,7 @@ Experiment::~Experiment() // -t or --threads number of threads (concurrency and contention) // -i or --iters iterations // -e or --experiments experiments + // -b or --busy amount of cycles processor should remain busy // -a or --access memory access pattern // random random access pattern // forward <stride> exclusive OR and mask @@ -130,6 +132,11 @@ Experiment::parse_args(int argc, char* argv[]) if (i == argc) { error = 1; break; } this->experiments = Experiment::parse_number(argv[i]); if (this->experiments == 0) { error = 1; break; } + } else if (strcasecmp(argv[i], "-b") == 0 || strcasecmp(argv[i], "--busy") == 0) { + i++; + if (i == argc) { error = 1; break; } + this->busy_cycles = Experiment::parse_number(argv[i]); + if (this->experiments == 0) { error = 1; break; } } else if (strcasecmp(argv[i], "-a") == 0 || strcasecmp(argv[i], "--access") == 0) { i++; if (i == argc) { error = 1; break; } @@ -221,6 +228,7 @@ Experiment::parse_args(int argc, char* argv[]) printf(" [-o|--output] <format> # output format\n"); printf(" [-n|--numa] <placement> # numa placement\n"); printf(" [-s|--seconds] <number> # run each experiment for <number> seconds\n"); + printf(" [-b|--busy] <number> # how much processing cycles each loop should count\n"); printf(" [-x|--strict] # fail rather than adjust options to sensible values\n"); printf("\n"); printf("<pattern> is selected from the following:\n"); diff --git a/src/Experiment.h b/src/Experiment.h index 2c749d3..4c0ae90 100644 --- a/src/Experiment.h +++ b/src/Experiment.h @@ -40,9 +40,10 @@ public: int64 links_per_chain; // working set chain size (links) int64 pages_per_chain; // working set chain size (pages) int64 bytes_per_thread; // thread working set size (bytes) - int64 chains_per_thread; // memory loading per thread + int64 chains_per_thread;// memory loading per thread int64 num_threads; // number of threads in the experiment int64 bytes_per_test; // test working set size (bytes) + int64 busy_cycles; // processing cycles float seconds; // number of seconds per experiment int64 iterations; // number of iterations per experiment @@ -84,6 +85,7 @@ public: const static int32 DEFAULT_BYTES_PER_THREAD = DEFAULT_BYTES_PER_CHAIN * DEFAULT_CHAINS_PER_THREAD; const static int32 DEFAULT_THREADS = 1; const static int32 DEFAULT_BYTES_PER_TEST = DEFAULT_BYTES_PER_THREAD * DEFAULT_THREADS; + const static int32 DEFAULT_BUSY_CYCLES = 10; const static int32 DEFAULT_SECONDS = 1; const static int32 DEFAULT_ITERATIONS = 0; const static int32 DEFAULT_EXPERIMENTS = 1; diff --git a/src/Run.cpp b/src/Run.cpp index 4fb8057..1ea4db3 100644 --- a/src/Run.cpp +++ b/src/Run.cpp @@ -27,9 +27,9 @@ static double max( double v1, double v2 ); static double min( double v1, double v2 ); -static void chase_pointers(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride); -static void follow_streams(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride); -static void (*run_benchmark)(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride) = chase_pointers; +static void chase_pointers(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride, int64 busy_cycles); +static void follow_streams(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride, int64 busy_cycles); +static void (*run_benchmark)(int64 chains_per_thread, int64 iterations, Chain** root, int64 bytes_per_line, int64 bytes_per_chain, int64 stride, int64 busy_cycles) = chase_pointers; Lock Run::global_mutex; int64 Run::_ops_per_chain = 0; @@ -120,7 +120,7 @@ Run::run() this->bp->barrier(); // chase pointers - run_benchmark(this->exp->chains_per_thread, iters, root, this->exp->bytes_per_line, this->exp->bytes_per_chain, this->exp->stride); + run_benchmark(this->exp->chains_per_thread, iters, root, this->exp->bytes_per_line, this->exp->bytes_per_chain, this->exp->stride, this->exp->busy_cycles); // barrier this->bp->barrier(); @@ -156,7 +156,7 @@ Run::run() this->bp->barrier(); // chase pointers - run_benchmark(this->exp->chains_per_thread, this->exp->iterations, root, this->exp->bytes_per_line, this->exp->bytes_per_chain, this->exp->stride); + run_benchmark(this->exp->chains_per_thread, this->exp->iterations, root, this->exp->bytes_per_line, this->exp->bytes_per_chain, this->exp->stride, this->exp->busy_cycles); // barrier this->bp->barrier(); @@ -348,7 +348,8 @@ chase_pointers( Chain** root, // root(s) of the chain(s) to follow int64 bytes_per_line, // ignored int64 bytes_per_chain, // ignored - int64 stride // ignored + int64 stride, // ignored + int64 busy_cycles // processing cycles ) { // chase pointers @@ -359,6 +360,8 @@ chase_pointers( Chain* a = root[0]; while (a != NULL) { a = a->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); } @@ -370,6 +373,8 @@ chase_pointers( while (a != NULL) { a = a->next; b = b->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -384,6 +389,8 @@ chase_pointers( a = a->next; b = b->next; c = c->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -401,6 +408,8 @@ chase_pointers( b = b->next; c = c->next; d = d->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -421,6 +430,8 @@ chase_pointers( c = c->next; d = d->next; e = e->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -444,6 +455,8 @@ chase_pointers( d = d->next; e = e->next; f = f->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -470,6 +483,8 @@ chase_pointers( e = e->next; f = f->next; g = g->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -499,6 +514,8 @@ chase_pointers( f = f->next; g = g->next; h = h->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -531,6 +548,8 @@ chase_pointers( g = g->next; h = h->next; j = j->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -566,6 +585,8 @@ chase_pointers( h = h->next; j = j->next; k = k->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -604,6 +625,8 @@ chase_pointers( j = j->next; k = k->next; l = l->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -645,6 +668,8 @@ chase_pointers( k = k->next; l = l->next; m = m->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -689,6 +714,8 @@ chase_pointers( l = l->next; m = m->next; n = n->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -736,6 +763,8 @@ chase_pointers( m = m->next; n = n->next; o = o->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -786,6 +815,8 @@ chase_pointers( n = n->next; o = o->next; p = p->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -839,6 +870,8 @@ chase_pointers( o = o->next; p = p->next; q = q->next; + for (int64 j=0; j < busy_cycles; j++) + asm("nop"); } mem_chk( a ); mem_chk( b ); @@ -905,7 +938,8 @@ follow_streams( Chain** root, // root(s) of the chain(s) to follow int64 bytes_per_line, // ignored int64 bytes_per_chain, // ignored - int64 stride // ignored + int64 stride, // ignored + int64 busy_cycles // ignored ) { int64 refs_per_line = bytes_per_line / sizeof(double); |