diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-13 14:18:39 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-13 14:18:39 +0200 |
commit | eb71b2b0a15a400d61285e4e0534a27af5c4f41d (patch) | |
tree | 4fa014d35792b33fade0df84baa19fbc33d790e0 | |
parent | 05001600966baeeba4ef42ddcf1804975fe88625 (diff) |
TRNS: refactor AspectC++ and timer headers
-rw-r--r-- | TRNS/Makefile | 8 | ||||
-rwxr-xr-x | TRNS/benchmark-scripts/ccmcc25.sh | 2 | ||||
-rw-r--r-- | TRNS/dpu/task.c | 2 | ||||
-rw-r--r-- | TRNS/host/app.c | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | TRNS/include/common.h (renamed from TRNS/support/common.h) | 0 | ||||
-rw-r--r-- | TRNS/include/dfatool_host.ah | 25 | ||||
-rw-r--r-- | TRNS/include/params.h (renamed from TRNS/support/params.h) | 4 | ||||
-rw-r--r-- | TRNS/include/timer.h | 5 | ||||
-rwxr-xr-x | TRNS/run-fgbs24a.sh | 29 | ||||
-rwxr-xr-x | TRNS/run-paper-strong-full.sh | 30 | ||||
-rwxr-xr-x | TRNS/run-paper-strong-rank.sh | 29 | ||||
-rwxr-xr-x | TRNS/run-paper-weak.sh | 28 | ||||
-rwxr-xr-x | TRNS/run-rank.sh | 32 | ||||
-rwxr-xr-x | TRNS/run.sh | 32 | ||||
-rw-r--r-- | TRNS/support/dfatool_host.ah | 101 | ||||
-rwxr-xr-x | TRNS/support/timer.h | 86 |
16 files changed, 42 insertions, 377 deletions
diff --git a/TRNS/Makefile b/TRNS/Makefile index 427a332..302fcd6 100644 --- a/TRNS/Makefile +++ b/TRNS/Makefile @@ -2,7 +2,6 @@ NR_DPUS ?= 1 NR_TASKLETS ?= 16 ENERGY ?= 0 -COMMON_INCLUDES := support HOST_SOURCES := $(wildcard host/*.c) DPU_SOURCES := $(wildcard dpu/*.c) @@ -12,12 +11,12 @@ dfatool_timing ?= 1 HOST_CC := ${CC} -COMMON_FLAGS := -Wall -Wextra -g -I${COMMON_INCLUDES} +COMMON_FLAGS := -Wall -Wextra -g -Iinclude HOST_FLAGS := ${COMMON_FLAGS} -O3 -march=native `dpu-pkg-config --cflags --libs dpu` -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DENERGY=${ENERGY} -DDFATOOL_TIMING=${dfatool_timing} -DASPECTC=${aspectc} DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} ifeq (${aspectc_timing}, 1) - ASPECTC_HOST_FLAGS += -a support/dfatool_host.ah + ASPECTC_HOST_FLAGS += -ainclude/dfatool_host_dpu.ah -ainclude/dfatool_host.ah endif ASPECTC_HOST_FLAGS ?= -a0 @@ -39,8 +38,11 @@ all: bin/host_code bin/dpu_code bin: ${QUIET}mkdir -p bin +# cp/rm are needed to work around AspectC++ not liking symlinks bin/host_code: ${HOST_SOURCES} ${COMMON_INCLUDES} 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/dpu_code: ${DPU_SOURCES} ${COMMON_INCLUDES} bin ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} diff --git a/TRNS/benchmark-scripts/ccmcc25.sh b/TRNS/benchmark-scripts/ccmcc25.sh index def251d..751566b 100755 --- a/TRNS/benchmark-scripts/ccmcc25.sh +++ b/TRNS/benchmark-scripts/ccmcc25.sh @@ -35,7 +35,7 @@ run_benchmark_nmc() { set -e sudo limit_ranks_to_numa_node ${numa_rank} make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} dfatool_timing=0 aspectc=1 aspectc_timing=1 - bin/host_code -w 0 -e 40 -p ${p} -o 2048 -m 16 -n 8 -x 1 + bin/host_code -w 0 -e 40 -p ${p} -o 2048 -m 16 -n 8 } export -f run_benchmark_nmc diff --git a/TRNS/dpu/task.c b/TRNS/dpu/task.c index 0f5e4be..9c0e0a8 100644 --- a/TRNS/dpu/task.c +++ b/TRNS/dpu/task.c @@ -12,7 +12,7 @@ #include <mutex.h> #include <barrier.h> -#include "../support/common.h" +#include "common.h" __host dpu_arguments_t DPU_INPUT_ARGUMENTS; diff --git a/TRNS/host/app.c b/TRNS/host/app.c index 735d2a9..b9a81b7 100644 --- a/TRNS/host/app.c +++ b/TRNS/host/app.c @@ -30,9 +30,9 @@ extern "C" { #include <assert.h> #include <math.h> -#include "../support/common.h" -#include "../support/timer.h" -#include "../support/params.h" +#include "common.h" +#include "timer.h" +#include "params.h" #define XSTR(x) STR(x) #define STR(x) #x diff --git a/TRNS/support/common.h b/TRNS/include/common.h index 6a94c62..6a94c62 100755..100644 --- a/TRNS/support/common.h +++ b/TRNS/include/common.h diff --git a/TRNS/include/dfatool_host.ah b/TRNS/include/dfatool_host.ah new file mode 100644 index 0000000..94f6101 --- /dev/null +++ b/TRNS/include/dfatool_host.ah @@ -0,0 +1,25 @@ +#pragma once + +#include <sys/time.h> +#include "dfatool_host_dpu.ah" + +aspect DfatoolHostTiming : public DfatoolHostDPUTiming { + + DfatoolHostTiming() { + element_size = sizeof(T); + } + + advice call("% input_params(...)") : after() { + Params* p = tjp->result(); + input_size = p->M_ * p->m * p->N_ * p->n; + printf("[>>] TRNS | n_dpus=%u n_elements=%lu e_exp=%d\n", NR_DPUS, input_size, p->exp); + } + + advice call("% trns_host(...)") : after() { + printf("[--] TRNS | n_dpus=%u n_ranks=%u n_elements=%lu e_exp=%d\n", n_dpus, n_ranks, input_size, p.exp); + } + + advice execution("% main(...)") : after() { + printf("[<<] TRNS | n_dpus=%u n_elements=%lu e_exp=%d\n", NR_DPUS, input_size, p.exp); + } +}; diff --git a/TRNS/support/params.h b/TRNS/include/params.h index 6b7e6f2..385490e 100644 --- a/TRNS/support/params.h +++ b/TRNS/include/params.h @@ -21,7 +21,7 @@ static void usage() { "\n -h help" "\n -w <W> # of untimed warmup iterations (default=1)" "\n -e <E> # of timed repetition iterations (default=3)" - "\n -x <X> Weak (0) or strong (1) scaling (default=0)" + "\n -x <X> Weak (0) or strong (1) scaling (default=1)" "\n" "\nBenchmark-specific options:" "\n -m <I> m (default=16 elements)" @@ -39,7 +39,7 @@ struct Params input_params(int argc, char **argv) { p.n = 8; p.n_warmup = 1; p.n_reps = 3; - p.exp = 0; + p.exp = 1; int opt; while((opt = getopt(argc, argv, "hw:e:x:m:n:o:p:")) >= 0) { diff --git a/TRNS/include/timer.h b/TRNS/include/timer.h new file mode 100644 index 0000000..8d5c3d5 --- /dev/null +++ b/TRNS/include/timer.h @@ -0,0 +1,5 @@ +#pragma once + +#define N_TIMERS 10 +#include "../../include/timer_base.h" +#undef N_TIMERS diff --git a/TRNS/run-fgbs24a.sh b/TRNS/run-fgbs24a.sh deleted file mode 100755 index 6ba8993..0000000 --- a/TRNS/run-fgbs24a.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -e - -mkdir -p $(hostname) - -# 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 TRNS strong-full (dfatool fgbs24a edition)" -echo "Started at $(date)" -echo "Revision $(git describe --always)" - -for nr_dpus in 2304 2048 2543; do - for nr_tasklets in 16; do - echo - if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets}; then - # upstream uses -p 2048, but then the number of DPUs is always constant... - timeout --foreground -k 1m 180m bin/host_code -w 0 -e 100 -p $nr_dpus -o 12288 -x 1 || true - fi - done -done -echo "Completed at $(date)" -) | tee "$(hostname)/fgbs24a.txt" diff --git a/TRNS/run-paper-strong-full.sh b/TRNS/run-paper-strong-full.sh deleted file mode 100755 index 9d3792c..0000000 --- a/TRNS/run-paper-strong-full.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 TRNS strong-full (dfatool edition)" -echo "Started at $(date)" -echo "Revision $(git describe --always)" - -# >2048 is not in upstream -for nr_dpus in 2543 2304 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}; then - # upstream uses -p 2048, but then the number of DPUs is always constant... - timeout --foreground -k 1m 90m bin/host_code -w 0 -e 40 -p $nr_dpus -o 12288 -x 1 || true - fi - done -done - -echo "Completed at $(date)" - -) | tee "log-$(hostname)-prim-strong-full.txt" diff --git a/TRNS/run-paper-strong-rank.sh b/TRNS/run-paper-strong-rank.sh deleted file mode 100755 index f5f00cb..0000000 --- a/TRNS/run-paper-strong-rank.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 TRNS strong-rank (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}; then - # upstream uses -p 64, but then the number of DPUs is always constant... - timeout --foreground -k 1m 60m bin/host_code -w 0 -e 40 -p $nr_dpus -o 12288 -x 1 || true - fi - done -done - -echo "Completed at $(date)" - -) | tee "log-$(hostname)-prim-strong-rank.txt" diff --git a/TRNS/run-paper-weak.sh b/TRNS/run-paper-weak.sh deleted file mode 100755 index f02d7d6..0000000 --- a/TRNS/run-paper-weak.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 TRNS 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}; then - timeout --foreground -k 1m 60m bin/host_code -w 0 -e 40 -p 1 -o 12288 -x 0 || true - fi - done -done | tee log-paper-weak.txt - -echo "Completed at $(date)" - -) | tee "log-$(hostname)-prim-weak.txt" diff --git a/TRNS/run-rank.sh b/TRNS/run-rank.sh deleted file mode 100755 index 00f6898..0000000 --- a/TRNS/run-rank.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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: input size (number of elements, not number of bytes!) - -( - -echo "prim-benchmarks TRNS (dfatool edition)" -echo "Started at $(date)" -echo "Revision $(git describe --always)" - -for nr_dpus in 1 4 8 16 32 48 64; do - for nr_tasklets in 8 12 16; do - # 12288 run-paper-weak, run-paper-strong-full - for i in 12288; do - echo - if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets}; then - # upstream uses -p 2048 in strong-full, but then the number of DPUs is always constant... - timeout --foreground -k 1m 90m bin/host_code -w 0 -e 40 -p 1 -o 12288 -x 0 || true - fi - done - done -done - -echo "Completed at $(date)" - -) | tee "log-$(hostname)-rank.txt" diff --git a/TRNS/run.sh b/TRNS/run.sh deleted file mode 100755 index 8d574a9..0000000 --- a/TRNS/run.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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: input size (number of elements, not number of bytes!) - -( - -echo "prim-benchmarks TRNS (dfatool edition)" -echo "Started at $(date)" -echo "Revision $(git describe --always)" - -for nr_dpus in 2542 2304 1 4 8 16 32 64 128 256 512 768 1024 1536 2048; do - for nr_tasklets in 8 12 16; do - # 12288 run-paper-weak, run-paper-strong-full - for i in 12288; do - echo - if make -B NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets}; then - # upstream uses -p 2048 in strong-full, but then the number of DPUs is always constant... - timeout --foreground -k 1m 90m bin/host_code -w 0 -e 40 -p $nr_dpus -o 12288 -x 1 || true - fi - done - done -done - -echo "Completed at $(date)" - -) | tee "log-$(hostname).txt" diff --git a/TRNS/support/dfatool_host.ah b/TRNS/support/dfatool_host.ah deleted file mode 100644 index c884c9d..0000000 --- a/TRNS/support/dfatool_host.ah +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once - -#include <sys/time.h> - -aspect DfatoolHostTiming { - struct timeval starttime; - struct timeval stoptime; - uint32_t n_ranks = 0; - uint32_t n_dpus = 0; - - double const M_to_Mi = 1.048576; /* 2^20 / 1e6 */ - - advice call("% dpu_get_nr_dpus(...)") : after() { - n_dpus = **(tjp->arg<1>()); - } - - advice call("% dpu_get_nr_ranks(...)") : after() { - n_ranks = **(tjp->arg<1>()); - } - - advice call("% dpu_alloc(...)") : around() { - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - n_dpus = *(tjp->arg<0>()); - printf("[::] dpu_alloc | n_dpus=%u | latency_us=%f\n", - n_dpus, - (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec) - ); - } - - advice call("% dpu_alloc_ranks(...)") : around() { - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - n_ranks = *(tjp->arg<0>()); - printf("[::] dpu_alloc_ranks | n_ranks=%u | latency_us=%f\n", - n_ranks, - (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec) - ); - } - - advice call("% dpu_load(...)") : around() { - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - printf("[::] dpu_load | n_dpus=%u n_ranks=%u | latency_us=%f\n", - n_dpus, n_ranks, - (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec) - ); - } - - advice call("% dpu_free(...)") : around() { - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - printf("[::] dpu_free | n_dpus=%u n_ranks=%u | latency_us=%f\n", - n_dpus, n_ranks, - (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec) - ); - } - - advice call("% dpu_launch(...)") : around() { - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - double latency_us = (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec); - unsigned long input_size = p.M_ * p.m * p.N_ * p.n; - printf("[::] dpu_launch | n_dpus=%u n_ranks=%u e_kernel=kernel%d n_elements=%lu | latency_us=%f throughput_Mrps=%f throughput_MiBps=%f\n", - n_dpus, n_ranks, - kernel + 1, - input_size, - latency_us, - input_size / latency_us, - input_size * sizeof(T) / (latency_us * M_to_Mi) - ); - } - - advice call("% dpu_push_xfer(...)") : around() { - size_t payload_size = *(tjp->arg<4>()); - gettimeofday(&starttime, NULL); - tjp->proceed(); - gettimeofday(&stoptime, NULL); - double time_us = (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec); - if (*(tjp->arg<1>()) == DPU_XFER_TO_DPU) { - printf("[::] dpu_push_to_dpu | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n", - n_dpus, n_ranks, - payload_size * n_dpus, payload_size, - time_us, - payload_size * n_dpus / (time_us * M_to_Mi) - ); - } else if (*(tjp->arg<1>()) == DPU_XFER_FROM_DPU) { - printf("[::] dpu_push_from_dpu | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n", - n_dpus, n_ranks, - payload_size * n_dpus, payload_size, - time_us, - payload_size * n_dpus / (time_us * M_to_Mi) - ); - } - } -}; diff --git a/TRNS/support/timer.h b/TRNS/support/timer.h deleted file mode 100755 index e04a202..0000000 --- a/TRNS/support/timer.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2016 University of Cordoba and University of Illinois - * All rights reserved. - * - * Developed by: IMPACT Research Group - * University of Cordoba and University of Illinois - * http://impact.crhc.illinois.edu/ - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * with the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * > Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimers. - * > Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimers in the - * documentation and/or other materials provided with the distribution. - * > Neither the names of IMPACT Research Group, University of Cordoba, - * University of Illinois nor the names of its contributors may be used - * to endorse or promote products derived from this Software without - * specific prior written permission. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH - * THE SOFTWARE. - * - */ - -#include <sys/time.h> - -#if DFATOOL_TIMING - -typedef struct Timer { - - struct timeval startTime[10]; - struct timeval stopTime[10]; - double time[10]; - -} Timer; - -#define dfatool_printf(fmt, ...) do { printf(fmt, __VA_ARGS__); } while (0) - -void start(Timer *timer, int i, int rep) -{ - if (rep == 0) { - timer->time[i] = 0.0; - } - gettimeofday(&timer->startTime[i], NULL); -} - -void stop(Timer *timer, int i) -{ - gettimeofday(&timer->stopTime[i], NULL); - timer->time[i] += - (timer->stopTime[i].tv_sec - - timer->startTime[i].tv_sec) * 1000000.0 + - (timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec); -} - -#else - -#define dfatool_printf(fmt, ...) do {} while (0) - -typedef int Timer; - -void start(Timer *timer, int i, int rep) -{ - (void)timer; - (void)i; - (void)rep; -} - -void stop(Timer *timer, int i) -{ - (void)timer; - (void)i; -} - -#endif |