summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt49
-rw-r--r--Makefile63
-rw-r--r--src/Chain.cpp (renamed from Chain.C)0
-rw-r--r--src/Chain.h (renamed from Chain.h)0
-rw-r--r--src/Experiment.cpp (renamed from Experiment.C)0
-rw-r--r--src/Experiment.h (renamed from Experiment.h)0
-rw-r--r--src/Lock.cpp (renamed from Lock.C)0
-rw-r--r--src/Lock.h (renamed from Lock.h)0
-rw-r--r--src/Main.c90
-rw-r--r--src/Main.cpp (renamed from Main.C)0
-rw-r--r--src/Main.h (renamed from Main.h)0
-rw-r--r--src/Output.cpp (renamed from Output.C)0
-rw-r--r--src/Output.h (renamed from Output.h)0
-rw-r--r--src/Run.cpp (renamed from Run.C)0
-rw-r--r--src/Run.h (renamed from Run.h)0
-rw-r--r--src/SpinBarrier.cpp (renamed from SpinBarrier.C)0
-rw-r--r--src/SpinBarrier.h (renamed from SpinBarrier.h)0
-rw-r--r--src/Thread.cpp (renamed from Thread.C)0
-rw-r--r--src/Thread.h (renamed from Thread.h)0
-rw-r--r--src/Timer.cpp (renamed from Timer.C)0
-rw-r--r--src/Timer.h (renamed from Timer.h)0
-rw-r--r--src/Types.cpp (renamed from Types.C)0
-rw-r--r--src/Types.h (renamed from Types.h)0
23 files changed, 139 insertions, 63 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..3da4838
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,49 @@
+#
+# Project configuration
+#
+
+cmake_minimum_required(VERSION 2.6)
+project(pChase)
+
+set (pChase_VERSION_MAJOR 0)
+set (pChase_VERSION_MINOR 4)
+
+find_package(Threads)
+
+find_library(LIBNUMA numa)
+option(USE_LIBNUMA "Build against NUMA libraries" ON)
+
+
+#
+# Code compilation
+#
+
+add_library(Chain src/Chain.h src/Chain.cpp)
+
+add_library(Experiment src/Experiment.h src/Experiment.cpp)
+
+add_library(Thread src/Thread.h src/Thread.cpp)
+
+add_library(Lock src/Lock.h src/Lock.cpp)
+
+add_library(Output src/Output.h src/Output.cpp)
+
+add_library(Run src/Run.h src/Run.cpp)
+target_link_libraries(Run Lock Chain Thread)
+
+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 (pChase src/Main.h src/Main.cpp)
+target_link_libraries(pChase Run Timer Output Experiment SpinBarrier)
+target_link_libraries(pChase ${CMAKE_THREAD_LIBS_INIT})
+if (USE_LIBNUMA)
+ if(LIBNUMA)
+ target_link_libraries(pChase ${LIBNUMA})
+ else ()
+ message(STATUS "WARNING: libnuma not found, not compiling against it")
+ endif ()
+endif ()
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 9ae95b9..0000000
--- a/Makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-
-#
-# BIT = { 32 | 64 }
-# MODE = { NUMA | SMP }
-#
-ifndef BIT
-BIT = 64
-endif
-ifndef MODE
-MODE = NUMA
-endif
-ifeq ($(MODE), NUMA)
-LIB = -lpthread -lnuma
-else
-LIB = -lpthread
-endif
-
-SRC = Main.C Chain.C Experiment.C Lock.C Output.C Run.C SpinBarrier.C Timer.C Thread.C Types.C
-HDR = $(SRC:.C=.h)
-OBJ = $(SRC:.C=.o)
-EXE = pChase$(BIT)_$(MODE)
-HYPDIR = /web/hypercomputing.org/www/doc/Guest/pChase
-PCHDIR = /web/pchase.org/www/doc/Guest/pChase
-TARFILE = tgz/pChase-`date +"%Y-%m-%d"`.tgz
-
-RM = /bin/rm
-MV = /bin/mv
-CI = /usr/bin/ci
-CO = /usr/bin/co
-CP = /bin/cp
-TAR = /bin/tar
-
-CXXFLAGS= -O3 -m$(BIT) -D$(MODE)
-
-.C.o:
- $(CXX) -c $(CXXFLAGS) $<
-
-$(EXE): $(OBJ)
- $(CXX) -o $(EXE) $(CXXFLAGS) $(OBJ) $(LIB)
-
-$(OBJ): $(HDR)
-
-rmexe:
- $(RM) -rf $(EXE)
-
-rmobj:
- $(RM) -rf $(OBJ)
-
-ci:
- $(CI) -f $(SRC) $(HDR) Makefile
-
-co:
- $(CO) -l $(SRC) $(HDR) Makefile
-
-tar:
- $(TAR) -cvzf $(TARFILE) $(SRC) $(HDR) Makefile License.htm License.txt pChase.sh run-pChase.sh
-
-cptar:
- $(TAR) -cvzf $(TARFILE) $(SRC) $(HDR) Makefile License.htm License.txt pChase.sh run-pChase.sh
- $(CP) $(TARFILE) $(HYPDIR)/tgz
- $(CP) $(SRC) $(HDR) Makefile License.htm License.txt pChase.sh run-pChase.sh $(HYPDIR)
- $(CP) $(TARFILE) $(PCHDIR)/tgz
- $(CP) $(SRC) $(HDR) Makefile License.htm License.txt pChase.sh run-pChase.sh $(PCHDIR)
diff --git a/Chain.C b/src/Chain.cpp
index ddbc104..ddbc104 100644
--- a/Chain.C
+++ b/src/Chain.cpp
diff --git a/Chain.h b/src/Chain.h
index 8bdb584..8bdb584 100644
--- a/Chain.h
+++ b/src/Chain.h
diff --git a/Experiment.C b/src/Experiment.cpp
index 75b1cab..75b1cab 100644
--- a/Experiment.C
+++ b/src/Experiment.cpp
diff --git a/Experiment.h b/src/Experiment.h
index 2c749d3..2c749d3 100644
--- a/Experiment.h
+++ b/src/Experiment.h
diff --git a/Lock.C b/src/Lock.cpp
index 104dc81..104dc81 100644
--- a/Lock.C
+++ b/src/Lock.cpp
diff --git a/Lock.h b/src/Lock.h
index 14bf1dc..14bf1dc 100644
--- a/Lock.h
+++ b/src/Lock.h
diff --git a/src/Main.c b/src/Main.c
new file mode 100644
index 0000000..5d5f243
--- /dev/null
+++ b/src/Main.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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 <stdio.h>
+
+#include "Main.h"
+
+#include "Run.h"
+#include "Timer.h"
+#include "Types.h"
+#include "Output.h"
+#include "Experiment.h"
+#include "SpinBarrier.h"
+
+ // This program allocates and accesses
+ // a number of blocks of memory, one or more
+ // for each thread that executes. Blocks
+ // are divided into sub-blocks called
+ // pages, and pages are divided into
+ // sub-blocks called cache lines.
+ //
+ // All pages are collected into a list.
+ // Pages are selected for the list in
+ // a particular order. Each cache line
+ // within the page is similarly gathered
+ // into a list in a particular order.
+ // In both cases the order may be random
+ // or linear.
+ //
+ // A root pointer points to the first
+ // cache line. A pointer in the cache
+ // line points to the next cache line,
+ // which contains a pointer to the cache
+ // line after that, and so on. This
+ // forms a pointer chain that touches all
+ // cache lines within the first page,
+ // then all cache lines within the second
+ // page, and so on until all pages are
+ // covered. The last pointer contains
+ // NULL, terminating the chain.
+ //
+ // Depending on compile-time options,
+ // pointers may be 32-bit or 64-bit
+ // pointers.
+
+int verbose = 0;
+
+int
+main( int argc, char* argv[] )
+{
+ Timer::calibrate(10000);
+ double clk_res = Timer::resolution();
+
+ Experiment e;
+ if (e.parse_args(argc, argv)) {
+ return 0;
+ }
+
+#if defined(UNDEFINED)
+ e.print();
+ if (argv != NULL) return 0;
+#endif
+
+ SpinBarrier sb( e.num_threads );
+ Run r[ e.num_threads ];
+ for (int i=0; i < e.num_threads; i++) {
+ r[i].set( e, &sb );
+ r[i].start();
+ }
+
+ for (int i=0; i < e.num_threads; i++) {
+ r[i].wait();
+ }
+
+ int64 ops = Run::ops_per_chain();
+ double secs = Run::seconds();
+
+ Output::print(e, ops, secs, clk_res);
+
+ return 0;
+}
diff --git a/Main.C b/src/Main.cpp
index ebd276a..ebd276a 100644
--- a/Main.C
+++ b/src/Main.cpp
diff --git a/Main.h b/src/Main.h
index 1492291..1492291 100644
--- a/Main.h
+++ b/src/Main.h
diff --git a/Output.C b/src/Output.cpp
index 9f9c09a..9f9c09a 100644
--- a/Output.C
+++ b/src/Output.cpp
diff --git a/Output.h b/src/Output.h
index 9ee2c80..9ee2c80 100644
--- a/Output.h
+++ b/src/Output.h
diff --git a/Run.C b/src/Run.cpp
index 4fb8057..4fb8057 100644
--- a/Run.C
+++ b/src/Run.cpp
diff --git a/Run.h b/src/Run.h
index 810c2e8..810c2e8 100644
--- a/Run.h
+++ b/src/Run.h
diff --git a/SpinBarrier.C b/src/SpinBarrier.cpp
index d3d2d7b..d3d2d7b 100644
--- a/SpinBarrier.C
+++ b/src/SpinBarrier.cpp
diff --git a/SpinBarrier.h b/src/SpinBarrier.h
index f0b76d3..f0b76d3 100644
--- a/SpinBarrier.h
+++ b/src/SpinBarrier.h
diff --git a/Thread.C b/src/Thread.cpp
index 8908cfe..8908cfe 100644
--- a/Thread.C
+++ b/src/Thread.cpp
diff --git a/Thread.h b/src/Thread.h
index 3948f56..3948f56 100644
--- a/Thread.h
+++ b/src/Thread.h
diff --git a/Timer.C b/src/Timer.cpp
index b326048..b326048 100644
--- a/Timer.C
+++ b/src/Timer.cpp
diff --git a/Timer.h b/src/Timer.h
index ba2c503..ba2c503 100644
--- a/Timer.h
+++ b/src/Timer.h
diff --git a/Types.C b/src/Types.cpp
index da5ecd0..da5ecd0 100644
--- a/Types.C
+++ b/src/Types.cpp
diff --git a/Types.h b/src/Types.h
index 9e2eeb0..9e2eeb0 100644
--- a/Types.h
+++ b/src/Types.h