summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2023-06-07 14:56:05 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2023-06-07 14:56:05 +0200
commit3884cdaff9c0fbd149931f3e4ddf28e4624652e4 (patch)
treeeef42d68efbb297f4da01d3901b2c613b60b908b
parent0118d5173e849135527bba960139213f09d4b19c (diff)
port cpu-dpu microbenchmark to dfatool
-rw-r--r--Microbenchmarks/CPU-DPU/Makefile46
-rw-r--r--Microbenchmarks/CPU-DPU/host/app.c50
-rwxr-xr-xMicrobenchmarks/CPU-DPU/run.sh22
3 files changed, 65 insertions, 53 deletions
diff --git a/Microbenchmarks/CPU-DPU/Makefile b/Microbenchmarks/CPU-DPU/Makefile
index 09d613a..f552a6d 100644
--- a/Microbenchmarks/CPU-DPU/Makefile
+++ b/Microbenchmarks/CPU-DPU/Makefile
@@ -1,45 +1,37 @@
-DPU_DIR := dpu
-HOST_DIR := host
-BUILDDIR ?= bin
NR_TASKLETS ?= 16
BL ?= 8
NR_DPUS ?= 1
TRANSFER ?= PUSH
-define conf_filename
- ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2)_BL_$(3)_TRANSFER_$(4).conf
-endef
-CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS},${BL},${TRANSFER})
-
-HOST_TARGET := ${BUILDDIR}/host_code
-DPU_TARGET := ${BUILDDIR}/dpu_code
-
COMMON_INCLUDES := support
-HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c)
-DPU_SOURCES := $(wildcard ${DPU_DIR}/*.c)
-
-.PHONY: all clean test
-
-__dirs := $(shell mkdir -p ${BUILDDIR})
+HOST_SOURCES := $(wildcard host/*.c)
+DPU_SOURCES := $(wildcard dpu/*.c)
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${TRANSFER}
DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -D${TRANSFER}
-all: ${HOST_TARGET} ${DPU_TARGET}
+QUIET = @
-${CONF}:
- $(RM) $(call conf_filename,*,*)
- touch ${CONF}
+ifdef verbose
+ QUIET =
+endif
-${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF}
- $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS}
+all: bin/host_code bin/dpu_code
-${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF}
- dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES}
+bin:
+ ${QUIET}mkdir -p bin
+
+bin/host_code: ${HOST_SOURCES} ${COMMON_INCLUDES} bin
+ ${QUIET}${CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS}
+
+bin/dpu_code: ${DPU_SOURCES} ${COMMON_INCLUDES} bin
+ ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES}
clean:
- $(RM) -r $(BUILDDIR)
+ ${QUIET}rm -rf bin
test: all
- ./${HOST_TARGET}
+ ${QUIET}bin/host_code
+
+.PHONY: all clean test
diff --git a/Microbenchmarks/CPU-DPU/host/app.c b/Microbenchmarks/CPU-DPU/host/app.c
index 6b8ab53..88148a1 100644
--- a/Microbenchmarks/CPU-DPU/host/app.c
+++ b/Microbenchmarks/CPU-DPU/host/app.c
@@ -22,16 +22,29 @@
#define DPU_BINARY "./bin/dpu_code"
#endif
+#define XSTR(x) STR(x)
+#define STR(x) #x
+
// Pointer declaration
static T* A;
static T* B;
static T* C;
static T* C2;
+static const char transfer_mode[] =
+#if SERIAL
+"SERIAL"
+#elif BROADCAST
+"BROADCAST"
+#else
+"PUSH"
+#endif
+;
+
// Create input arrays
static void read_input(T* A, T* B, unsigned int nr_elements) {
srand(0);
- printf("nr_elements\t%u\t", nr_elements);
+ //printf("nr_elements\t%u\t", nr_elements);
for (unsigned int i = 0; i < nr_elements; i++) {
A[i] = (T) (rand());
B[i] = A[i];
@@ -50,7 +63,7 @@ int main(int argc, char **argv) {
DPU_ASSERT(dpu_alloc(NR_DPUS, "nrThreadPerPool=8", &dpu_set));
DPU_ASSERT(dpu_load(dpu_set, DPU_BINARY, NULL));
DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &nr_of_dpus));
- printf("Allocated %d DPU(s)\n", nr_of_dpus);
+ //printf("Allocated %d DPU(s)\n", nr_of_dpus);
unsigned int i = 0;
unsigned int input_size = p.exp == 0 ? p.input_size * nr_of_dpus : p.input_size;
@@ -69,17 +82,22 @@ int main(int argc, char **argv) {
// Timer declaration
Timer timer;
- printf("NR_TASKLETS\t%d\tBL\t%d\n", NR_TASKLETS, BL);
+ //printf("NR_TASKLETS\t%d\tBL\t%d\n", NR_TASKLETS, BL);
// Loop over main kernel
for(int rep = 0; rep < p.n_warmup + p.n_reps; rep++) {
- printf("Load input data\n");
+ //printf("Load input data\n");
// Input arguments
const unsigned int input_size_dpu = input_size / nr_of_dpus;
+#ifdef BROADCAST
+ const unsigned int transfer_size = input_size_dpu;
+#else
+ const unsigned int transfer_size = input_size;
+#endif
// Copy input arrays
if(rep >= p.n_warmup)
- start(&timer, 1, rep - p.n_warmup);
+ start(&timer, 1, 0);
i = 0;
#ifdef SERIAL
DPU_FOREACH (dpu_set, dpu) {
@@ -97,10 +115,10 @@ int main(int argc, char **argv) {
if(rep >= p.n_warmup)
stop(&timer, 1);
- printf("Run program on DPU(s) \n");
+ //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);
@@ -117,9 +135,9 @@ int main(int argc, char **argv) {
}
#endif
- printf("Retrieve results\n");
+ //printf("Retrieve results\n");
if(rep >= p.n_warmup)
- start(&timer, 3, rep - p.n_warmup);
+ start(&timer, 3, 0);
i = 0;
#ifdef SERIAL
DPU_FOREACH (dpu_set, dpu) {
@@ -135,19 +153,29 @@ int main(int argc, char **argv) {
if(rep >= p.n_warmup)
stop(&timer, 3);
+ if (rep >= p.n_warmup) {
+ printf("[::] NMC transfer | n_dpus=%d n_tasklets=%d e_type=%s n_elements=%u e_mode=%s"
+ " | throughput_dram_mram_MBps=%f throughput_mram_dram_MBps=%f",
+ nr_of_dpus, NR_TASKLETS, XSTR(T), transfer_size, transfer_mode,
+ transfer_size * sizeof(T) / timer.time[1],
+ transfer_size * sizeof(T) / timer.time[3]);
+ printf(" throughput_dram_mram_MOpps=%f throughput_mram_dram_MOpps=%f\n",
+ transfer_size / timer.time[1],
+ transfer_size / timer.time[3]);
+ }
}
// Print timing results
printf("CPU-DPU ");
print(&timer, 1, p.n_reps);
- double time_load = timer.time[1] / (1000 * p.n_reps);
+ double time_load = timer.time[1] / (1000 * 1);
printf("CPU-DPU Bandwidth (GB/s): %f\n", (input_size * 8)/(time_load*1e6));
printf("DPU Kernel ");
print(&timer, 2, p.n_reps);
printf("\n");
printf("DPU-CPU ");
print(&timer, 3, p.n_reps);
- double time_retrieve = timer.time[3] / (1000 * p.n_reps);
+ double time_retrieve = timer.time[3] / (1000 * 1);
printf("DPU-CPU Bandwidth (GB/s): %f\n", (input_size * 8)/(time_retrieve*1e6));
// Check output
diff --git a/Microbenchmarks/CPU-DPU/run.sh b/Microbenchmarks/CPU-DPU/run.sh
index 0132cb1..48261ec 100755
--- a/Microbenchmarks/CPU-DPU/run.sh
+++ b/Microbenchmarks/CPU-DPU/run.sh
@@ -1,22 +1,14 @@
#!/bin/bash
-mkdir -p profile
set -e
-for i in 1 2 4 8 16 32 64
-do
- for j in 1
- do
- for k in SERIAL PUSH BROADCAST
- do
- for l in 1 4 16 64 256 1024 4096 16384 65536 262144 1048576 4194304
- do
- NR_DPUS=$i NR_TASKLETS=$j BL=10 TRANSFER=$k make all
- wait
- ./bin/host_code -w 5 -e 20 -i ${l} >& profile/${i}_tl${j}_TR${k}_i${l}.txt
- wait
- make clean
- wait
+for i in 1 2 4 8 16 32 64; do
+ for j in 1; do
+ for k in SERIAL PUSH BROADCAST; do
+ # 8 B ... 64 MB
+ for l in 1 4 16 64 256 1024 4096 16384 65536 262144 1048576 4194304 838868; do
+ make -B NR_DPUS=$i NR_TASKLETS=$j BL=10 TRANSFER=$k
+ bin/host_code -w 0 -e 50 -i $l
done
done
done