summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Microbenchmarks/STREAM/Makefile49
-rw-r--r--Microbenchmarks/STREAM/dpu/add.c8
-rw-r--r--Microbenchmarks/STREAM/dpu/copyw.c8
-rw-r--r--Microbenchmarks/STREAM/dpu/scale.c8
-rw-r--r--Microbenchmarks/STREAM/dpu/triad.c8
-rw-r--r--Microbenchmarks/STREAM/host/app.c64
-rwxr-xr-xMicrobenchmarks/STREAM/run.sh49
-rw-r--r--Microbenchmarks/STREAM/support/common.h2
-rw-r--r--Microbenchmarks/STREAM/support/params.h5
9 files changed, 107 insertions, 94 deletions
diff --git a/Microbenchmarks/STREAM/Makefile b/Microbenchmarks/STREAM/Makefile
index c669857..12fd65c 100644
--- a/Microbenchmarks/STREAM/Makefile
+++ b/Microbenchmarks/STREAM/Makefile
@@ -1,46 +1,31 @@
-DPU_DIR := dpu
-HOST_DIR := host
-BUILDDIR ?= bin
NR_TASKLETS ?= 16
BL ?= 10
NR_DPUS ?= 1
+T ?= uint64_t
OP ?= copy
MEM ?= MRAM
+UNROLL ?= 1
-define conf_filename
- ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2)_BL_$(3)_$(4)_$(5).conf
-endef
-CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS},${BL},${OP},${MEM})
+DPU_SOURCES = dpu/${OP}.c
+HOST_SOURCES = $(wildcard host/*.c)
-HOST_TARGET := ${BUILDDIR}/host_code
-DPU_TARGET := ${BUILDDIR}/dpu_code
+COMMON_INCLUDES = support
+COMMON_FLAGS = -Wall -Wextra -O2 -I${COMMON_INCLUDES} -DNR_DPUS=${NR_DPUS} -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -DT=${T} -D${OP} -D${MEM} -DUNROLL=${UNROLL}
+HOST_FLAGS = ${COMMON_FLAGS} -std=c11 `dpu-pkg-config --cflags --libs dpu`
+DPU_FLAGS = ${COMMON_FLAGS} -flto
-COMMON_INCLUDES := support
-HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c)
-DPU_SOURCES := $(wildcard ${DPU_DIR}/${OP}.c)
+all: bin/dpu_code bin/host_code
-.PHONY: all clean test
+bin:
+ mkdir -p bin
-__dirs := $(shell mkdir -p ${BUILDDIR})
+bin/dpu_code: ${DPU_SOURCES}
+ dpu-upmem-dpurte-clang ${DPU_FLAGS} ${DPU_SOURCES} -o $@
-COMMON_FLAGS := -Wall -Wextra -g -I${COMMON_INCLUDES}
-HOST_FLAGS := ${COMMON_FLAGS} -std=c11 -O3 `dpu-pkg-config --cflags --libs dpu` -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DBL=${BL} -D${OP} -D${MEM}
-DPU_FLAGS := ${COMMON_FLAGS} -O2 -flto -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -D${OP} -D${MEM}
-
-all: ${HOST_TARGET} ${DPU_TARGET}
-
-${CONF}:
- $(RM) $(call conf_filename,*,*)
- touch ${CONF}
-
-${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF}
- $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS}
-
-${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF}
- dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES}
+bin/host_code: ${HOST_SOURCES}
+ ${CC} ${HOST_FLAGS} ${HOST_SOURCES} -o $@
clean:
- $(RM) -r $(BUILDDIR)
+ ${RM} -f bin/dpu_code bin/host_code
-test: all
- ./${HOST_TARGET}
+.PHONY: all clean
diff --git a/Microbenchmarks/STREAM/dpu/add.c b/Microbenchmarks/STREAM/dpu/add.c
index faf6504..12854ee 100644
--- a/Microbenchmarks/STREAM/dpu/add.c
+++ b/Microbenchmarks/STREAM/dpu/add.c
@@ -18,12 +18,16 @@ __host dpu_results_t DPU_RESULTS[NR_TASKLETS];
// Add
static void add_dpu(T *bufferC, T *bufferA, T *bufferB) {
-
+#if UNROLL
#pragma unroll
for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
bufferC[i] = bufferA[i] + bufferB[i];
}
-
+#else
+ for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
+ bufferC[i] = bufferA[i] + bufferB[i];
+ }
+#endif
}
// Barrier
diff --git a/Microbenchmarks/STREAM/dpu/copyw.c b/Microbenchmarks/STREAM/dpu/copyw.c
index eff7a3b..66dd319 100644
--- a/Microbenchmarks/STREAM/dpu/copyw.c
+++ b/Microbenchmarks/STREAM/dpu/copyw.c
@@ -18,12 +18,16 @@ __host dpu_results_t DPU_RESULTS[NR_TASKLETS];
// Copy
static void copyw_dpu(T *bufferB, T *bufferA) {
-
+#if UNROLL
#pragma unroll
for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
bufferB[i] = bufferA[i];
}
-
+#else
+ for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
+ bufferB[i] = bufferA[i];
+ }
+#endif
}
// Barrier
diff --git a/Microbenchmarks/STREAM/dpu/scale.c b/Microbenchmarks/STREAM/dpu/scale.c
index 4247aac..53a70a2 100644
--- a/Microbenchmarks/STREAM/dpu/scale.c
+++ b/Microbenchmarks/STREAM/dpu/scale.c
@@ -18,12 +18,16 @@ __host dpu_results_t DPU_RESULTS[NR_TASKLETS];
// Scale
static void scale_dpu(T *bufferB, T *bufferA, T scalar) {
-
+#if UNROLL
#pragma unroll
for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
bufferB[i] = scalar * bufferA[i];
}
-
+#else
+ for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
+ bufferB[i] = scalar * bufferA[i];
+ }
+#endif
}
// Barrier
diff --git a/Microbenchmarks/STREAM/dpu/triad.c b/Microbenchmarks/STREAM/dpu/triad.c
index e81cb59..9e641ea 100644
--- a/Microbenchmarks/STREAM/dpu/triad.c
+++ b/Microbenchmarks/STREAM/dpu/triad.c
@@ -18,12 +18,16 @@ __host dpu_results_t DPU_RESULTS[NR_TASKLETS];
// Triad
static void triad_dpu(T *bufferC, T *bufferA, T *bufferB, T scalar) {
-
+#if UNROLL
#pragma unroll
for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
bufferC[i] = bufferA[i] + scalar * bufferB[i];
}
-
+#else
+ for (unsigned int i = 0; i < BLOCK_SIZE / sizeof(T); i++){
+ bufferC[i] = bufferA[i] + scalar * bufferB[i];
+ }
+#endif
}
// Barrier
diff --git a/Microbenchmarks/STREAM/host/app.c b/Microbenchmarks/STREAM/host/app.c
index 4571e96..6e0ac16 100644
--- a/Microbenchmarks/STREAM/host/app.c
+++ b/Microbenchmarks/STREAM/host/app.c
@@ -22,6 +22,9 @@
#define DPU_BINARY "./bin/dpu_code"
#endif
+#define XSTR(x) STR(x)
+#define STR(x) #x
+
// Pointer declaration
static T* A;
static T* B;
@@ -40,6 +43,27 @@ static void read_input(T* A, T* B, unsigned int nr_elements) {
}
}
+static char benchmark_name[] =
+#ifdef scale
+"SCALE"
+#elif add
+"ADD"
+#elif triad
+"TRIAD"
+#else
+"COPY"
+#endif
+;
+
+static char mem_name[] =
+#ifdef WRAM
+"WRAM"
+#endif
+#ifdef MRAM
+"MRAM"
+#endif
+;
+
// Compute output in the host
#if defined(add) || defined(triad)
static void stream_host(T* C, T* B, T* A, unsigned int nr_elements) {
@@ -76,7 +100,7 @@ int main(int argc, char **argv) {
unsigned int i = 0;
double cc = 0;
double cc_min = 0;
- const unsigned int input_size = p.exp == 0 ? p.input_size * nr_of_dpus : p.input_size;
+ const unsigned int input_size = p.input_size * nr_of_dpus;
// Input/output allocation
A = malloc(input_size * sizeof(T));
@@ -102,7 +126,7 @@ int main(int argc, char **argv) {
// Compute output on CPU (performance comparison and verification purposes)
if(rep >= p.n_warmup)
- start(&timer, 0, rep - p.n_warmup);
+ start(&timer, 0, 0);
#if defined(add) || defined(triad)
stream_host(C2, B, A, input_size);
#else
@@ -113,7 +137,7 @@ int main(int argc, char **argv) {
printf("Load input data\n");
if(rep >= p.n_warmup)
- start(&timer, 1, rep - p.n_warmup);
+ start(&timer, 1, 0);
// Input arguments
const unsigned int input_size_dpu = input_size / nr_of_dpus;
unsigned int kernel = 0;
@@ -134,7 +158,7 @@ int main(int argc, char **argv) {
printf("Run program on DPU(s) \n");
// Run DPU kernel
if(rep >= p.n_warmup)
- start(&timer, 2, rep - p.n_warmup);
+ start(&timer, 2, 0);
DPU_ASSERT(dpu_launch(dpu_set, DPU_SYNCHRONOUS));
if(rep >= p.n_warmup)
stop(&timer, 2);
@@ -153,7 +177,7 @@ int main(int argc, char **argv) {
printf("Retrieve results\n");
if(rep >= p.n_warmup)
- start(&timer, 3, rep - p.n_warmup);
+ start(&timer, 3, 0);
dpu_results_t results[nr_of_dpus];
i = 0;
DPU_FOREACH (dpu_set, dpu) {
@@ -198,19 +222,6 @@ int main(int argc, char **argv) {
}
#endif
- }
- printf("DPU cycles = %g cc\n", cc / p.n_reps);
-
- // Print timing results
- printf("CPU ");
- print(&timer, 0, p.n_reps);
- printf("CPU-DPU ");
- print(&timer, 1, p.n_reps);
- printf("DPU Kernel ");
- print(&timer, 2, p.n_reps);
- printf("DPU-CPU ");
- print(&timer, 3, p.n_reps);
-
// Check output
bool status = true;
for (i = 0; i < input_size; i++) {
@@ -231,10 +242,25 @@ int main(int argc, char **argv) {
}
if (status) {
printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n");
+ printf("[::] n_dpus=%d n_tasklets=%d e_benchmark=%-6s e_type=%s e_mem=%s b_unroll=%d | throughput_cpu_MBps=%f throughput_pim_MBps=%f throughput_MBps=%f \n", nr_of_dpus, NR_TASKLETS, benchmark_name, XSTR(T), mem_name, UNROLL, input_size * sizeof(T) / timer.time[0], input_size * sizeof(T) / timer.time[2], input_size * sizeof(T) / (timer.time[1] + timer.time[2] + timer.time[3]));
+ printf("[::] n_dpus=%d n_tasklets=%d e_benchmark=%-6s e_type=%s e_mem=%s b_unroll=%d | throughput_cpu_MOpps=%f throughput_pim_MOpps=%f throughput_MOpps=%f \n", nr_of_dpus, NR_TASKLETS, benchmark_name, XSTR(T), mem_name, UNROLL, input_size / timer.time[0], input_size / timer.time[2], input_size / (timer.time[1] + timer.time[2] + timer.time[3]));
} else {
printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n");
}
+ }
+ printf("DPU cycles = %g cc\n", cc / p.n_reps);
+
+ // Print timing results
+ printf("CPU ");
+ print(&timer, 0, p.n_reps);
+ printf("CPU-DPU ");
+ print(&timer, 1, p.n_reps);
+ printf("DPU Kernel ");
+ print(&timer, 2, p.n_reps);
+ printf("DPU-CPU ");
+ print(&timer, 3, p.n_reps);
+
// Deallocation
free(A);
free(B);
@@ -244,5 +270,5 @@ int main(int argc, char **argv) {
free(C2);
DPU_ASSERT(dpu_free(dpu_set));
- return status ? 0 : -1;
+ return 0;
}
diff --git a/Microbenchmarks/STREAM/run.sh b/Microbenchmarks/STREAM/run.sh
index 3ed965e..24b08df 100755
--- a/Microbenchmarks/STREAM/run.sh
+++ b/Microbenchmarks/STREAM/run.sh
@@ -1,38 +1,25 @@
#!/bin/bash
-mkdir -p profile
set -e
-# MRAM
-for i in copy copyw add scale triad
-do
- for j in 1
- do
- for k in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- do
- NR_DPUS=$j NR_TASKLETS=$k BL=10 MEM=MRAM OP=$i make all
- wait
- ./bin/host_code -w 0 -e 1 -i 2097152 >& profile/${i}_${j}_tl${k}_MRAM.txt
- wait
- make clean
- wait
- done
- done
-done
+# BL: use 2^(BL) B blocks for MRAM <-> WRAM transfers on PIM module
+# T: data type
+# -w: number of un-timed warmup iterations
+# -e: number of timed iterations
+# -i: input size (number of elements, not number of bytes!)
+# 2097152 B -> 2M is maximum for 64bit types (due to 16M per DPU)
-# WRAM
-for i in copyw add scale triad
-do
- for j in 1
- do
- for k in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- do
- NR_DPUS=$j NR_TASKLETS=$k BL=10 MEM=WRAM OP=$i make all
- wait
- ./bin/host_code -w 0 -e 1 -i 2097152 >& profile/${i}_${j}_tl${k}_WRAM.txt
- wait
- make clean
- wait
- done
+for mem in MRAM WRAM; do
+ for nr_dpus in 1 2 4 8 16 32 64 128 256 512; do
+ for nr_tasklets in 1 2 3 4 6 8 10 12 16 20 24; do
+ for op in copy copyw add scale triad; do
+ for dt in uint8_t uint16_t uint32_t uint64_t float double; do
+ if make -B MEM=${mem} OP=${op} NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10 T=${dt} UNROLL=1 \
+ || make -B MEM=${mem} OP=${op} NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10 T=${dt} UNROLL=0; then
+ bin/host_code -w 0 -e 20 -i 2097152
+ fi
+ done
+ done
+ done
done
done
diff --git a/Microbenchmarks/STREAM/support/common.h b/Microbenchmarks/STREAM/support/common.h
index 8e2e59b..7264fbd 100644
--- a/Microbenchmarks/STREAM/support/common.h
+++ b/Microbenchmarks/STREAM/support/common.h
@@ -25,7 +25,9 @@ typedef struct {
#endif
// Data type
+#ifndef T
#define T uint64_t
+#endif
#define PERF 1 // Use perfcounters?
#define PRINT 0
diff --git a/Microbenchmarks/STREAM/support/params.h b/Microbenchmarks/STREAM/support/params.h
index 4618411..d28ba65 100644
--- a/Microbenchmarks/STREAM/support/params.h
+++ b/Microbenchmarks/STREAM/support/params.h
@@ -7,7 +7,6 @@ typedef struct Params {
unsigned int input_size;
int n_warmup;
int n_reps;
- int exp;
}Params;
static void usage() {
@@ -30,10 +29,9 @@ struct Params input_params(int argc, char **argv) {
p.input_size = 8 << 10;
p.n_warmup = 1;
p.n_reps = 3;
- p.exp = 0;
int opt;
- while((opt = getopt(argc, argv, "hi:w:e:x:")) >= 0) {
+ while((opt = getopt(argc, argv, "hi:w:e:")) >= 0) {
switch(opt) {
case 'h':
usage();
@@ -42,7 +40,6 @@ struct Params input_params(int argc, char **argv) {
case 'i': p.input_size = atoi(optarg); break;
case 'w': p.n_warmup = atoi(optarg); break;
case 'e': p.n_reps = atoi(optarg); break;
- case 'x': p.exp = atoi(optarg); break;
default:
fprintf(stderr, "\nUnrecognized option!\n");
usage();