summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2025-05-13 11:59:49 +0200
committerBirte Kristina Friesel <birte.friesel@uos.de>2025-05-13 11:59:49 +0200
commit591e195f3eeb06237dedd9c5a66fcfe0b0a10889 (patch)
tree4daa94bdc644015afac7cd27b4ecf93299a8d79b /include
parentffba7bb7077fe4c1fc3493ef45d71cadfef53782 (diff)
VA: Use common timer and timing aspect headers
Diffstat (limited to 'include')
-rw-r--r--include/dfatool_host_dpu.ah115
-rw-r--r--include/timer_base.h53
2 files changed, 168 insertions, 0 deletions
diff --git a/include/dfatool_host_dpu.ah b/include/dfatool_host_dpu.ah
new file mode 100644
index 0000000..1056a94
--- /dev/null
+++ b/include/dfatool_host_dpu.ah
@@ -0,0 +1,115 @@
+#pragma once
+
+#include <sys/time.h>
+
+aspect DfatoolHostDPUTiming {
+ 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("% 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 @ %s:%d | n_dpus=%u | latency_us=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_ranks=%u | latency_us=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_dpus=%u n_ranks=%u | latency_us=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_dpus=%u n_ranks=%u | latency_us=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_dpus=%u n_ranks=%u e_kernel=kernel%d n_elements=%lu | latency_us=%f throughput_Mrps=%f throughput_MiBps=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ 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 @ %s:%d | n_dpus=%u n_ranks=%u total_payload_B=%lu dpu_payload_B=%lu | latency_us=%f throughput_MiBps=%f\n",
+ tjp->filename(),
+ tjp->line(),
+ n_dpus, n_ranks,
+ payload_size * n_dpus, payload_size,
+ time_us,
+ payload_size * n_dpus / (time_us * M_to_Mi)
+ );
+ }
+ }
+};
diff --git a/include/timer_base.h b/include/timer_base.h
new file mode 100644
index 0000000..fed8bec
--- /dev/null
+++ b/include/timer_base.h
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <sys/time.h>
+
+#if DFATOOL_TIMING
+
+typedef struct Timer {
+
+ struct timeval startTime[N_TIMERS];
+ struct timeval stopTime[N_TIMERS];
+ double time[N_TIMERS];
+
+} Timer;
+
+#define dfatool_printf(fmt, ...) do { printf(fmt, __VA_ARGS__); } while (0)
+
+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);
+}
+
+#else
+
+#define dfatool_printf(fmt, ...) do {} while (0)
+
+typedef int Timer;
+
+void start(Timer *timer, int i, int rep)
+{
+ (void)timer;
+ (void)i;
+ (void)rep;
+}
+
+void stop(Timer *timer, int i)
+{
+ (void)timer;
+ (void)i;
+}
+
+#endif