summaryrefslogtreecommitdiff
path: root/VA/support
diff options
context:
space:
mode:
Diffstat (limited to 'VA/support')
-rwxr-xr-xVA/support/common.h14
-rw-r--r--VA/support/dfatool_host.ah106
-rw-r--r--VA/support/params.h4
-rwxr-xr-xVA/support/timer.h26
4 files changed, 137 insertions, 13 deletions
diff --git a/VA/support/common.h b/VA/support/common.h
index cee09e2..6ce6e23 100755
--- a/VA/support/common.h
+++ b/VA/support/common.h
@@ -1,14 +1,20 @@
#ifndef _COMMON_H_
#define _COMMON_H_
+enum kernels {
+ kernel1 = 0,
+ nr_kernels = 1,
+};
+
// Structures used by both the host and the dpu to communicate information
typedef struct {
+ /*
+ * Size per DPU cannot exceed 32 bit, as each DPU only has 64 MiB of memory
+ * (i.e., only needs 26 bit for addressing).
+ */
uint32_t size;
uint32_t transfer_size;
- enum kernels {
- kernel1 = 0,
- nr_kernels = 1,
- } kernel;
+ enum kernels kernel;
} dpu_arguments_t;
// Transfer size between MRAM and WRAM
diff --git a/VA/support/dfatool_host.ah b/VA/support/dfatool_host.ah
new file mode 100644
index 0000000..f207ea2
--- /dev/null
+++ b/VA/support/dfatool_host.ah
@@ -0,0 +1,106 @@
+#pragma once
+
+#include <sys/time.h>
+
+aspect DfatoolHostTiming {
+ struct timeval starttime;
+ struct timeval stoptime;
+ uint32_t n_ranks = 0;
+ uint32_t n_dpus = 0;
+
+ double const M_to_Mi = 1.048576; /* 2^20 / 1e6 */
+
+ advice call("% input_params(...)") : after() {
+ Params* p = tjp->result();
+ printf("[--] n_dpus=%u n_elements=%lu e_exp=%d \n", NR_DPUS, p->input_size, p->exp);
+ }
+
+ advice call("% dpu_get_nr_dpus(...)") : after() {
+ n_dpus = **(tjp->arg<1>());
+ }
+
+ advice call("% dpu_get_nr_ranks(...)") : after() {
+ n_ranks = **(tjp->arg<1>());
+ }
+
+ advice call("% dpu_alloc(...)") : around() {
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ n_dpus = *(tjp->arg<0>());
+ printf("[::] dpu_alloc | n_dpus=%u | latency_us=%f\n",
+ n_dpus,
+ (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec)
+ );
+ }
+
+ advice call("% dpu_alloc_ranks(...)") : around() {
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ n_ranks = *(tjp->arg<0>());
+ printf("[::] dpu_alloc_ranks | n_ranks=%u | latency_us=%f\n",
+ n_ranks,
+ (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec)
+ );
+ }
+
+ advice call("% dpu_load(...)") : around() {
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ printf("[::] dpu_load | n_dpus=%u n_ranks=%u | latency_us=%f\n",
+ n_dpus, n_ranks,
+ (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec)
+ );
+ }
+
+ advice call("% dpu_free(...)") : around() {
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ printf("[::] dpu_free | n_dpus=%u n_ranks=%u | latency_us=%f\n",
+ n_dpus, n_ranks,
+ (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec)
+ );
+ }
+
+ advice call("% dpu_launch(...)") : around() {
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ double latency_us = (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec);
+ unsigned long input_size = p.input_size;
+ printf("[::] dpu_launch | n_dpus=%u n_ranks=%u e_kernel=kernel%d n_elements=%lu | latency_us=%f throughput_Mrps=%f throughput_MiBps=%f\n",
+ n_dpus, n_ranks,
+ kernel + 1,
+ input_size,
+ latency_us,
+ input_size / latency_us,
+ input_size * sizeof(T) / (latency_us * M_to_Mi)
+ );
+ }
+
+ advice call("% dpu_push_xfer(...)") : around() {
+ size_t payload_size = *(tjp->arg<4>());
+ gettimeofday(&starttime, NULL);
+ tjp->proceed();
+ gettimeofday(&stoptime, NULL);
+ double time_us = (stoptime.tv_sec - starttime.tv_sec) * 1000000.0 + (stoptime.tv_usec - starttime.tv_usec);
+ if (*(tjp->arg<1>()) == DPU_XFER_TO_DPU) {
+ printf("[::] dpu_push_to_dpu | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n",
+ n_dpus, n_ranks,
+ payload_size * n_dpus, payload_size,
+ time_us,
+ payload_size * n_dpus / (time_us * M_to_Mi)
+ );
+ } else if (*(tjp->arg<1>()) == DPU_XFER_FROM_DPU) {
+ printf("[::] dpu_push_from_dpu | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n",
+ n_dpus, n_ranks,
+ payload_size * n_dpus, payload_size,
+ time_us,
+ payload_size * n_dpus / (time_us * M_to_Mi)
+ );
+ }
+ }
+};
diff --git a/VA/support/params.h b/VA/support/params.h
index 47c10ef..4f41adc 100644
--- a/VA/support/params.h
+++ b/VA/support/params.h
@@ -4,7 +4,7 @@
#include "common.h"
typedef struct Params {
- unsigned int input_size;
+ unsigned long int input_size;
int n_warmup;
int n_reps;
int exp;
@@ -41,7 +41,7 @@ struct Params input_params(int argc, char **argv)
exit(0);
break;
case 'i':
- p.input_size = atoi(optarg);
+ p.input_size = atol(optarg);
break;
case 'w':
p.n_warmup = atoi(optarg);
diff --git a/VA/support/timer.h b/VA/support/timer.h
index df68334..c0208d3 100755
--- a/VA/support/timer.h
+++ b/VA/support/timer.h
@@ -35,6 +35,8 @@
#include <sys/time.h>
+#if DFATOOL_TIMING
+
typedef struct Timer {
struct timeval startTime[7];
@@ -43,6 +45,8 @@ typedef struct Timer {
} Timer;
+#define dfatool_printf(fmt, ...) do { printf(fmt, __VA_ARGS__); } while (0)
+
void start(Timer *timer, int i, int rep)
{
if (rep == 0) {
@@ -60,15 +64,23 @@ void stop(Timer *timer, int i)
(timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec);
}
-void print(Timer *timer, int i, int REP)
+#else
+
+#define dfatool_printf(fmt, ...) do {} while (0)
+
+typedef int Timer;
+
+void start(Timer *timer, int i, int rep)
{
- printf("Time (ms): %f\t", timer->time[i] / (1000 * REP));
+ (void)timer;
+ (void)i;
+ (void)rep;
}
-void printall(Timer *timer, int maxt)
+void stop(Timer *timer, int i)
{
- for (int i = 0; i <= maxt; i++) {
- printf(" timer%d_us=%f", i, timer->time[i]);
- }
- printf("\n");
+ (void)timer;
+ (void)i;
}
+
+#endif