diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-15 11:08:24 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-15 11:08:24 +0200 |
commit | 643e7dc59e8e0799f91ff74df56c52d7d4c10f12 (patch) | |
tree | 2553ba527ccd0a4dfd542cbb45f899298c8fc60d | |
parent | 665cc63e16a1a5ac083c3a2df38236ae58025b64 (diff) |
NW: AspectC++ support
-rw-r--r-- | NW/Makefile | 62 | ||||
-rw-r--r-- | NW/dpu/task.c | 2 | ||||
-rw-r--r-- | NW/host/app.c | 49 | ||||
-rw-r--r--[-rwxr-xr-x] | NW/include/common.h (renamed from NW/support/common.h) | 0 | ||||
-rw-r--r-- | NW/include/dfatool_host.ah | 30 | ||||
-rw-r--r-- | NW/include/params.h (renamed from NW/support/params.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | NW/include/timer.h (renamed from NW/support/timer.h) | 0 | ||||
-rw-r--r-- | README.md | 2 |
8 files changed, 87 insertions, 58 deletions
diff --git a/NW/Makefile b/NW/Makefile index 68f495a..30353c9 100644 --- a/NW/Makefile +++ b/NW/Makefile @@ -1,46 +1,56 @@ -DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin NR_TASKLETS ?= 13 BL ?= 1024 BL_IN ?= 4 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_SOURCES := $(wildcard host/*.c) +DPU_SOURCES := $(wildcard dpu/*.c) -HOST_TARGET := ${BUILDDIR}/nw_host -DPU_TARGET := ${BUILDDIR}/nw_dpu +aspectc ?= 0 +aspectc_timing ?= 0 -COMMON_INCLUDES := support -HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c) -DPU_SOURCES := $(wildcard ${DPU_DIR}/*.c) +HOST_CC := ${CC} -.PHONY: all clean test +COMMON_FLAGS := -Wall -Wextra -g -Iinclude -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DBL=${BL} +HOST_FLAGS := ${COMMON_FLAGS} -O3 `dpu-pkg-config --cflags --libs dpu` -DENERGY=${ENERGY} -DASPECTC=${aspectc} +DPU_FLAGS := ${COMMON_FLAGS} -O2 -DBL_IN=${BL_IN} + +ifeq (${aspectc_timing}, 1) + ASPECTC_HOST_FLAGS += -ainclude/dfatool_host_dpu.ah -ainclude/dfatool_host.ah +endif + +ASPECTC_HOST_FLAGS ?= -a0 -__dirs := $(shell mkdir -p ${BUILDDIR}) +ifeq (${aspectc}, 1) + HOST_CC = ag++ -r repo.acp -v 0 ${ASPECTC_HOST_FLAGS} --c_compiler ${UPMEM_HOME}/bin/clang++ -p . --Xcompiler +else + HOST_FLAGS += -std=c11 +endif -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} -DBL_IN=${BL_IN} +QUIET = @ -all: ${HOST_TARGET} ${DPU_TARGET} +ifdef verbose + QUIET = +endif -${CONF}: - $(RM) $(call conf_filename,*,*) - touch ${CONF} +all: bin/nw_host bin/nw_dpu -${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF} - $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS} +bin: + ${QUIET}mkdir -p bin -${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF} - dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} +bin/nw_host: ${HOST_SOURCES} include bin + ${QUIET}cp ../include/dfatool_host_dpu.ah include + ${QUIET}${HOST_CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS} + ${QUIET}rm -f include/dfatool_host_dpu.ah + +bin/nw_dpu: ${DPU_SOURCES} include bin + ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} clean: $(RM) -r $(BUILDDIR) test: all - ./${HOST_TARGET} + bin/nw_host + +.PHONY: all clean test diff --git a/NW/dpu/task.c b/NW/dpu/task.c index c022f70..fab163a 100644 --- a/NW/dpu/task.c +++ b/NW/dpu/task.c @@ -10,7 +10,7 @@ #include <perfcounter.h> #include <barrier.h> -#include "../support/common.h" +#include "common.h" __host dpu_arguments_t DPU_INPUT_ARGUMENTS; diff --git a/NW/host/app.c b/NW/host/app.c index 0e899ec..9de2918 100644 --- a/NW/host/app.c +++ b/NW/host/app.c @@ -7,20 +7,30 @@ #include <stdlib.h> #include <stdbool.h> #include <string.h> + +#if ASPECTC +extern "C" { +#endif + #include <dpu.h> #include <dpu_log.h> -#include <unistd.h> -#include <getopt.h> -#include <assert.h> - -#include "../support/common.h" -#include "../support/timer.h" -#include "../support/params.h" #if ENERGY #include <dpu_probe.h> #endif +#if ASPECTC +} +#endif + +#include <unistd.h> +#include <getopt.h> +#include <assert.h> + +#include "common.h" +#include "timer.h" +#include "params.h" + // Define the DPU Binary path as DPU_BINARY here #ifndef DPU_BINARY #define DPU_BINARY "./bin/nw_dpu" @@ -184,7 +194,7 @@ int main(int argc, char **argv) { struct Params p = input_params(argc, argv); struct dpu_set_t dpu_set, dpu; - uint32_t nr_of_dpus, max_dpus; + uint32_t nr_of_dpus, nr_of_ranks, max_dpus; #if ENERGY struct dpu_probe_t probe; @@ -195,6 +205,7 @@ int main(int argc, char **argv) { 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); printf("Allocated %d TASKLET(s) per DPU\n", NR_TASKLETS); #if DYNAMIC @@ -822,28 +833,6 @@ int main(int argc, char **argv) { stop(&timer, 1); } - - // Print timing results - printf("CPU version "); - print(&timer, 0, p.n_reps); - printf("CPU-DPU "); - print(&timer, 2, p.n_reps); - printf("DPU Kernel "); - print(&timer, 3, p.n_reps); - printf("Inter-DPU "); - print(&timer, 1, p.n_reps); - printf("DPU-CPU "); - print(&timer, 4, p.n_reps); - printf("\n"); - printf("Longest Diagonal CPU-DPU "); - print(&long_diagonal_timer, 2, p.n_reps); - printf("Longest Diagonal DPU Kernel "); - print(&long_diagonal_timer, 3, p.n_reps); - printf("Longest Diagonal Inter-DPU "); - print(&long_diagonal_timer, 1, p.n_reps); - printf("Longest Diagonal DPU-CPU "); - print(&long_diagonal_timer, 4, p.n_reps); - printf("\n"); #if ENERGY printf("DPU Energy (J): %f \t ", tavg_energy / p.n_reps); diff --git a/NW/support/common.h b/NW/include/common.h index 69069e7..69069e7 100755..100644 --- a/NW/support/common.h +++ b/NW/include/common.h diff --git a/NW/include/dfatool_host.ah b/NW/include/dfatool_host.ah new file mode 100644 index 0000000..d45aef3 --- /dev/null +++ b/NW/include/dfatool_host.ah @@ -0,0 +1,30 @@ +#pragma once + +#include <sys/time.h> +#include "dfatool_host_dpu.ah" + +aspect DfatoolHostTiming : public DfatoolHostDPUTiming { + + unsigned long n_elements; + unsigned int element_size; + + virtual int getKernel() { return 1; } + + DfatoolHostTiming() { + element_size = sizeof(uint32_t); + } + + advice call("% input_params(...)"): after() { + Params* p = tjp->result(); + n_elements = p->max_rows; + printf("[>>] NW | n_dpus=%u n_elements=%lu\n", NR_DPUS, n_elements); + } + + advice call("% srand(...)") : after() { + printf("[--] NW | n_dpus=%u n_elements=%lu\n", NR_DPUS, n_elements); + } + + advice execution("% main(...)") : after() { + printf("[<<] NW | n_dpus=%u n_elements=%lu\n", NR_DPUS, n_elements); + } +}; diff --git a/NW/support/params.h b/NW/include/params.h index 8874248..8874248 100644 --- a/NW/support/params.h +++ b/NW/include/params.h diff --git a/NW/support/timer.h b/NW/include/timer.h index efaefcd..efaefcd 100755..100644 --- a/NW/support/timer.h +++ b/NW/include/timer.h @@ -77,7 +77,7 @@ CPU and DPU benchmarks in this repository have been adjusted as follows: * HST-L: AD * HST-S: DLN * MLP: A -* NW: – +* NW: A * RED: DLN * SCAN-SSA: D * SCAN-RSS: DLN |