summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GEMV/Makefile29
-rw-r--r--GEMV/dpu/task.c2
-rw-r--r--GEMV/host/app.c54
-rw-r--r--[-rwxr-xr-x]GEMV/include/common.h (renamed from GEMV/support/common.h)0
-rw-r--r--GEMV/include/dfatool_host.ah27
-rw-r--r--GEMV/include/params.h (renamed from GEMV/support/params.h)0
-rw-r--r--GEMV/include/timer.h5
-rwxr-xr-xGEMV/support/timer.h74
8 files changed, 92 insertions, 99 deletions
diff --git a/GEMV/Makefile b/GEMV/Makefile
index 5f766ae..644278e 100644
--- a/GEMV/Makefile
+++ b/GEMV/Makefile
@@ -5,16 +5,31 @@ WITH_ALLOC_OVERHEAD ?= 0
WITH_LOAD_OVERHEAD ?= 0
WITH_FREE_OVERHEAD ?= 0
-COMMON_INCLUDES := support
HOST_SOURCES := $(wildcard host/*.c)
DPU_SOURCES := $(wildcard dpu/*.c)
-.PHONY: all clean test
+aspectc ?= 0
+aspectc_timing ?= 0
+dfatool_timing ?= 1
+
+HOST_CC := ${CC}
-COMMON_FLAGS := -Wall -Wextra -g -I${COMMON_INCLUDES}
-HOST_FLAGS := ${COMMON_FLAGS} -std=c11 -O3 `dpu-pkg-config --cflags --libs dpu` -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DBL=${BL} -DWITH_ALLOC_OVERHEAD=${WITH_ALLOC_OVERHEAD} -DWITH_LOAD_OVERHEAD=${WITH_LOAD_OVERHEAD} -DWITH_FREE_OVERHEAD=${WITH_FREE_OVERHEAD}
+COMMON_FLAGS := -Wall -Wextra -g -Iinclude
+HOST_FLAGS := ${COMMON_FLAGS} -O3 `dpu-pkg-config --cflags --libs dpu` -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DBL=${BL} -DWITH_ALLOC_OVERHEAD=${WITH_ALLOC_OVERHEAD} -DWITH_LOAD_OVERHEAD=${WITH_LOAD_OVERHEAD} -DWITH_FREE_OVERHEAD=${WITH_FREE_OVERHEAD} -DASPECTC=${aspectc} -DDFATOOL_TIMING=${dfatool_timing}
DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL}
+ifeq (${aspectc_timing}, 1)
+ ASPECTC_HOST_FLAGS += -ainclude/dfatool_host_dpu.ah -ainclude/dfatool_host.ah
+endif
+
+ASPECTC_HOST_FLAGS ?= -a0
+
+ifeq (${aspectc}, 1)
+ HOST_CC = ag++ -r repo.acp -v 0 ${ASPECTC_HOST_FLAGS} --c_compiler ${UPMEM_HOME}/bin/clang++ -p . --Xcompiler
+else
+ HOST_FLAGS += -std=c11
+endif
+
QUIET = @
ifdef verbose
@@ -27,7 +42,9 @@ bin:
${QUIET}mkdir -p bin
bin/gemv_host: ${HOST_SOURCES} ${COMMON_INCLUDES} bin
- ${QUIET}${CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS}
+ ${QUIET}cp ../include/dfatool_host_dpu.ah include
+ ${QUIET}${HOST_CC} -o $@ ${HOST_SOURCES} ${HOST_FLAGS}
+ ${QUIET}rm -f include/dfatool_host_dpu.ah
bin/gemv_dpu: ${DPU_SOURCES} ${COMMON_INCLUDES} bin
${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES}
@@ -37,3 +54,5 @@ clean:
test: all
bin/gemv_host -m 1024 -n 1024
+
+.PHONY: all clean test
diff --git a/GEMV/dpu/task.c b/GEMV/dpu/task.c
index 3bf52e8..120f134 100644
--- a/GEMV/dpu/task.c
+++ b/GEMV/dpu/task.c
@@ -10,7 +10,7 @@
#include <barrier.h>
#include <seqread.h>
-#include "../support/common.h"
+#include "common.h"
#define roundup(n, m) ((n / m) * m + m)
diff --git a/GEMV/host/app.c b/GEMV/host/app.c
index 6553774..9838eb4 100644
--- a/GEMV/host/app.c
+++ b/GEMV/host/app.c
@@ -8,25 +8,33 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
-#include <dpu.h>
-#include <dpu_log.h>
#include <unistd.h>
#include <getopt.h>
#include <assert.h>
-#if ENERGY
-#include <dpu_probe.h>
+#if ASPECTC
+extern "C" {
#endif
+#include <dpu.h>
+#include <dpu_log.h>
#include <dpu_management.h>
#include <dpu_target_macros.h>
+#if ENERGY
+#include <dpu_probe.h>
+#endif
+
+#if ASPECTC
+}
+#endif
+
#define XSTR(x) STR(x)
#define STR(x) #x
-#include "../support/common.h"
-#include "../support/timer.h"
-#include "../support/params.h"
+#include "common.h"
+#include "timer.h"
+#include "params.h"
// Define the DPU Binary path as DPU_BINARY here
#ifndef DPU_BINARY
@@ -38,6 +46,8 @@ static T *B;
static T *C;
static T *C_dpu;
+unsigned int kernel = 0;
+
// Create input arrays
static void init_data(T *A, T *B, unsigned int m_size, unsigned int n_size)
{
@@ -85,18 +95,24 @@ int main(int argc, char **argv)
// Allocate DPUs and load binary
#if !WITH_ALLOC_OVERHEAD
DPU_ASSERT(dpu_alloc(NR_DPUS, NULL, &dpu_set));
+#if DFATOOL_TIMING
timer.time[0] = 0; // alloc
#endif
+#endif
#if !WITH_LOAD_OVERHEAD
DPU_ASSERT(dpu_load(dpu_set, DPU_BINARY, NULL));
DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &nr_of_dpus));
DPU_ASSERT(dpu_get_nr_ranks(dpu_set, &nr_of_ranks));
assert(nr_of_dpus == NR_DPUS);
+#if DFATOOL_TIMING
timer.time[1] = 0; // load
#endif
+#endif
#if !WITH_FREE_OVERHEAD
+#if DFATOOL_TIMING
timer.time[8] = 0; // free
#endif
+#endif
#if ENERGY
struct dpu_probe_t probe;
@@ -155,10 +171,10 @@ int main(int argc, char **argv)
input_args[i].nr_rows = rows_per_dpu;
}
- A = malloc(max_rows_per_dpu * NR_DPUS * n_size_pad * sizeof(T));
- B = malloc(n_size_pad * sizeof(T));
- C = malloc(max_rows_per_dpu * NR_DPUS * sizeof(T));
- C_dpu = malloc(max_rows_per_dpu * NR_DPUS * sizeof(T));
+ A = (T*)malloc(max_rows_per_dpu * NR_DPUS * n_size_pad * sizeof(T));
+ B = (T*)malloc(n_size_pad * sizeof(T));
+ C = (T*)malloc(max_rows_per_dpu * NR_DPUS * sizeof(T));
+ C_dpu = (T*)malloc(max_rows_per_dpu * NR_DPUS * sizeof(T));
// Initialize data with arbitrary data
init_data(A, B, m_size, n_size);
@@ -347,26 +363,26 @@ int main(int argc, char **argv)
printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET
"] Outputs are equal\n");
if (rep >= p.n_warmup) {
- printf
+ dfatool_printf
("[::] GEMV-UPMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_type=%s block_size_B=%d n_elements=%d",
NR_DPUS, nr_of_ranks, NR_TASKLETS, XSTR(T),
BLOCK_SIZE, n_size * m_size);
- printf
+ dfatool_printf
(" b_with_alloc_overhead=%d b_with_load_overhead=%d b_with_free_overhead=%d numa_node_rank=%d ",
WITH_ALLOC_OVERHEAD, WITH_LOAD_OVERHEAD,
WITH_FREE_OVERHEAD, numa_node_rank);
- printf
+ dfatool_printf
("| latency_alloc_us=%f latency_load_us=%f latency_cpu_us=%f latency_write_us=%f latency_kernel_us=%f latency_read_us=%f latency_free_us=%f",
timer.time[0], timer.time[1],
timer.time[2],
timer.time[3] + timer.time[6] +
timer.time[7], timer.time[4],
timer.time[5], timer.time[8]);
- printf
+ dfatool_printf
(" latency_write1_us=%f latency_write2_us=%f latency_write3_us=%f",
timer.time[3], timer.time[6], timer.time[7]
);
- printf
+ dfatool_printf
(" throughput_cpu_MBps=%f throughput_upmem_kernel_MBps=%f throughput_upmem_total_MBps=%f",
n_size * m_size * sizeof(T) /
timer.time[2],
@@ -377,7 +393,7 @@ int main(int argc, char **argv)
timer.time[3] + timer.time[6] +
timer.time[7] + timer.time[4] +
timer.time[5] + timer.time[8]));
- printf
+ dfatool_printf
(" throughput_upmem_wxr_MBps=%f throughput_upmem_lwxr_MBps=%f throughput_upmem_alwxr_MBps=%f",
n_size * m_size * sizeof(T) /
(timer.time[3] + timer.time[6] +
@@ -392,7 +408,7 @@ int main(int argc, char **argv)
timer.time[3] + timer.time[6] +
timer.time[7] + timer.time[4] +
timer.time[5]));
- printf
+ dfatool_printf
(" throughput_cpu_MOpps=%f throughput_upmem_kernel_MOpps=%f throughput_upmem_total_MOpps=%f",
n_size * m_size / timer.time[2],
n_size * m_size / (timer.time[4]),
@@ -404,7 +420,7 @@ int main(int argc, char **argv)
timer.time[4] +
timer.time[5] +
timer.time[8]));
- printf
+ dfatool_printf
(" throughput_upmem_wxr_MOpps=%f throughput_upmem_lwxr_MOpps=%f throughput_upmem_alwxr_MOpps=%f\n",
n_size * m_size / (timer.time[3] +
timer.time[6] +
diff --git a/GEMV/support/common.h b/GEMV/include/common.h
index 47a9628..47a9628 100755..100644
--- a/GEMV/support/common.h
+++ b/GEMV/include/common.h
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/support/params.h b/GEMV/include/params.h
index c72b0c1..c72b0c1 100644
--- a/GEMV/support/params.h
+++ b/GEMV/include/params.h
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
diff --git a/GEMV/support/timer.h b/GEMV/support/timer.h
deleted file mode 100755
index b2b9148..0000000
--- a/GEMV/support/timer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2016 University of Cordoba and University of Illinois
- * All rights reserved.
- *
- * Developed by: IMPACT Research Group
- * University of Cordoba and University of Illinois
- * http://impact.crhc.illinois.edu/
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * with the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * > Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimers.
- * > Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimers in the
- * documentation and/or other materials provided with the distribution.
- * > Neither the names of IMPACT Research Group, University of Cordoba,
- * University of Illinois nor the names of its contributors may be used
- * to endorse or promote products derived from this Software without
- * specific prior written permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
- * THE SOFTWARE.
- *
- */
-
-#include <sys/time.h>
-typedef struct Timer {
- struct timeval startTime[9];
- struct timeval stopTime[9];
- double time[9];
-} Timer;
-
-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);
-
- //printf("Time (ms): %f\t",((timer->stopTime[i].tv_sec - timer->startTime[i].tv_sec) * 1000000.0 +
- // (timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec)) / 1000);
-}
-
-void print(Timer *timer, int i, int REP)
-{
- printf("%f\t", timer->time[i] / (1000 * REP));
-}
-
-void printall(Timer *timer, int maxt)
-{
- for (int i = 0; i <= maxt; i++) {
- printf(" timer%d_us=%f", i, timer->time[i]);
- }
- printf("\n");
-}