summaryrefslogtreecommitdiff
path: root/HST-L/include
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-05-15 08:20:02 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2025-05-15 08:20:02 +0200
commita2931b65cd3ff5a2e77d9564a95aa3368a24533e (patch)
treecb3123bcd67184824909317aa7a3157fdcfba470 /HST-L/include
parentd8192e05fb13c57fd7ca05af6946093b51aa7d96 (diff)
HST-L: Add AspectC++ support
Diffstat (limited to 'HST-L/include')
-rw-r--r--HST-L/include/common.h47
-rw-r--r--HST-L/include/dfatool_host.ah31
-rw-r--r--HST-L/include/params.h67
-rw-r--r--HST-L/include/timer.h5
4 files changed, 150 insertions, 0 deletions
diff --git a/HST-L/include/common.h b/HST-L/include/common.h
new file mode 100644
index 0000000..438825e
--- /dev/null
+++ b/HST-L/include/common.h
@@ -0,0 +1,47 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+// 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
+#define DIV 2 // Shift right to divide by sizeof(T)
+#define REGS (BLOCK_SIZE >> 2) // 32 bits
+
+// Pixel depth
+#define DEPTH 12
+#define ByteSwap16(n) (((((unsigned int)n) << 8) & 0xFF00) | ((((unsigned int)n) >> 8) & 0x00FF))
+
+enum kernels {
+ kernel1 = 0,
+ nr_kernels = 1,
+} kernel;
+
+// Structures used by both the host and the dpu to communicate information
+typedef struct {
+ uint32_t size;
+ uint32_t transfer_size;
+ uint32_t bins;
+ enum kernels kernel;
+} dpu_arguments_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"
+
+#define divceil(n, m) (((n)-1) / (m) + 1)
+#define roundup(n, m) ((n / m) * m + m)
+#endif
diff --git a/HST-L/include/dfatool_host.ah b/HST-L/include/dfatool_host.ah
new file mode 100644
index 0000000..db4e441
--- /dev/null
+++ b/HST-L/include/dfatool_host.ah
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <sys/time.h>
+#include "dfatool_host_dpu.ah"
+
+aspect DfatoolHostTiming : public DfatoolHostDPUTiming {
+ unsigned long n_pixels;
+ unsigned int n_bins;
+ unsigned int element_size;
+
+ virtual int getKernel() { return 1; }
+
+ DfatoolHostTiming() {
+ element_size = sizeof(T);
+ }
+
+ advice call("% input_params(...)") : after() {
+ Params* p = tjp->result();
+ n_pixels = p->input_size;
+ n_bins = p->bins;
+ printf("[>>] HST-L | n_dpus=%u n_pixels=%lu n_bins=%u\n", NR_DPUS, n_pixels, n_bins);
+ }
+
+ advice call("% histogram_host(...)") : after() {
+ printf("[--] HST-L | n_dpus=%u n_pixels=%lu n_bins=%u\n", NR_DPUS, n_pixels, n_bins);
+ }
+
+ advice execution("% main(...)") : after() {
+ printf("[<<] HST-L | n_dpus=%u n_pixels=%lu n_bins=%u\n", NR_DPUS, n_pixels, n_bins);
+ }
+};
diff --git a/HST-L/include/params.h b/HST-L/include/params.h
new file mode 100644
index 0000000..d0c3129
--- /dev/null
+++ b/HST-L/include/params.h
@@ -0,0 +1,67 @@
+#ifndef _PARAMS_H_
+#define _PARAMS_H_
+
+#include "common.h"
+
+typedef struct Params {
+ unsigned int input_size;
+ unsigned int bins;
+ int n_warmup;
+ int n_reps;
+ const char *file_name;
+ int exp;
+ int dpu_s;
+}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 -x <X> Weak (0) or strong (1, 2) scaling (default=1)"
+ "\n"
+ "\nBenchmark-specific options:"
+ "\n -i <I> input size (default=1536*1024 elements)"
+ "\n -b <B> histogram size (default=256 bins)"
+ "\n -f <F> input image file (default=../input/image_VanHateren.iml)"
+ "\n");
+}
+
+struct Params input_params(int argc, char **argv) {
+ struct Params p;
+ p.input_size = 1536 * 1024;
+ p.bins = 256;
+ p.n_warmup = 1;
+ p.n_reps = 3;
+ p.exp = 1;
+ p.file_name = "./input/image_VanHateren.iml";
+ p.dpu_s = 64;
+
+ int opt;
+ while((opt = getopt(argc, argv, "hi:b:w:e:f:x:z:")) >= 0) {
+ switch(opt) {
+ case 'h':
+ usage();
+ exit(0);
+ break;
+ case 'i': p.input_size = atoi(optarg); break;
+ case 'b': p.bins = atoi(optarg); break;
+ case 'w': p.n_warmup = atoi(optarg); break;
+ case 'e': p.n_reps = atoi(optarg); break;
+ case 'f': p.file_name = optarg; break;
+ case 'x': p.exp = atoi(optarg); break;
+ case 'z': p.dpu_s = 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/HST-L/include/timer.h b/HST-L/include/timer.h
new file mode 100644
index 0000000..5b8eba3
--- /dev/null
+++ b/HST-L/include/timer.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#define N_TIMERS 7
+#include "../../include/timer_base.h"
+#undef N_TIMERS