From 0f710b4f47dfc51e3f01473995dbb6ed5844eff1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 31 May 2023 16:12:59 +0200 Subject: port UNI to dfatool --- UNI/Makefile | 46 ++++++++++++--------------- UNI/baselines/cpu/Makefile | 6 ++-- UNI/baselines/cpu/app_baseline.c | 14 +++------ UNI/baselines/cpu/run-opti.sh | 11 +++++++ UNI/baselines/cpu/run.sh | 11 +++++-- UNI/host/app.c | 67 +++++++++++++++++++++++++--------------- UNI/run-paper-strong-full.sh | 22 +++++++++++++ UNI/run-paper-strong-rank.sh | 26 ++++++++++++++++ UNI/run-paper-weak.sh | 22 +++++++++++++ 9 files changed, 160 insertions(+), 65 deletions(-) create mode 100755 UNI/baselines/cpu/run-opti.sh create mode 100755 UNI/run-paper-strong-full.sh create mode 100755 UNI/run-paper-strong-rank.sh create mode 100755 UNI/run-paper-weak.sh diff --git a/UNI/Makefile b/UNI/Makefile index 65c7962..f9cdf0b 100644 --- a/UNI/Makefile +++ b/UNI/Makefile @@ -1,45 +1,37 @@ -DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin NR_TASKLETS ?= 16 BL ?= 10 NR_DPUS ?= 1 ENERGY ?= 0 -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}/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} -DENERGY=${ENERGY} DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -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} + bin/host_code + +.PHONY: all clean test diff --git a/UNI/baselines/cpu/Makefile b/UNI/baselines/cpu/Makefile index 10e4f9b..ec3f403 100644 --- a/UNI/baselines/cpu/Makefile +++ b/UNI/baselines/cpu/Makefile @@ -16,13 +16,15 @@ uni_O2: app_baseline.c run: uni ./uni -i 1258291200 -t 4 +# -e 20 was not part of the upstream instructions + .PHONY: run_O0 run_O0: uni_O0 - ./uni_O0 -i 1258291200 -t 4 + ./uni_O0 -i 1258291200 -t 4 -e 20 .PHONY: run_O2 run_O2: uni_O2 - ./uni_O2 -i 1258291200 -t 4 + ./uni_O2 -i 1258291200 -t 4 -e 20 .PHONY: clean clean: diff --git a/UNI/baselines/cpu/app_baseline.c b/UNI/baselines/cpu/app_baseline.c index 39f225a..f4f303f 100644 --- a/UNI/baselines/cpu/app_baseline.c +++ b/UNI/baselines/cpu/app_baseline.c @@ -32,7 +32,7 @@ static T *create_test_file(unsigned int nr_elements) { B = (T*) malloc(nr_elements * sizeof(T)); C = (T*) malloc(nr_elements * sizeof(T)); - printf("nr_elements\t%u\t", nr_elements); + //printf("nr_elements\t%u\t", nr_elements); for (int i = 0; i < nr_elements; i++) { //A[i] = (unsigned int) (rand()); //A[i] = i+1; @@ -141,16 +141,12 @@ int main(int argc, char **argv) { nr_threads++; if (rep >= p.n_warmup) { - printf("[::] n_threads=%d e_type=%s n_elements=%d " - "| throughput_cpu_MBps=%f\n", - nr_threads, XSTR(T), file_size, - file_size * 2 * sizeof(T) / timer.time[0]); - printf("[::] n_threads=%d e_type=%s n_elements=%d " - "| throughput_cpu_MOpps=%f\n", + printf("[::] UNI CPU | n_threads=%d e_type=%s n_elements=%d " + "| throughput_MBps=%f", nr_threads, XSTR(T), file_size, + file_size * sizeof(T) / timer.time[0]); + printf(" throughput_MOpps=%f", file_size / timer.time[0]); - printf("[::] n_threads=%d e_type=%s n_elements=%d | ", - nr_threads, XSTR(T), file_size); printall(&timer, 0); } } diff --git a/UNI/baselines/cpu/run-opti.sh b/UNI/baselines/cpu/run-opti.sh new file mode 100755 index 0000000..0a3a4a3 --- /dev/null +++ b/UNI/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/UNI/baselines/cpu/run.sh b/UNI/baselines/cpu/run.sh index 3c99ad2..37a6a9c 100755 --- a/UNI/baselines/cpu/run.sh +++ b/UNI/baselines/cpu/run.sh @@ -2,16 +2,23 @@ set -e +HOST="$(hostname)" + +echo $HOST + +( + echo "prim-benchmarks UNI CPU (dfatool edition)" echo "Started at $(date)" echo "Revision $(git describe --always)" -for nr_threads in 1 2 4 6 8 12 16 20 24 32; do +for nr_threads in 88 64 44 1 2 4 6 8 12 16 20 24 32; do for i in 19660800 1258291200 629145600 314572800 157286400 78643200 39321600; do for dt in int8_t int16_t int32_t int64_t float double; do if make -B TYPE=${dt}; then - timeout -k 1m 30m ./uni -i ${i} -w 0 -e 100 -t ${nr_threads} || true + timeout --foreground -k 1m 60m ./uni -i ${i} -w 0 -e 100 -t ${nr_threads} || true fi done done done +) | tee "${HOST}-explore.txt" diff --git a/UNI/host/app.c b/UNI/host/app.c index 1b91bba..e068d6b 100644 --- a/UNI/host/app.c +++ b/UNI/host/app.c @@ -22,6 +22,9 @@ #define DPU_BINARY "./bin/dpu_code" #endif +#define XSTR(x) STR(x) +#define STR(x) #x + #if ENERGY #include #endif @@ -106,14 +109,14 @@ 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); total_count = unique_host(C, A, input_size); if(rep >= p.n_warmup) stop(&timer, 0); 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_dpu_round; unsigned int kernel = 0; @@ -134,7 +137,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); #if ENERGY DPU_ASSERT(dpu_probe_start(&probe)); #endif @@ -168,7 +171,7 @@ int main(int argc, char **argv) { accum = 0; if(rep >= p.n_warmup) - start(&timer, 3, rep - p.n_warmup); + start(&timer, 3, 0); // PARALLEL RETRIEVE TRANSFER dpu_results_t* results_retrieve[nr_of_dpus]; @@ -212,7 +215,7 @@ int main(int argc, char **argv) { i = 0; if(rep >= p.n_warmup) - start(&timer, 4, rep - p.n_warmup); + start(&timer, 4, 0); DPU_FOREACH (dpu_set, dpu) { // Copy output array DPU_ASSERT(dpu_copy_from(dpu, DPU_MRAM_HEAP_POINTER_NAME, input_size_dpu * sizeof(T), bufferC + results_scan[i] - offset_scan[i], results[i].t_count * sizeof(T))); @@ -227,6 +230,39 @@ int main(int argc, char **argv) { free(offset); free(offset_scan); + // Check output + bool status = true; + if(accum != total_count) status = false; +#if PRINT + printf("accum %u, total_count %u\n", accum, total_count); +#endif + for (i = 0; i < accum; i++) { + if(C[i] != bufferC[i]){ + status = false; +#if PRINT + printf("%d: %lu -- %lu\n", i, C[i], bufferC[i]); +#endif + } + } + if (status) { + printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); + if (rep >= p.n_warmup) { + printf("[::] UNI NMC | n_dpus=%d n_tasklets=%d e_type=%s block_size_B=%d n_elements=%d " + "| throughput_cpu_MBps=%f throughput_pim_MBps=%f throughput_MBps=%f", + nr_of_dpus, NR_TASKLETS, XSTR(T), BLOCK_SIZE, input_size, + 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] + timer.time[4])); + printf(" throughput_cpu_MOpps=%f throughput_pim_MOpps=%f throughput_MOpps=%f", + input_size / timer.time[0], + input_size / timer.time[2], + input_size / (timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4])); + printall(&timer, 4); + } + } else { + printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n"); + } + } // Print timing results @@ -247,25 +283,6 @@ int main(int argc, char **argv) { printf("DPU Energy (J): %f\t", energy); #endif - // Check output - bool status = true; - if(accum != total_count) status = false; -#if PRINT - printf("accum %u, total_count %u\n", accum, total_count); -#endif - for (i = 0; i < accum; i++) { - if(C[i] != bufferC[i]){ - status = false; -#if PRINT - printf("%d: %lu -- %lu\n", i, C[i], bufferC[i]); -#endif - } - } - 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); @@ -273,5 +290,5 @@ int main(int argc, char **argv) { free(C2); DPU_ASSERT(dpu_free(dpu_set)); - return status ? 0 : -1; + return 0; } diff --git a/UNI/run-paper-strong-full.sh b/UNI/run-paper-strong-full.sh new file mode 100755 index 0000000..9e5ac97 --- /dev/null +++ b/UNI/run-paper-strong-full.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 UNI strong-full (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for nr_dpus in 256 512 1024 2048; do + for nr_tasklets in 1 2 4 8 16; do + echo + if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10; then + timeout --foreground -k 1m 30m bin/host_code -w 0 -e 100 -i 251658240 -x 1 || true + fi + done +done | tee log-paper-strong-full.txt diff --git a/UNI/run-paper-strong-rank.sh b/UNI/run-paper-strong-rank.sh new file mode 100755 index 0000000..6cffd65 --- /dev/null +++ b/UNI/run-paper-strong-rank.sh @@ -0,0 +1,26 @@ +#!/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 UNI strong-rank (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +# 256 and 512 are not part of upstream config space +for nr_dpus in 512 256 1 4 16 64; do + for nr_tasklets in 1 2 4 8 16; do + echo + if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10; then + timeout --foreground -k 1m 30m bin/host_code -w 0 -e 100 -i 3932160 -x 1 || true + fi + done +done +) | tee log-paper-strong-rank.txt diff --git a/UNI/run-paper-weak.sh b/UNI/run-paper-weak.sh new file mode 100755 index 0000000..e9b5e04 --- /dev/null +++ b/UNI/run-paper-weak.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 UNI weak (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for nr_dpus in 1 4 16 64; do + for nr_tasklets in 1 2 4 8 16; do + echo + if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=10; then + timeout --foreground -k 1m 30m bin/host_code -w 0 -e 100 -i 3932160 -x 0 || true + fi + done +done | tee log-paper-weak.txt -- cgit v1.2.3