diff options
-rw-r--r-- | GEMV/Makefile | 44 | ||||
-rw-r--r-- | GEMV/host/app.c | 81 | ||||
-rwxr-xr-x | GEMV/run.sh | 26 |
3 files changed, 94 insertions, 57 deletions
diff --git a/GEMV/Makefile b/GEMV/Makefile index fbba9b8..25174d3 100644 --- a/GEMV/Makefile +++ b/GEMV/Makefile @@ -1,44 +1,36 @@ -DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin +NR_DPUS ?= 1 NR_TASKLETS ?= 16 BL ?= 10 -NR_DPUS ?= 1 - -define conf_filename - ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2)_BL_$(3).conf -endef -CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS},${BL}) - -HOST_TARGET := ${BUILDDIR}/gemv_host -DPU_TARGET := ${BUILDDIR}/gemv_dpu COMMON_INCLUDES := support -HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c) -DPU_SOURCES := $(wildcard ${DPU_DIR}/*.c) +HOST_SOURCES := $(wildcard host/*.c) +DPU_SOURCES := $(wildcard dpu/*.c) .PHONY: all clean test -__dirs := $(shell mkdir -p ${BUILDDIR}) - 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} DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -all: ${HOST_TARGET} ${DPU_TARGET} +QUIET = @ + +ifdef verbose + QUIET = +endif + +all: bin/gemv_host bin/gemv_dpu -${CONF}: - $(RM) $(call conf_filename,*,*) - touch ${CONF} +bin: + ${QUIET}mkdir -p bin -${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF} - $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS} +bin/gemv_host: ${HOST_SOURCES} ${COMMON_INCLUDES} bin + ${QUIET}${CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS} -${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF} - dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} +bin/gemv_dpu: ${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} -m 1024 -n 1024 + bin/gemv_host -m 1024 -n 1024 diff --git a/GEMV/host/app.c b/GEMV/host/app.c index de2e847..daf4427 100644 --- a/GEMV/host/app.c +++ b/GEMV/host/app.c @@ -18,6 +18,9 @@ #include <dpu_probe.h> #endif +#define XSTR(x) STR(x) +#define STR(x) #x + #include "../support/common.h" #include "../support/timer.h" #include "../support/params.h" @@ -140,15 +143,12 @@ int main(int argc, char **argv) { Timer timer; // Compute output on CPU (performance comparison and verification purposes) - start(&timer, 0, 0); - gemv_host(C, A, B, m_size, n_size); - stop(&timer, 0); for (unsigned int rep = 0; rep < p.n_warmup + p.n_reps; rep++) { - - - + start(&timer, 0, 0); + gemv_host(C, A, B, m_size, n_size); + stop(&timer, 0); if (rep >= p.n_warmup) - start(&timer, 1, rep - p.n_warmup); + start(&timer, 1, 0); // Input arguments i = 0; DPU_FOREACH(dpu_set, dpu, i) { @@ -177,7 +177,7 @@ int main(int argc, char **argv) { // Run kernel on DPUs if (rep >= p.n_warmup) { - start(&timer, 2, rep - p.n_warmup); + start(&timer, 2, 0); #if ENERGY DPU_ASSERT(dpu_probe_start(&probe)); #endif @@ -202,7 +202,7 @@ int main(int argc, char **argv) { // Retrieve results C_dpu = malloc(max_rows_per_dpu * nr_of_dpus * sizeof(T)); if (rep >= p.n_warmup) - start(&timer, 3, rep - p.n_warmup); + start(&timer, 3, 0); i = 0; DPU_FOREACH(dpu_set, dpu, i) { DPU_ASSERT(dpu_prepare_xfer(dpu, C_dpu + i * max_rows_per_dpu)); @@ -210,6 +210,46 @@ int main(int argc, char **argv) { DPU_ASSERT(dpu_push_xfer(dpu_set, DPU_XFER_FROM_DPU, DPU_MRAM_HEAP_POINTER_NAME, max_rows_per_dpu * n_size_pad * sizeof(T) + n_size_pad * sizeof(T), max_rows_per_dpu * sizeof(T), DPU_XFER_DEFAULT)); if(rep >= p.n_warmup) stop(&timer, 3); + + + // Check output + bool status = true; + unsigned int n,j; + i = 0; + for (n = 0; n < nr_of_dpus; n++) { + for (j = 0; j < dpu_info[n].rows_per_dpu; j++) { + if(C[i] != C_dpu[n * max_rows_per_dpu + j]) { + status = false; +#if PRINT + // printf("%d: %d -- %d\n", i, C[i], C_dpu[n * max_rows_per_dpu + j]); +#endif + } + i++; + } + } + if (status) { + printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); + if (rep >= p.n_warmup) { + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%d " + "| throughput_cpu_MBps=%f throughput_pim_MBps=%f throughput_MBps=%f\n", + nr_of_dpus, NR_TASKLETS, XSTR(T), n_size * m_size, + n_size * m_size * sizeof(T) / timer.time[0], + n_size * m_size * sizeof(T) / timer.time[2], + n_size * m_size * sizeof(T) / (timer.time[1] + timer.time[2] + timer.time[3])); + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%d " + "| throughput_cpu_MOpps=%f throughput_pim_MOpps=%f throughput_MOpps=%f\n", + nr_of_dpus, NR_TASKLETS, XSTR(T), n_size * m_size, + n_size * m_size / timer.time[0], + n_size * m_size / timer.time[2], + n_size * m_size / (timer.time[1] + timer.time[2] + timer.time[3])); + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%d |", + nr_of_dpus, NR_TASKLETS, XSTR(T), n_size * m_size); + printall(&timer, 3); + } + } else { + printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n"); + } + } #if ENERGY double acc_energy, avg_energy, acc_time, avg_time; @@ -233,27 +273,6 @@ int main(int argc, char **argv) { printf("Energy (J): %f J\t", avg_energy); #endif - // Check output - bool status = true; - unsigned int n,j; - i = 0; - for (n = 0; n < nr_of_dpus; n++) { - for (j = 0; j < dpu_info[n].rows_per_dpu; j++) { - if(C[i] != C_dpu[n * max_rows_per_dpu + j]) { - status = false; -#if PRINT - // printf("%d: %d -- %d\n", i, C[i], C_dpu[n * max_rows_per_dpu + j]); -#endif - } - i++; - } - } - if (status) { - printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); - } else { - printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n"); - } - // Deallocation free(A); free(B); @@ -265,5 +284,5 @@ int main(int argc, char **argv) { DPU_ASSERT(dpu_probe_deinit(&probe)); #endif - return status ? 0 : -1; + return 0; } diff --git a/GEMV/run.sh b/GEMV/run.sh new file mode 100755 index 0000000..2f61ef2 --- /dev/null +++ b/GEMV/run.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +# BL: use 2^(BL) B blocks for MRAM <-> WRAM transfers on PIM module +# -w: number of un-timed warmup iterations +# -e: number of timed iterations +# -m: number of rows +# -n: number of cols + +echo "prim-benchmarks VA (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for n in 512 1024 2048 4096; do + for m in 512 1024 2048 4096; 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 + echo + if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10; then + timeout --foreground -k 1m 30m bin/gemv_host -w 0 -e 100 -m $m -n $n || true + fi + done + done + done +done |