summaryrefslogtreecommitdiff
path: root/GEMV/include
diff options
context:
space:
mode:
Diffstat (limited to 'GEMV/include')
-rw-r--r--GEMV/include/common.h41
-rw-r--r--GEMV/include/dfatool_host.ah27
-rw-r--r--GEMV/include/params.h65
-rw-r--r--GEMV/include/timer.h5
4 files changed, 138 insertions, 0 deletions
diff --git a/GEMV/include/common.h b/GEMV/include/common.h
new file mode 100644
index 0000000..47a9628
--- /dev/null
+++ b/GEMV/include/common.h
@@ -0,0 +1,41 @@
+#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;
+
+// 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 uint32_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/GEMV/include/dfatool_host.ah b/GEMV/include/dfatool_host.ah
new file mode 100644
index 0000000..bc2d512
--- /dev/null
+++ b/GEMV/include/dfatool_host.ah
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <sys/time.h>
+#include "dfatool_host_dpu.ah"
+
+aspect DfatoolHostTiming : public DfatoolHostDPUTiming {
+
+ uint32_t kernel = 1;
+
+ DfatoolHostTiming() {
+ element_size = sizeof(T);
+ }
+
+ advice call("% input_params(...)") : after() {
+ Params* p = tjp->result();
+ input_size = p->n_size * p->m_size;
+ printf("[>>] GEMV | n_dpus=%u n_elements=%lu\n", NR_DPUS, input_size);
+ }
+
+ advice call("% gemv_host(...)") : after() {
+ printf("[--] GEMV | n_dpus=%u n_elements=%lu\n", NR_DPUS, input_size);
+ }
+
+ advice execution("% main(...)") : after() {
+ printf("[<<] GEMV | n_dpus=%u n_elements=%lu\n", NR_DPUS, input_size);
+ }
+};
diff --git a/GEMV/include/params.h b/GEMV/include/params.h
new file mode 100644
index 0000000..c72b0c1
--- /dev/null
+++ b/GEMV/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=8192 elements)"
+ "\n -n <I> n_size (default=8192 elements)" "\n");
+}
+
+struct Params input_params(int argc, char **argv)
+{
+ struct Params p;
+ p.m_size = 8192;
+ p.n_size = 8192;
+ 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/GEMV/include/timer.h b/GEMV/include/timer.h
new file mode 100644
index 0000000..313151d
--- /dev/null
+++ b/GEMV/include/timer.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#define N_TIMERS 9
+#include "../../include/timer_base.h"
+#undef N_TIMERS