From f9531223b72f8337b8d774c9e3a0d0b0f9ffcc7b Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 2 Nov 2011 15:11:59 +0100 Subject: Cleaning up a bit. --- CMakeLists.txt | 2 -- src/Chain.h | 10 ++++++++++ src/Experiment.cpp | 13 +++++++++++-- src/Experiment.h | 11 +++++++++++ src/Lock.cpp | 14 ++++++++++++-- src/Lock.h | 12 ++++++++++++ src/Main.cpp | 13 ++++++++++++- src/Output.cpp | 14 +++++++++++--- src/Output.h | 11 +++++++++++ src/Run.cpp | 26 +++++++++++++++++--------- src/Run.h | 12 +++++++++++- src/SpinBarrier.cpp | 15 +++++++++++++-- src/SpinBarrier.h | 7 +++++++ src/Thread.cpp | 17 +++++++++++++---- src/Thread.h | 12 ++++++++++++ src/Timer.cpp | 15 ++++++++++++--- src/Timer.h | 11 +++++++++++ src/Types.cpp | 12 ------------ src/Types.h | 10 ++++++++++ 19 files changed, 196 insertions(+), 41 deletions(-) delete mode 100644 src/Types.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c232e64..6c88c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,6 @@ add_library(SpinBarrier src/SpinBarrier.h src/SpinBarrier.cpp) add_library(Timer src/Timer.h src/Timer.cpp) -add_library(Types src/Types.h src/Types.cpp) - add_executable (chase src/Main.cpp) target_link_libraries(chase Run Timer Output Experiment SpinBarrier) target_link_libraries(chase ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/Chain.h b/src/Chain.h index dc25738..16c5eb9 100644 --- a/src/Chain.h +++ b/src/Chain.h @@ -9,9 +9,19 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Chain_h) #define Chain_h + +// +// Struct definition +// + struct Chain { Chain* next; private: diff --git a/src/Experiment.cpp b/src/Experiment.cpp index e58be0a..701647c 100644 --- a/src/Experiment.cpp +++ b/src/Experiment.cpp @@ -9,17 +9,26 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// +// Implementation header +#include "Experiment.h" + +// System includes #include #include #include #include - #if defined(NUMA) #include #endif -#include "Experiment.h" + +// +// Implementation +// Experiment::Experiment() : strict (0), diff --git a/src/Experiment.h b/src/Experiment.h index e90d55c..b6a2bf5 100644 --- a/src/Experiment.h +++ b/src/Experiment.h @@ -9,12 +9,23 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Experiment_h) #define Experiment_h +// Local includes #include "Chain.h" #include "Types.h" + +// +// Class definition +// + class Experiment { public: Experiment(); diff --git a/src/Lock.cpp b/src/Lock.cpp index 517843d..c4262e2 100644 --- a/src/Lock.cpp +++ b/src/Lock.cpp @@ -9,11 +9,21 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ -#include -#include +// +// Configuration +// +// Implementation header #include "Lock.h" +// System includes +#include + + +// +// Implementation +// + Lock::Lock() { pthread_mutex_init(&(this->mutex), NULL); } diff --git a/src/Lock.h b/src/Lock.h index 04d5e15..46bd04e 100644 --- a/src/Lock.h +++ b/src/Lock.h @@ -9,11 +9,23 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + + +// Include guard #if !defined(Lock_h) #define Lock_h +// System includes #include + +// +// Class definition +// + class Lock { public: Lock(); diff --git a/src/Main.cpp b/src/Main.cpp index ccdaef8..17ea869 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -9,8 +9,14 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ -#include +// +// Configuration +// +// System includes +#include + +// Local includes #include "Run.h" #include "Timer.h" #include "Types.h" @@ -48,6 +54,11 @@ // pointers may be 32-bit or 64-bit // pointers. + +// +// Implementation +// + int verbose = 0; int main(int argc, char* argv[]) { diff --git a/src/Output.cpp b/src/Output.cpp index 84eb0df..bfffe0d 100644 --- a/src/Output.cpp +++ b/src/Output.cpp @@ -9,14 +9,22 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Implementation header +#include "Output.h" + +// System includes #include #include #include -#include "Output.h" -#include "Types.h" -#include "Experiment.h" +// +// Implementation +// void Output::print(Experiment &e, int64 ops, double secs, double ck_res) { if (e.output_mode == Experiment::CSV) { diff --git a/src/Output.h b/src/Output.h index 65d3926..db7d912 100644 --- a/src/Output.h +++ b/src/Output.h @@ -9,12 +9,23 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Output_h) #define Output_h +// Local includes #include "Types.h" #include "Experiment.h" + +// +// Class definition +// + class Output { public: static void print(Experiment &e, int64 ops, double secs, double ck_res); diff --git a/src/Run.cpp b/src/Run.cpp index dab1d11..0de55c8 100644 --- a/src/Run.cpp +++ b/src/Run.cpp @@ -9,23 +9,31 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ -#include -#include +// +// Configuration +// + +// Implementation header +#include "Run.h" + +// System includes +#include +#include #include -#include +#include #include - #if defined(NUMA) #include #endif -#include "Run.h" - +// Local includes #include - -#include "Chain.h" #include "Timer.h" -#include "SpinBarrier.h" + + +// +// Implementation +// static double max(double v1, double v2); static double min(double v1, double v2); diff --git a/src/Run.h b/src/Run.h index 8b51397..7f82076 100644 --- a/src/Run.h +++ b/src/Run.h @@ -9,17 +9,27 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Run_h) #define Run_h +// Local includes #include "Thread.h" - #include "Lock.h" #include "Chain.h" #include "Types.h" #include "Experiment.h" #include "SpinBarrier.h" + +// +// Class definition +// + class Run: public Thread { public: Run(); diff --git a/src/SpinBarrier.cpp b/src/SpinBarrier.cpp index d89e7c3..5ff5ce1 100644 --- a/src/SpinBarrier.cpp +++ b/src/SpinBarrier.cpp @@ -21,11 +21,22 @@ * void barrier() * * * ******************************************************************************/ -#include -#include +// +// Configuration +// + +// Implementation header #include "SpinBarrier.h" +// System includes +#include + + +// +// Implementation +// + // create a new barrier SpinBarrier::SpinBarrier(int participants) : limit(participants) { diff --git a/src/SpinBarrier.h b/src/SpinBarrier.h index 4ab3242..a329f7c 100644 --- a/src/SpinBarrier.h +++ b/src/SpinBarrier.h @@ -23,11 +23,18 @@ * * ******************************************************************************/ +// Include guard #if !defined( SpinBarrier_h ) #define SpinBarrier_h +// System includes #include + +// +// Class definition +// + class SpinBarrier { public: SpinBarrier(int participants); diff --git a/src/Thread.cpp b/src/Thread.cpp index 0dfb91c..c7ea37d 100644 --- a/src/Thread.cpp +++ b/src/Thread.cpp @@ -9,17 +9,26 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ -#include -#include -#include +// +// Configuration +// +// Implementation header #include "Thread.h" -#include "Lock.h" +// System includes +#include +#include +#include Lock Thread::_global_lock; int Thread::count = 0; + +// +// Implementation +// + Thread::Thread() { Thread::global_lock(); this->id = Thread::count; diff --git a/src/Thread.h b/src/Thread.h index 55ebf1c..8ca2b76 100644 --- a/src/Thread.h +++ b/src/Thread.h @@ -9,13 +9,25 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Thread_h) #define Thread_h +// System includes #include +// Local includes #include "Lock.h" + +// +// Class definition +// + class Thread { public: Thread(); diff --git a/src/Timer.cpp b/src/Timer.cpp index 8331b9a..24ec8e9 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -9,12 +9,16 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ -#include -#include +// +// Configuration +// +// Implementation header #include "Timer.h" -#include "Types.h" +// System includes +#include +#include static int64 read_rtc(); static void calibrate_rtc(int n); @@ -30,6 +34,11 @@ static double time_factor = -1; #define RTC #endif + +// +// Implementation +// + #if defined(RTC) double Timer::seconds() { diff --git a/src/Timer.h b/src/Timer.h index abc52af..7689f36 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -9,11 +9,22 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Timer_h) #define Timer_h +// Local includes #include "Types.h" + +// +// Class definition +// + class Timer { public: static double seconds(); diff --git a/src/Types.cpp b/src/Types.cpp deleted file mode 100644 index 409f727..0000000 --- a/src/Types.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 International Business Machines Corporation. * - * All rights reserved. This program and the accompanying materials * - * are made available under the terms of the Common Public License v1.0 * - * which accompanies this distribution, and is available at * - * http://www.opensource.org/licenses/cpl1.0.php * - * * - * Contributors: * - * Douglas M. Pase - initial API and implementation * - *******************************************************************************/ - -#include "Types.h" diff --git a/src/Types.h b/src/Types.h index 9bb6038..73bd501 100644 --- a/src/Types.h +++ b/src/Types.h @@ -9,9 +9,19 @@ * Douglas M. Pase - initial API and implementation * *******************************************************************************/ +// +// Configuration +// + +// Include guard #if !defined(Types_h) #define Types_h + +// +// Type definitions +// + typedef long long int64; typedef int int32; typedef short int16; -- cgit v1.2.3