diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-15 10:13:23 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-15 10:13:23 +0200 |
commit | 665cc63e16a1a5ac083c3a2df38236ae58025b64 (patch) | |
tree | c153ad46b6673fd2627d5988c360f8ec00b84fac /MLP/include | |
parent | 28f4fec42cc1eeec9718d1534728afaf9ac540f8 (diff) |
MLP: Add AspectC++ support
Diffstat (limited to 'MLP/include')
-rw-r--r-- | MLP/include/common.h | 45 | ||||
-rw-r--r-- | MLP/include/dfatool_host.ah | 31 | ||||
-rw-r--r-- | MLP/include/params.h | 65 | ||||
-rw-r--r-- | MLP/include/timer.h | 5 |
4 files changed, 146 insertions, 0 deletions
diff --git a/MLP/include/common.h b/MLP/include/common.h new file mode 100644 index 0000000..4b5031b --- /dev/null +++ b/MLP/include/common.h @@ -0,0 +1,45 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +// Structures used by both the host and the dpu to communicate information +typedef struct { + uint32_t n_size; + uint32_t n_size_pad; + uint32_t nr_rows; + uint32_t max_rows; +} dpu_arguments_t; + +// Specific information for each DPU +struct dpu_info_t { + uint32_t rows_per_dpu; + uint32_t rows_per_dpu_pad; + uint32_t prev_rows_dpu; +}; +struct dpu_info_t *dpu_info; + +#define NUM_LAYERS 3 +#define max(x, y) (x > y ? x : y) +#define min(x, y) (x < y ? x : y) + +// Transfer size between MRAM and WRAM +#ifdef BL +#define BLOCK_SIZE_LOG2 BL +#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2) +#else +#define BLOCK_SIZE_LOG2 8 +#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2) +#define BL BLOCK_SIZE_LOG2 +#endif + +// Data type +#define T int32_t + +#ifndef ENERGY +#define ENERGY 0 +#endif +#define PRINT 0 + +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_GREEN "\x1b[32m" +#define ANSI_COLOR_RESET "\x1b[0m" +#endif diff --git a/MLP/include/dfatool_host.ah b/MLP/include/dfatool_host.ah new file mode 100644 index 0000000..8cc4db5 --- /dev/null +++ b/MLP/include/dfatool_host.ah @@ -0,0 +1,31 @@ +#pragma once + +#include <sys/time.h> +#include "dfatool_host_dpu.ah" + +aspect DfatoolHostTiming : public DfatoolHostDPUTiming { + + unsigned int n_rows, n_cols; + 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_rows = p->m_size; + n_cols = p->n_size; + printf("[>>] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } + + advice call("% binarySearch(...)") : after() { + printf("[--] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } + + advice execution("% main(...)") : after() { + printf("[<<] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } +}; diff --git a/MLP/include/params.h b/MLP/include/params.h new file mode 100644 index 0000000..4bfc2fc --- /dev/null +++ b/MLP/include/params.h @@ -0,0 +1,65 @@ +#ifndef _PARAMS_H_ +#define _PARAMS_H_ + +#include "common.h" + +typedef struct Params { + unsigned int m_size; + unsigned int n_size; + unsigned int n_warmup; + unsigned int n_reps; +} Params; + +static void usage() +{ + fprintf(stderr, + "\nUsage: ./program [options]" + "\n" + "\nGeneral options:" + "\n -h help" + "\n -w <W> # of untimed warmup iterations (default=1)" + "\n -e <E> # of timed repetition iterations (default=3)" + "\n" + "\nBenchmark-specific options:" + "\n -m <I> m_size (default=2048 elements)" + "\n -n <I> n_size (default=2048 elements)" "\n"); +} + +struct Params input_params(int argc, char **argv) +{ + struct Params p; + p.m_size = 163840; + p.n_size = 4096; + p.n_warmup = 1; + p.n_reps = 3; + + int opt; + while ((opt = getopt(argc, argv, "hm:n:w:e:")) >= 0) { + switch (opt) { + case 'h': + usage(); + exit(0); + break; + case 'm': + p.m_size = atoi(optarg); + break; + case 'n': + p.n_size = atoi(optarg); + break; + case 'w': + p.n_warmup = atoi(optarg); + break; + case 'e': + p.n_reps = atoi(optarg); + break; + default: + fprintf(stderr, "\nUnrecognized option!\n"); + usage(); + exit(0); + } + } + assert(NR_DPUS > 0 && "Invalid # of dpus!"); + + return p; +} +#endif diff --git a/MLP/include/timer.h b/MLP/include/timer.h new file mode 100644 index 0000000..bff638d --- /dev/null +++ b/MLP/include/timer.h @@ -0,0 +1,5 @@ +#pragma once + +#define N_TIMERS 5 +#include "../../include/timer_base.h" +#undef N_TIMERS |