summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/Chain.h10
-rw-r--r--src/Experiment.cpp13
-rw-r--r--src/Experiment.h11
-rw-r--r--src/Lock.cpp14
-rw-r--r--src/Lock.h12
-rw-r--r--src/Main.cpp13
-rw-r--r--src/Output.cpp14
-rw-r--r--src/Output.h11
-rw-r--r--src/Run.cpp26
-rw-r--r--src/Run.h12
-rw-r--r--src/SpinBarrier.cpp15
-rw-r--r--src/SpinBarrier.h7
-rw-r--r--src/Thread.cpp17
-rw-r--r--src/Thread.h12
-rw-r--r--src/Timer.cpp15
-rw-r--r--src/Timer.h11
-rw-r--r--src/Types.cpp12
-rw-r--r--src/Types.h10
19 files changed, 196 insertions, 41 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-
#if defined(NUMA)
#include <numa.h>
#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 <stdio.h>
-#include <pthread.h>
+//
+// Configuration
+//
+// Implementation header
#include "Lock.h"
+// System includes
+#include <cstdio>
+
+
+//
+// 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 <pthread.h>
+
+//
+// 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 <stdio.h>
+//
+// Configuration
+//
+// System includes
+#include <cstdio>
+
+// 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
-#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 <stdio.h>
-#include <stdlib.h>
+//
+// Configuration
+//
+
+// Implementation header
+#include "Run.h"
+
+// System includes
+#include <cstdio>
+#include <cstdlib>
#include <unistd.h>
-#include <stddef.h>
+#include <cstddef>
#include <vector>
-
#if defined(NUMA)
#include <numa.h>
#endif
-#include "Run.h"
-
+// Local includes
#include <AsmJit/AsmJit.h>
-
-#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 <stdio.h>
-#include <pthread.h>
+//
+// Configuration
+//
+
+// Implementation header
#include "SpinBarrier.h"
+// System includes
+#include <cstdio>
+
+
+//
+// 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 <pthread.h>
+
+//
+// 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 <stdio.h>
-#include <pthread.h>
-#include <unistd.h>
+//
+// Configuration
+//
+// Implementation header
#include "Thread.h"
-#include "Lock.h"
+// System includes
+#include <cstdio>
+#include <pthread.h>
+#include <unistd.h>
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 <pthread.h>
+// 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 <stdio.h>
-#include <sys/time.h>
+//
+// Configuration
+//
+// Implementation header
#include "Timer.h"
-#include "Types.h"
+// System includes
+#include <cstdio>
+#include <sys/time.h>
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;