summaryrefslogtreecommitdiff
path: root/TRNS/baselines/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'TRNS/baselines/cpu')
-rw-r--r--TRNS/baselines/cpu/Makefile26
-rw-r--r--TRNS/baselines/cpu/main.cpp26
-rwxr-xr-xTRNS/baselines/cpu/run-opti.sh11
-rw-r--r--TRNS/baselines/cpu/support/timer.h7
4 files changed, 57 insertions, 13 deletions
diff --git a/TRNS/baselines/cpu/Makefile b/TRNS/baselines/cpu/Makefile
index cb2e264..781e2be 100644
--- a/TRNS/baselines/cpu/Makefile
+++ b/TRNS/baselines/cpu/Makefile
@@ -41,9 +41,29 @@ DEP=kernel.cpp kernel.h main.cpp support/common.h support/setup.h support/timer.
SRC=main.cpp kernel.cpp
EXE=trns
-all:
- $(CXX) $(CXX_FLAGS) $(SRC) $(LIB) -o $(EXE)
+all: trns
+
+trns: ${SRC}
+ $(CXX) -O2 $(CXX_FLAGS) $(SRC) $(LIB) -o $(EXE)
+
+trns_O0: ${SRC}
+ $(CXX) $(CXX_FLAGS) $(SRC) $(LIB) -o $(EXE)_O0
+
+trns_O2: ${SRC}
+ $(CXX) -O2 $(CXX_FLAGS) $(SRC) $(LIB) -o $(EXE)_O2
+
+run: trns
+ ./trns -w 0 -r 1 -m 16 -n 8 -o 4096 -p 2556
+
+# upstream uses -r 1
+
+run_O0: trns_O0
+ ./trns_O0 -w 0 -r 50 -m 16 -n 8 -o 4096 -p 2556
+
+run_O2: trns_O2
+ ./trns_O2 -w 0 -r 50 -m 16 -n 8 -o 4096 -p 2556
clean:
- rm -f $(EXE)
+ rm -f $(EXE) ${EXE}_O0 ${EXE}_O2
+.PHONY: all run run_O0 run_O2 clean
diff --git a/TRNS/baselines/cpu/main.cpp b/TRNS/baselines/cpu/main.cpp
index 2c3bdc3..2c481df 100644
--- a/TRNS/baselines/cpu/main.cpp
+++ b/TRNS/baselines/cpu/main.cpp
@@ -44,6 +44,9 @@
#include <string.h>
#include <assert.h>
+#define XSTR(x) STR(x)
+#define STR(x) #x
+
// Params ---------------------------------------------------------------------
struct Params {
@@ -138,7 +141,7 @@ int main(int argc, char **argv) {
T *h_in_backup = (T *)malloc(in_size * sizeof(T));
ALLOC_ERR(h_in_backup);
timer.stop("Allocation");
- timer.print("Allocation", 1);
+ //timer.print("Allocation", 1);
// Initialize
timer.start("Initialization");
@@ -147,7 +150,7 @@ int main(int argc, char **argv) {
for(int i = 0; i < N_; i++)
h_head[i].store(0);
timer.stop("Initialization");
- timer.print("Initialization", 1);
+ //timer.print("Initialization", 1);
memcpy(h_in_backup, h_in_out, in_size * sizeof(T)); // Backup for reuse across iterations
// Loop over main kernel
@@ -197,10 +200,21 @@ int main(int argc, char **argv) {
// end timer
if(rep >= p.n_warmup)
timer.stop("Step 3");
+
+ if (rep >= p.n_warmup) {
+ printf("[::] TRNS CPU | n_threads=%d e_type=%s n_elements=%d "
+ "| throughput_MBps=%f",
+ p.n_threads, XSTR(T), in_size,
+ in_size * sizeof(T) / (timer.get("Step 1") + timer.get("Step 2") + timer.get("Step 3")));
+ printf(" throughput_MOpps=%f",
+ in_size / (timer.get("Step 1") + timer.get("Step 2") + timer.get("Step 3")));
+ printf(" timer1_us=%f timer2_us=%f timer3_us=%f\n",
+ timer.get("Step 1"), timer.get("Step 2"), timer.get("Step 3"));
+ }
}
- timer.print("Step 1", p.n_reps);
- timer.print("Step 2", p.n_reps);
- timer.print("Step 3", p.n_reps);
+ //timer.print("Step 1", p.n_reps);
+ //timer.print("Step 2", p.n_reps);
+ //timer.print("Step 3", p.n_reps);
// Verify answer
//verify(h_in_out, h_in_backup, M_ * m, N_ * n, 1);
@@ -212,7 +226,7 @@ int main(int argc, char **argv) {
free(h_head);
free(h_in_backup);
timer.stop("Deallocation");
- timer.print("Deallocation", 1);
+ //timer.print("Deallocation", 1);
printf("Test Passed\n");
return 0;
diff --git a/TRNS/baselines/cpu/run-opti.sh b/TRNS/baselines/cpu/run-opti.sh
new file mode 100755
index 0000000..0a3a4a3
--- /dev/null
+++ b/TRNS/baselines/cpu/run-opti.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+HOST="$(hostname)"
+
+echo $HOST
+
+make clean
+
+make run_O0 | sed 's/CPU/CPU O0/' | tee "${HOST}-O0.txt"
+
+make run_O2 | sed 's/CPU/CPU O2/' | tee "${HOST}-O2.txt"
diff --git a/TRNS/baselines/cpu/support/timer.h b/TRNS/baselines/cpu/support/timer.h
index 70ee386..d8ef221 100644
--- a/TRNS/baselines/cpu/support/timer.h
+++ b/TRNS/baselines/cpu/support/timer.h
@@ -47,9 +47,7 @@ struct Timer {
map<string, double> time;
void start(string name) {
- if(!time.count(name)) {
- time[name] = 0.0;
- }
+ time[name] = 0.0;
gettimeofday(&startTime[name], NULL);
}
@@ -59,5 +57,6 @@ struct Timer {
(stopTime[name].tv_usec - startTime[name].tv_usec);
}
- void print(string name, int REP) { printf("%s Time (ms): %f\n", name.c_str(), time[name] / (1000 * REP)); }
+ void print(string name, int REP) { printf("%s Time (ms): %f\n", name.c_str(), time[name] / (1000 * REP)); }
+ double get(string name) { return time[name]; }
};