diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2023-05-25 15:56:34 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2023-05-25 15:56:34 +0200 |
commit | f800d7f49beb23e3692469b5d8dbbc9a2bb846da (patch) | |
tree | fd2d7cc9d63b4fe9240eae764f4fb916f723b60f /BS | |
parent | 9be82d39101398116c0974fd26a63956631df57b (diff) |
port BS NMC to dfatool
Diffstat (limited to 'BS')
-rw-r--r-- | BS/Makefile | 41 | ||||
-rw-r--r-- | BS/host/app.c | 71 | ||||
-rwxr-xr-x | BS/run.sh | 22 |
3 files changed, 89 insertions, 45 deletions
diff --git a/BS/Makefile b/BS/Makefile index 129ade1..99dd0f8 100644 --- a/BS/Makefile +++ b/BS/Makefile @@ -1,44 +1,39 @@ -DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin -NR_TASKLETS ?= 16 NR_DPUS ?= 1 -PROBLEM_SIZE ?= 2 - -define conf_filename - ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2).conf -endef -CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS}) +NR_TASKLETS ?= 16 +PROBLEM_SIZE ?= 8192 # original 2, wtf COMMON_INCLUDES := support -HOST_TARGET := ${BUILDDIR}/bs_host -DPU_TARGET := ${BUILDDIR}/bs_dpu +HOST_TARGET := bin/bs_host +DPU_TARGET := bin/bs_dpu -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} -DPROBLEM_SIZE=${PROBLEM_SIZE} DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} +QUIET = @ + +ifdef verbose + QUIET = +endif + all: ${HOST_TARGET} ${DPU_TARGET} -${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} + ${QUIET}${CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS} ${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF} - dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} + ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} clean: - $(RM) -r $(BUILDDIR) + ${QUIET}rm -rf bin test: all - ./${HOST_TARGET} -i 262144 + ${HOST_TARGET} -i 262144 diff --git a/BS/host/app.c b/BS/host/app.c index 3929877..85587ac 100644 --- a/BS/host/app.c +++ b/BS/host/app.c @@ -18,6 +18,9 @@ #include <dpu_probe.h> #endif +#define XSTR(x) STR(x) +#define STR(x) #x + #include "params.h" #include "timer.h" @@ -48,6 +51,7 @@ int64_t binarySearch(DTYPE * input, DTYPE * querys, DTYPE input_size, uint64_t n while (l <= r) { DTYPE m = l + (r - l) / 2; + // XXX shouldn't this short-circuit? // Check if x is present at mid if (input[m] == querys[q]) result = m; @@ -101,11 +105,6 @@ int main(int argc, char **argv) { // Create an input file with arbitrary data create_test_file(input, querys, input_size, num_querys); - // Compute host solution - start(&timer, 0, 0); - result_host = binarySearch(input, querys, input_size - 1, num_querys); - stop(&timer, 0); - // Create kernel arguments uint64_t slice_per_dpu = num_querys / nr_of_dpus; dpu_arguments_t input_arguments = {input_size, slice_per_dpu, 0}; @@ -114,8 +113,14 @@ int main(int argc, char **argv) { // Perform input transfers uint64_t i = 0; - if (rep >= p.n_warmup) - start(&timer, 1, rep - p.n_warmup); + // Compute host solution + start(&timer, 0, 0); + result_host = binarySearch(input, querys, input_size - 1, num_querys); + stop(&timer, 0); + + if (rep >= p.n_warmup) { + start(&timer, 1, 0); + } DPU_FOREACH(dpu_set, dpu, i) { @@ -142,13 +147,14 @@ int main(int argc, char **argv) { DPU_ASSERT(dpu_push_xfer(dpu_set, DPU_XFER_TO_DPU, DPU_MRAM_HEAP_POINTER_NAME, input_size * sizeof(DTYPE), slice_per_dpu * sizeof(DTYPE), DPU_XFER_DEFAULT)); - if (rep >= p.n_warmup) - stop(&timer, 1); + if (rep >= p.n_warmup) { + stop(&timer, 1); + } // 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 @@ -176,8 +182,9 @@ int main(int argc, char **argv) { #endif // Retrieve results - if (rep >= p.n_warmup) - start(&timer, 3, rep - p.n_warmup); + if (rep >= p.n_warmup) { + start(&timer, 3, 0); + } dpu_results_t* results_retrieve[nr_of_dpus]; i = 0; DPU_FOREACH(dpu_set, dpu, i) @@ -199,10 +206,36 @@ int main(int argc, char **argv) { } free(results_retrieve[i]); } - if(rep >= p.n_warmup) - stop(&timer, 3); + if(rep >= p.n_warmup) { + stop(&timer, 3); + } + + int status = (result_dpu == result_host); + if (status) { + printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] results are equal\n"); + if (rep >= p.n_warmup) { + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%lu " + "| throughput_cpu_MBps=%f throughput_pim_MBps=%f throughput_MBps=%f\n", + nr_of_dpus, NR_TASKLETS, XSTR(DTYPE), input_size, + num_querys * sizeof(DTYPE) / timer.time[0], + num_querys * sizeof(DTYPE) / timer.time[2], + num_querys * sizeof(DTYPE) / (timer.time[1] + timer.time[2] + timer.time[3])); + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%lu " + "| throughput_cpu_MOpps=%f throughput_pim_MOpps=%f throughput_MOpps=%f\n", + nr_of_dpus, NR_TASKLETS, XSTR(DTYPE), input_size, + num_querys / timer.time[0], + num_querys / timer.time[2], + num_querys / (timer.time[1] + timer.time[2] + timer.time[3])); + printf("[::] n_dpus=%d n_tasklets=%d e_type=%s n_elements=%lu |", + nr_of_dpus, NR_TASKLETS, XSTR(DTYPE), input_size); + printall(&timer, 3); + } + } else { + printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] results differ!\n"); + } } // Print timing results + /* printf("CPU Version Time (ms): "); print(&timer, 0, p.n_reps); printf("CPU-DPU Time (ms): "); @@ -211,6 +244,7 @@ int main(int argc, char **argv) { print(&timer, 2, p.n_reps); printf("DPU-CPU Time (ms): "); print(&timer, 3, p.n_reps); + */ #if ENERGY double energy; @@ -218,15 +252,8 @@ int main(int argc, char **argv) { printf("DPU Energy (J): %f\t", energy * num_iterations); #endif - int status = (result_dpu == result_host); - if (status) { - printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] results are equal\n"); - } else { - printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] results differ!\n"); - } - free(input); DPU_ASSERT(dpu_free(dpu_set)); - return status ? 0 : 1; + return 0; } diff --git a/BS/run.sh b/BS/run.sh new file mode 100755 index 0000000..cf32e4f --- /dev/null +++ b/BS/run.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# 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; ignored, always uses 262144 elements + +echo "prim-benchmarks VA (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +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/bs_host -w 0 -e 100 || true + fi + done +done |