diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2023-12-12 18:17:19 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2023-12-12 18:17:19 +0100 |
commit | eb118b2f743656434c0c77e5318eeacc38bd9924 (patch) | |
tree | 0d97d59c59c45e9cd8057e805552cd8bb4635494 | |
parent | f1fbecc7a02aafdba953479f5c91f09c4a195484 (diff) |
WRAM WiP
-rw-r--r-- | Microbenchmarks/WRAM/Makefile | 44 | ||||
-rw-r--r-- | Microbenchmarks/WRAM/host/app.c | 32 | ||||
-rwxr-xr-x | Microbenchmarks/WRAM/run-transfer.sh | 43 |
3 files changed, 78 insertions, 41 deletions
diff --git a/Microbenchmarks/WRAM/Makefile b/Microbenchmarks/WRAM/Makefile index f824e41..24817fb 100644 --- a/Microbenchmarks/WRAM/Makefile +++ b/Microbenchmarks/WRAM/Makefile @@ -1,6 +1,4 @@ DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin NR_TASKLETS ?= 16 BL ?= 10 NR_DPUS ?= 1 @@ -8,40 +6,34 @@ OP ?= streaming MEM ?= WRAM TYPE ?= INT64 -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}) - -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) 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} -D${TYPE} DPU_FLAGS := ${COMMON_FLAGS} -O2 -flto -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -D${OP} -D${MEM} -D${TYPE} -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/task.c ${COMMON_INCLUDES} bin + ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ dpu/task.c clean: - $(RM) -r $(BUILDDIR) + ${QUIET}rm -rf bin test: all - ./${HOST_TARGET} + ${QUIET}bin/host_code + +.PHONY: all clean test diff --git a/Microbenchmarks/WRAM/host/app.c b/Microbenchmarks/WRAM/host/app.c index a0131da..65193fc 100644 --- a/Microbenchmarks/WRAM/host/app.c +++ b/Microbenchmarks/WRAM/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 unsigned int* A; static T* B; @@ -49,6 +52,14 @@ static void read_input(unsigned int* A, T* B, unsigned int nr_elements) { } } +#ifdef streaming +char transfer_mode[] = "streaming"; +#elif strided +char transfer_mode[] = "strided"; +#else +char transfer_mode[] = "random"; +#endif + // Compute output in the host static void copy_host(T* C, T* B, unsigned int* A, unsigned int nr_elements) { unsigned int wram_size = BLOCK_SIZE >> DIV; @@ -67,11 +78,13 @@ int main(int argc, char **argv) { struct dpu_set_t dpu_set, dpu; uint32_t nr_of_dpus; + uint32_t nr_of_ranks; // Allocate DPUs and load binary DPU_ASSERT(dpu_alloc(NR_DPUS, NULL, &dpu_set)); DPU_ASSERT(dpu_load(dpu_set, DPU_BINARY, NULL)); DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &nr_of_dpus)); + DPU_ASSERT(dpu_get_nr_ranks(dpu_set, &nr_of_ranks)); printf("Allocated %d DPU(s)\n", nr_of_dpus); unsigned int i = 0; @@ -165,6 +178,10 @@ int main(int argc, char **argv) { dpu_results_t result; result.cycles = 0; DPU_ASSERT(dpu_copy_from(dpu, "DPU_RESULTS", each_tasklet * sizeof(dpu_results_t), &result, sizeof(dpu_results_t))); + printf("[::] DMA UPMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_type=%s n_elements=%u e_mode=%s block_size_B=%d" + " | dpu_cycles=%lu\n", + nr_of_dpus, nr_of_ranks, NR_TASKLETS, XSTR(T), input_size_dpu, transfer_mode, BLOCK_SIZE, + result.cycles); if (result.cycles > results[i].cycles) results[i].cycles = result.cycles; } @@ -195,16 +212,6 @@ int main(int argc, char **argv) { } 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++) { @@ -215,11 +222,6 @@ int main(int argc, char **argv) { #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); diff --git a/Microbenchmarks/WRAM/run-transfer.sh b/Microbenchmarks/WRAM/run-transfer.sh new file mode 100755 index 0000000..7c4a179 --- /dev/null +++ b/Microbenchmarks/WRAM/run-transfer.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +( + +echo "prim-benchmarks WRAM microbenchmark (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for ndpu in 1 4 8 16; do + for ntask in 1 2 4 8 12 16 20; do + for bl in 4 5 6 7 8 9 10 11; do + for op in streaming strided random; do + if make -B NR_DPUS=$ndpu NR_TASKLETS=$ntask BL=$bl OP=$op; then + bin/host_code -w 0 -e 10 || true + fi + done + done + done +done +echo "Completed at $(date)" +) | tee "log-$(hostname)-wram-only.txt" + +( + +echo "prim-benchmarks WRAM microbenchmark (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for ndpu in 1 4 8 16; do + for ntask in 1 2 4 8 12 16 20; do + for bl in 4 5 6 7 8 9 10 11; do + for op in streaming strided random; do + if make -B NR_DPUS=$ndpu NR_TASKLETS=$ntask BL=$bl OP=$op MEM=MRAM; then + bin/host_code -w 0 -e 10 || true + fi + done + done + done +done +echo "Completed at $(date)" +) | tee "log-$(hostname)-wram-mram.txt" |