From 828846895c8ed472cceea35b66fff53aa63984d6 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 23 May 2025 15:13:59 +0200 Subject: RED: add AspectC++ support --- RED/include/common.h | 18 ++++++------ RED/include/dfatool_host.ah | 29 +++++++++++++++++++ RED/include/params.h | 4 +-- RED/include/timer.h | 69 +++------------------------------------------ 4 files changed, 45 insertions(+), 75 deletions(-) mode change 100755 => 100644 RED/include/common.h create mode 100644 RED/include/dfatool_host.ah mode change 100755 => 100644 RED/include/timer.h (limited to 'RED/include') diff --git a/RED/include/common.h b/RED/include/common.h old mode 100755 new mode 100644 index 121bf31..6cc1ae2 --- a/RED/include/common.h +++ b/RED/include/common.h @@ -38,19 +38,21 @@ #define DIV 1 // Shift right to divide by sizeof(T) #endif +enum kernels { + kernel1 = 0, + nr_kernels = 1, +}; + // Structures used by both the host and the dpu to communicate information typedef struct { - uint32_t size; - enum kernels { - kernel1 = 0, - nr_kernels = 1, - } kernel; - T t_count; + uint32_t size; + enum kernels kernel; + T t_count; } dpu_arguments_t; typedef struct { - uint64_t cycles; - T t_count; + uint64_t cycles; + T t_count; } dpu_results_t; #ifndef PERF diff --git a/RED/include/dfatool_host.ah b/RED/include/dfatool_host.ah new file mode 100644 index 0000000..88dfbd8 --- /dev/null +++ b/RED/include/dfatool_host.ah @@ -0,0 +1,29 @@ +#pragma once + +#include +#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(T); + } + + advice call("% input_params(...)") : after() { + Params* p = tjp->result(); + n_elements = p->input_size; + printf("[>>] RED | n_dpus=%u n_elements=%lu\n", NR_DPUS, n_elements); + } + + advice call("% reduction_host(...)") : after() { + printf("[--] RED | n_dpus=%u n_elements=%lu\n", n_dpus, n_elements); + } + + advice execution("% main(...)") : after() { + printf("[<<] RED | n_dpus=%u n_elements=%lu\n", NR_DPUS, n_elements); + } +}; diff --git a/RED/include/params.h b/RED/include/params.h index 97bc50a..ee90908 100644 --- a/RED/include/params.h +++ b/RED/include/params.h @@ -18,7 +18,7 @@ static void usage() { "\n -h help" "\n -w # of untimed warmup iterations (default=1)" "\n -e # of timed repetition iterations (default=3)" - "\n -x Weak (0) or strong (1) scaling (default=0)" + "\n -x Weak (0) or strong (1) scaling (default=1)" "\n" "\nBenchmark-specific options:" "\n -i input size (default=6553600 elements)" @@ -30,7 +30,7 @@ struct Params input_params(int argc, char **argv) { p.input_size = 6553600; p.n_warmup = 1; p.n_reps = 3; - p.exp = 0; + p.exp = 1; int opt; while((opt = getopt(argc, argv, "hi:w:e:x:")) >= 0) { diff --git a/RED/include/timer.h b/RED/include/timer.h old mode 100755 new mode 100644 index 4d597b9..5b8eba3 --- a/RED/include/timer.h +++ b/RED/include/timer.h @@ -1,66 +1,5 @@ -/* - * 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. - * - */ +#pragma once -#include - -typedef struct Timer{ - - struct timeval startTime[7]; - struct timeval stopTime[7]; - double time[7]; - -}Timer; - -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); -} - -void print(Timer *timer, int i, int REP) { printf("Time (ms): %f\t", timer->time[i] / (1000 * REP)); } - -void printall(Timer *timer, int maxt) { - for (int i = 0; i <= maxt; i++) { - printf(" timer%d_us=%f", i, timer->time[i]); - } - printf("\n"); -} +#define N_TIMERS 7 +#include "../../include/timer_base.h" +#undef N_TIMERS -- cgit v1.2.3