diff options
-rw-r--r-- | MLP/Makefile | 64 | ||||
-rw-r--r-- | MLP/dpu/task.c | 2 | ||||
-rw-r--r-- | MLP/host/app.c | 36 | ||||
-rw-r--r--[-rwxr-xr-x] | MLP/include/common.h (renamed from MLP/support/common.h) | 0 | ||||
-rw-r--r-- | MLP/include/dfatool_host.ah | 31 | ||||
-rw-r--r-- | MLP/include/params.h (renamed from MLP/support/params.h) | 0 | ||||
-rw-r--r-- | MLP/include/timer.h | 5 | ||||
-rwxr-xr-x | MLP/support/timer.h | 69 | ||||
-rw-r--r-- | README.md | 2 |
9 files changed, 91 insertions, 118 deletions
diff --git a/MLP/Makefile b/MLP/Makefile index 944b3ca..9d69752 100644 --- a/MLP/Makefile +++ b/MLP/Makefile @@ -1,44 +1,54 @@ -DPU_DIR := dpu -HOST_DIR := host -BUILDDIR ?= bin -NR_TASKLETS ?= 16 +NR_DPUS ?= 1 +NR_TASKLETS ?= 16 BL ?= 10 -NR_DPUS ?= 1 -define conf_filename - ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2)_BL_$(3).conf -endef -CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS},${BL}) +HOST_SOURCES := $(wildcard host/*.c) +DPU_SOURCES := $(wildcard dpu/*.c) -HOST_TARGET := ${BUILDDIR}/mlp_host -DPU_TARGET := ${BUILDDIR}/mlp_dpu +aspectc ?= 0 +aspectc_timing ?= 0 -COMMON_INCLUDES := support -HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c) -DPU_SOURCES := $(wildcard ${DPU_DIR}/*.c) +HOST_CC := ${CC} -.PHONY: all clean test +COMMON_FLAGS := -Wall -Wextra -g -Iinclude -DNR_TASKLETS=${NR_TASKLETS} -DNR_DPUS=${NR_DPUS} -DBL=${BL} +HOST_FLAGS := ${COMMON_FLAGS} -O3 `dpu-pkg-config --cflags --libs dpu` -DASPECTC=${aspectc} +DPU_FLAGS := ${COMMON_FLAGS} -O2 + +ifeq (${aspectc_timing}, 1) + ASPECTC_HOST_FLAGS += -ainclude/dfatool_host_dpu.ah -ainclude/dfatool_host.ah +endif + +ASPECTC_HOST_FLAGS ?= -a0 -__dirs := $(shell mkdir -p ${BUILDDIR}) +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 -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} -DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} +QUIET = @ -all: ${HOST_TARGET} ${DPU_TARGET} +ifdef verbose + QUIET = +endif -${CONF}: - $(RM) $(call conf_filename,*,*) - touch ${CONF} +all: bin/mlp_dpu bin/mlp_host -${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF} - $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS} +bin: + ${QUIET}mkdir -p bin -${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF} +bin/mlp_host: ${HOST_SOURCES} include bin + ${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/mlp_dpu: ${DPU_SOURCES} include bin dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} clean: $(RM) -r $(BUILDDIR) test: all - ./${HOST_TARGET} -m 1024 -n 1024 + bin/mlp_host -m 1024 -n 1024 + +.PHONY: all clean test diff --git a/MLP/dpu/task.c b/MLP/dpu/task.c index 4f85024..ae400ae 100644 --- a/MLP/dpu/task.c +++ b/MLP/dpu/task.c @@ -10,7 +10,7 @@ #include <barrier.h> #include <seqread.h> -#include "../support/common.h" +#include "common.h" __host dpu_arguments_t DPU_INPUT_ARGUMENTS; diff --git a/MLP/host/app.c b/MLP/host/app.c index 24243bf..9c32ab8 100644 --- a/MLP/host/app.c +++ b/MLP/host/app.c @@ -8,19 +8,28 @@ #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 ASPECTC +extern "C" { +#endif + +#include <dpu.h> +#include <dpu_log.h> + #if ENERGY #include <dpu_probe.h> #endif -#include "../support/common.h" -#include "../support/timer.h" -#include "../support/params.h" +#if ASPECTC +} +#endif + +#include "common.h" +#include "timer.h" +#include "params.h" // Define the DPU Binary path as DPU_BINARY here #ifndef DPU_BINARY @@ -159,8 +168,8 @@ int main(int argc, char **argv) B = (T *) malloc(n_size * sizeof(T)); B_host = (T *) malloc(n_size * sizeof(T)); C = (T *) malloc(m_size * sizeof(T)); - C_dpu = malloc(max_rows_per_dpu * nr_of_dpus * sizeof(T)); - B_tmp = malloc(max_rows_per_dpu * nr_of_dpus * sizeof(T)); + C_dpu = (T*)malloc(max_rows_per_dpu * nr_of_dpus * sizeof(T)); + B_tmp = (T*)malloc(max_rows_per_dpu * nr_of_dpus * sizeof(T)); init_data(A, B, B_host, m_size, n_size); @@ -331,22 +340,9 @@ int main(int argc, char **argv) DPU_ASSERT(dpu_probe_get(&probe, DPU_TIME, DPU_AVERAGE, &avg_time)); #endif - // Print timing results - printf("CPU Version Time (ms): "); - print(&timer, 0, 1); - printf("CPU-DPU Time (ms): "); - print(&timer, 1, p.n_reps); - printf("DPU Kernel Time (ms): "); - print(&timer, 2, p.n_reps); - printf("Inter-DPU Time (ms): "); - print(&timer, 4, p.n_reps); - printf("DPU-CPU Time (ms): "); - print(&timer, 3, p.n_reps); - #if ENERGY printf("Energy (J): %f J\t", avg_energy); #endif - printf("\n\n"); // Check output bool status = true; diff --git a/MLP/support/common.h b/MLP/include/common.h index 4b5031b..4b5031b 100755..100644 --- a/MLP/support/common.h +++ b/MLP/include/common.h diff --git a/MLP/include/dfatool_host.ah b/MLP/include/dfatool_host.ah new file mode 100644 index 0000000..8cc4db5 --- /dev/null +++ b/MLP/include/dfatool_host.ah @@ -0,0 +1,31 @@ +#pragma once + +#include <sys/time.h> +#include "dfatool_host_dpu.ah" + +aspect DfatoolHostTiming : public DfatoolHostDPUTiming { + + unsigned int n_rows, n_cols; + unsigned int element_size; + + virtual int getKernel() { return 1; } + + DfatoolHostTiming() { + element_size = sizeof(uint32_t); + } + + advice call("% input_params(...)"): after() { + Params* p = tjp->result(); + n_rows = p->m_size; + n_cols = p->n_size; + printf("[>>] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } + + advice call("% binarySearch(...)") : after() { + printf("[--] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } + + advice execution("% main(...)") : after() { + printf("[<<] MLP | n_dpus=%u n_rows=%u n_cols=%u\n", NR_DPUS, n_rows, n_cols); + } +}; diff --git a/MLP/support/params.h b/MLP/include/params.h index 4bfc2fc..4bfc2fc 100644 --- a/MLP/support/params.h +++ b/MLP/include/params.h diff --git a/MLP/include/timer.h b/MLP/include/timer.h new file mode 100644 index 0000000..bff638d --- /dev/null +++ b/MLP/include/timer.h @@ -0,0 +1,5 @@ +#pragma once + +#define N_TIMERS 5 +#include "../../include/timer_base.h" +#undef N_TIMERS diff --git a/MLP/support/timer.h b/MLP/support/timer.h deleted file mode 100755 index 961ed11..0000000 --- a/MLP/support/timer.h +++ /dev/null @@ -1,69 +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[5]; - struct timeval stopTime[5]; - double time[5]; - -} 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)); -} @@ -76,7 +76,7 @@ CPU and DPU benchmarks in this repository have been adjusted as follows: * GEMV: ADLN * HST-L: AD * HST-S: DLN -* MLP: – +* MLP: A * NW: – * RED: DLN * SCAN-SSA: D |