diff options
-rw-r--r-- | Microbenchmarks/STREAM/Makefile | 2 | ||||
-rw-r--r-- | Microbenchmarks/STREAM/host/app.c | 54 | ||||
-rwxr-xr-x | Microbenchmarks/STREAM/run-rank.sh | 38 | ||||
-rw-r--r-- | Microbenchmarks/STREAM/support/timer.h | 24 |
4 files changed, 77 insertions, 41 deletions
diff --git a/Microbenchmarks/STREAM/Makefile b/Microbenchmarks/STREAM/Makefile index af3c47e..94cb3d4 100644 --- a/Microbenchmarks/STREAM/Makefile +++ b/Microbenchmarks/STREAM/Makefile @@ -15,7 +15,7 @@ DPU_SOURCES = dpu/${OP}.c HOST_SOURCES = $(wildcard host/*.c) COMMON_INCLUDES = support -COMMON_FLAGS = -Wall -Wextra -O2 -I${COMMON_INCLUDES} -DNR_DPUS=${NR_DPUS} -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -DT=${T} -D${OP} -D${MEM} -DUNROLL=${UNROLL} +COMMON_FLAGS = -Wall -Wextra -O2 -D_POSIX_C_SOURCE=200809L -I${COMMON_INCLUDES} -DNR_DPUS=${NR_DPUS} -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -DT=${T} -D${OP} -D${MEM} -DUNROLL=${UNROLL} HOST_FLAGS = ${COMMON_FLAGS} -std=c11 `dpu-pkg-config --cflags --libs dpu` -DWITH_ALLOC_OVERHEAD=${WITH_ALLOC_OVERHEAD} -DWITH_LOAD_OVERHEAD=${WITH_LOAD_OVERHEAD} -DWITH_FREE_OVERHEAD=${WITH_FREE_OVERHEAD} -DWITH_DPUINFO=${WITH_DPUINFO} -DSDK_SINGLETHREADED=${SDK_SINGLETHREADED} DPU_FLAGS = ${COMMON_FLAGS} -flto diff --git a/Microbenchmarks/STREAM/host/app.c b/Microbenchmarks/STREAM/host/app.c index 3e49d48..6ae7829 100644 --- a/Microbenchmarks/STREAM/host/app.c +++ b/Microbenchmarks/STREAM/host/app.c @@ -113,17 +113,17 @@ int main(int argc, char **argv) { // Allocate DPUs and load binary #if !WITH_ALLOC_OVERHEAD DPU_ASSERT(dpu_alloc(NR_DPUS, DPU_ALLOC_PROFILE, &dpu_set)); - timer.time[0] = 0; // alloc + timer.nanoseconds[0] = 0; // alloc #endif #if !WITH_LOAD_OVERHEAD 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)); assert(nr_of_dpus == NR_DPUS); - timer.time[1] = 0; // load + timer.nanoseconds[1] = 0; // load #endif #if !WITH_FREE_OVERHEAD - timer.time[6] = 0; // free + timer.nanoseconds[6] = 0; // free #endif unsigned int i = 0; @@ -329,30 +329,30 @@ int main(int argc, char **argv) { printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); printf("[::] STREAM UPMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_benchmark=%-6s e_type=%s e_mem=%s b_unroll=%d block_size_B=%d n_elements=%d n_elements_per_dpu=%d b_sdk_singlethreaded=%d ", NR_DPUS, nr_of_ranks, NR_TASKLETS, benchmark_name, XSTR(T), mem_name, UNROLL, BLOCK_SIZE, input_size, input_size / NR_DPUS, SDK_SINGLETHREADED); - printf("| latency_alloc_us=%f latency_load_us=%f latency_cpu_us=%f latency_write_us=%f latency_kernel_us=%f latency_read_us=%f latency_free_us=%f", - timer.time[0], - timer.time[1], - timer.time[2], - timer.time[3], - timer.time[4], - timer.time[5], - timer.time[6]); - printf(" throughput_cpu_MBps=%f throughput_upmem_kernel_MBps=%f throughput_upmem_total_MBps=%f", - input_size * n_arrays * sizeof(T) / timer.time[2], - input_size * n_arrays * sizeof(T) / (timer.time[4]), - input_size * n_arrays * sizeof(T) / (timer.time[0] + timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6])); - printf(" throughput_upmem_wxr_MBps=%f throughput_upmem_lwxr_MBps=%f throughput_upmem_alwxr_MBps=%f", - input_size * n_arrays * sizeof(T) / (timer.time[3] + timer.time[4] + timer.time[5]), - input_size * n_arrays * sizeof(T) / (timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5]), - input_size * n_arrays * sizeof(T) / (timer.time[0] + timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5])); - printf(" throughput_cpu_MOpps=%f throughput_upmem_kernel_MOpps=%f throughput_upmem_total_MOpps=%f", - input_size / timer.time[2], - input_size / (timer.time[4]), - input_size / (timer.time[0] + timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6])); - printf(" throughput_upmem_wxr_MOpps=%f throughput_upmem_lwxr_MOpps=%f throughput_upmem_alwxr_MOpps=%f\n", - input_size / (timer.time[3] + timer.time[4] + timer.time[5]), - input_size / (timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5]), - input_size / (timer.time[0] + timer.time[1] + timer.time[3] + timer.time[4] + timer.time[5])); + printf("| latency_alloc_ns=%lu latency_load_ns=%lu latency_cpu_ns=%lu latency_write_ns=%lu latency_kernel_ns=%lu latency_read_ns=%lu latency_free_ns=%lu", + timer.nanoseconds[0], + timer.nanoseconds[1], + timer.nanoseconds[2], + timer.nanoseconds[3], + timer.nanoseconds[4], + timer.nanoseconds[5], + timer.nanoseconds[6]); + printf(" throughput_cpu_Bps=%f throughput_upmem_kernel_Bps=%f throughput_upmem_total_Bps=%f", + input_size * n_arrays * sizeof(T) * 1e9 / timer.nanoseconds[2], + input_size * n_arrays * sizeof(T) * 1e9 / (timer.nanoseconds[4]), + input_size * n_arrays * sizeof(T) * 1e9 / (timer.nanoseconds[0] + timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5] + timer.nanoseconds[6])); + printf(" throughput_upmem_wxr_Bps=%f throughput_upmem_lwxr_Bps=%f throughput_upmem_alwxr_Bps=%f", + input_size * n_arrays * sizeof(T) * 1e9 / (timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5]), + input_size * n_arrays * sizeof(T) * 1e9 / (timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5]), + input_size * n_arrays * sizeof(T) * 1e9 / (timer.nanoseconds[0] + timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5])); + printf(" throughput_cpu_Opps=%f throughput_upmem_kernel_Opps=%f throughput_upmem_total_Opps=%f", + input_size * 1e9 / timer.nanoseconds[2], + input_size * 1e9 / (timer.nanoseconds[4]), + input_size * 1e9 / (timer.nanoseconds[0] + timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5] + timer.nanoseconds[6])); + printf(" throughput_upmem_wxr_Opps=%f throughput_upmem_lwxr_Opps=%f throughput_upmem_alwxr_Opps=%f\n", + input_size * 1e9 / (timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5]), + input_size * 1e9 / (timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5]), + input_size * 1e9 / (timer.nanoseconds[0] + timer.nanoseconds[1] + timer.nanoseconds[3] + timer.nanoseconds[4] + timer.nanoseconds[5])); } else { printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n"); } diff --git a/Microbenchmarks/STREAM/run-rank.sh b/Microbenchmarks/STREAM/run-rank.sh new file mode 100755 index 0000000..49253ea --- /dev/null +++ b/Microbenchmarks/STREAM/run-rank.sh @@ -0,0 +1,38 @@ +#!/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!) +# Each DPU uses three buffers, each of which holds $i * sizeof($dt) bytes. +# With a total MRAM capacity of 64M, this gives us ~21M per buffer, or 16M when rounding down to the next power of two. +# With a maximum data type width of 8B (uint64_t, double), this limits the number of elements per DPU to 2097152. + +( + +echo "prim-benchmarks STREAM microbenchmark (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +for i in 2097152 1048576 131072 16384 4096; do + for nr_dpus in 1 4 8 16 32 48 64; do + for nr_tasklets in 1 8 12 16; do + for dt in uint64_t uint8_t uint16_t uint32_t float double; do + for op in tried scale add copy copyw; do + for bl in 3 4 5 6 8 10; do + echo + if make -B OP=${op} NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=${bl} T=${dt} UNROLL=1 WITH_ALLOC_OVERHEAD=1 WITH_LOAD_OVERHEAD=1 WITH_FREE_OVERHEAD=1 \ + || make -B OP=${op} NR_DPUS=${nr_dpus} NR_TASKLETS=${nr_tasklets} BL=${bl} T=${dt} UNROLL=0 WITH_ALLOC_OVERHEAD=1 WITH_LOAD_OVERHEAD=1 WITH_FREE_OVERHEAD=1; then + timeout --foreground -k 1m 30m bin/host_code -w 0 -e 100 -i $i -x 0 || true + fi + done + done + done + done + done +done +echo "Completed at $(date)" +) | tee "log-$(hostname)-rank-idle.txt" diff --git a/Microbenchmarks/STREAM/support/timer.h b/Microbenchmarks/STREAM/support/timer.h index b53d95f..901baac 100644 --- a/Microbenchmarks/STREAM/support/timer.h +++ b/Microbenchmarks/STREAM/support/timer.h @@ -33,27 +33,25 @@ *
*/
-#include <sys/time.h>
+#include <time.h>
-typedef struct Timer{
+typedef struct Timer {
- struct timeval startTime[7];
- struct timeval stopTime[7];
- double time[7];
+ struct timespec startTime[7];
+ struct timespec stopTime[7];
+ uint64_t nanoseconds[7];
-}Timer;
+} Timer;
void start(Timer *timer, int i, int rep) {
if(rep == 0) {
- timer->time[i] = 0.0;
+ timer->nanoseconds[i] = 0;
}
- gettimeofday(&timer->startTime[i], NULL);
+ clock_gettime(CLOCK_MONOTONIC, &timer->startTime[i]);
}
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);
+ clock_gettime(CLOCK_MONOTONIC, &timer->stopTime[i]);
+ timer->nanoseconds[i] += (timer->stopTime[i].tv_sec - timer->startTime[i].tv_sec) * 1000000000 +
+ (timer->stopTime[i].tv_nsec - timer->startTime[i].tv_nsec);
}
-
-void print(Timer *timer, int i, int REP) { printf("Time (ms): %f\t", timer->time[i] / (1000 * REP)); }
|