diff options
-rw-r--r-- | BFS/Makefile | 29 | ||||
-rw-r--r-- | BFS/dpu/task.c | 2 | ||||
-rw-r--r-- | BFS/host/app.c | 60 | ||||
-rw-r--r-- | BFS/host/mram-management.h | 4 | ||||
-rw-r--r-- | BFS/include/common.h (renamed from BFS/support/common.h) | 0 | ||||
-rw-r--r-- | BFS/include/dfatool_host.ah | 27 | ||||
-rw-r--r-- | BFS/include/graph.h (renamed from BFS/support/graph.h) | 0 | ||||
-rw-r--r-- | BFS/include/params.h (renamed from BFS/support/params.h) | 0 | ||||
-rw-r--r-- | BFS/include/timer.h | 8 | ||||
-rw-r--r-- | BFS/include/utils.h (renamed from BFS/support/utils.h) | 0 | ||||
-rw-r--r-- | BFS/support/timer.h | 31 | ||||
-rw-r--r-- | include/dfatool_host_dpu.ah | 20 | ||||
-rw-r--r-- | include/timer_base.h | 11 |
13 files changed, 124 insertions, 68 deletions
diff --git a/BFS/Makefile b/BFS/Makefile index d43202f..598de50 100644 --- a/BFS/Makefile +++ b/BFS/Makefile @@ -4,17 +4,34 @@ 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) -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} -DWITH_ALLOC_OVERHEAD=${WITH_ALLOC_OVERHEAD} -DWITH_LOAD_OVERHEAD=${WITH_LOAD_OVERHEAD} -DWITH_FREE_OVERHEAD=${WITH_FREE_OVERHEAD} +aspectc ?= 0 +aspectc_timing ?= 0 +dfatool_timing ?= 1 + +HOST_CC := ${CC} + +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} -DWITH_ALLOC_OVERHEAD=${WITH_ALLOC_OVERHEAD} -DWITH_LOAD_OVERHEAD=${WITH_LOAD_OVERHEAD} -DWITH_FREE_OVERHEAD=${WITH_FREE_OVERHEAD} -DDFATOOL_TIMING=${dfatool_timing} -DASPECTC=${aspectc} DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} +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 +ifeq (${verbose}, 1) QUIET = endif @@ -27,7 +44,9 @@ bin/dpu_code: ${DPU_SOURCES} ${COMMON_INCLUDES} bin ${QUIET}dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} bin/host_code: ${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 clean: ${QUIET}rm -rf bin diff --git a/BFS/dpu/task.c b/BFS/dpu/task.c index 44ec214..5275047 100644 --- a/BFS/dpu/task.c +++ b/BFS/dpu/task.c @@ -12,7 +12,7 @@ #include <perfcounter.h> #include "dpu-utils.h" -#include "../support/common.h" +#include "common.h" BARRIER_INIT(my_barrier, NR_TASKLETS); diff --git a/BFS/host/app.c b/BFS/host/app.c index 9ba7ffb..763ff7a 100644 --- a/BFS/host/app.c +++ b/BFS/host/app.c @@ -3,9 +3,24 @@ * BFS Host Application Source File * */ +#if ASPECTC +extern "C" { +#endif + #include <dpu.h> #include <dpu_log.h> +#ifndef ENERGY +#define ENERGY 0 +#endif +#if ENERGY +#include <dpu_probe.h> +#endif + +#if ASPECTC +} +#endif + #include <assert.h> #include <getopt.h> #include <stdio.h> @@ -14,18 +29,11 @@ #include <unistd.h> #include "mram-management.h" -#include "../support/common.h" -#include "../support/graph.h" -#include "../support/params.h" -#include "../support/timer.h" -#include "../support/utils.h" - -#ifndef ENERGY -#define ENERGY 0 -#endif -#if ENERGY -#include <dpu_probe.h> -#endif +#include "common.h" +#include "graph.h" +#include "params.h" +#include "timer.h" +#include "utils.h" #define DPU_BINARY "./bin/dpu_code" @@ -44,10 +52,6 @@ int main(int argc, char **argv) double tenergy = 0; #endif - printf - ("WITH_ALLOC_OVERHEAD=%d WITH_LOAD_OVERHEAD=%d WITH_FREE_OVERHEAD=%d\n", - WITH_ALLOC_OVERHEAD, WITH_LOAD_OVERHEAD, WITH_FREE_OVERHEAD); - // Allocate DPUs and load binary struct dpu_set_t dpu_set, dpu; uint32_t numDPUs, numRanks; @@ -59,7 +63,7 @@ int main(int argc, char **argv) #if WITH_ALLOC_OVERHEAD stopTimer(&timer, 0); #else - timer.time[0] = 0; + zeroTimer(&timer, 0); #endif #if WITH_LOAD_OVERHEAD @@ -69,7 +73,7 @@ int main(int argc, char **argv) #if WITH_LOAD_OVERHEAD stopTimer(&timer, 0); #else - timer.time[1] = 0; + zeroTimer(&timer, 1); #endif DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &numDPUs)); @@ -86,10 +90,10 @@ int main(int argc, char **argv) uint32_t numNodes = csrGraph.numNodes; uint32_t *nodePtrs = csrGraph.nodePtrs; uint32_t *neighborIdxs = csrGraph.neighborIdxs; - uint32_t *nodeLevel = calloc(numNodes, sizeof(uint32_t)); // Node's BFS level (initially all 0 meaning not reachable) - uint64_t *visited = calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node - uint64_t *currentFrontier = calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node - uint64_t *nextFrontier = calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node + uint32_t *nodeLevel = (uint32_t*)calloc(numNodes, sizeof(uint32_t)); // Node's BFS level (initially all 0 meaning not reachable) + uint64_t *visited = (uint64_t*)calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node + uint64_t *currentFrontier = (uint64_t*)calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node + uint64_t *nextFrontier = (uint64_t*)calloc(numNodes / 64, sizeof(uint64_t)); // Bit vector with one bit per node setBit(nextFrontier[0], 0); // Initialize frontier to first node uint32_t level = 1; @@ -325,7 +329,7 @@ int main(int argc, char **argv) // Calculating result on CPU PRINT_INFO(p.verbosity >= 1, "Calculating result on CPU"); - uint32_t *nodeLevelReference = calloc(numNodes, sizeof(uint32_t)); // Node's BFS level (initially all 0 meaning not reachable) + uint32_t *nodeLevelReference = (uint32_t*) calloc(numNodes, sizeof(uint32_t)); // Node's BFS level (initially all 0 meaning not reachable) memset(nextFrontier, 0, numNodes / 64 * sizeof(uint64_t)); setBit(nextFrontier[0], 0); // Initialize frontier to first node nextFrontierEmpty = 0; @@ -395,7 +399,7 @@ int main(int argc, char **argv) #if WITH_FREE_OVERHEAD stopTimer(&timer, 7); #else - timer.time[7] = 0; + zeroTimer(&timer, 7); #endif // Verify the result @@ -412,9 +416,9 @@ int main(int argc, char **argv) } if (status) { - printf + dfatool_printf ("[::] BFS-UMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_type=%s n_elements=%d " - "| throughput_pim_MBps=%f throughput_MBps=%f", numDPUs, + "| throughput_pim_MBps=%f throughput_MBps=%f", numDPUs, numRanks, NR_TASKLETS, "uint32_t", numNodes, numNodes * sizeof(uint32_t) / (timer.time[2] + timer.time[3]), @@ -423,12 +427,12 @@ int main(int argc, char **argv) timer.time[2] + timer.time[3] + timer.time[4])); - printf(" throughput_pim_MOpps=%f throughput_MOpps=%f", + dfatool_printf(" throughput_pim_MOpps=%f throughput_MOpps=%f", numNodes / (timer.time[2] + timer.time[3]), numNodes / (timer.time[0] + timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4])); - printf + dfatool_printf (" latency_alloc_us=%f latency_load_us=%f latency_write_us=%f latency_kernel_us=%f latency_sync_us=%f latency_read_us=%f latency_cpu_us=%f latency_free_us=%f\n", timer.time[0], timer.time[1], timer.time[2], timer.time[3], timer.time[4], timer.time[5], timer.time[6], diff --git a/BFS/host/mram-management.h b/BFS/host/mram-management.h index f2ee031..61616da 100644 --- a/BFS/host/mram-management.h +++ b/BFS/host/mram-management.h @@ -2,8 +2,8 @@ #ifndef _MRAM_MANAGEMENT_H_ #define _MRAM_MANAGEMENT_H_ -#include "../support/common.h" -#include "../support/utils.h" +#include "common.h" +#include "utils.h" #define DPU_CAPACITY (64 << 20) // A DPU's capacity is 64 MiB diff --git a/BFS/support/common.h b/BFS/include/common.h index 5f2aa0d..5f2aa0d 100644 --- a/BFS/support/common.h +++ b/BFS/include/common.h diff --git a/BFS/include/dfatool_host.ah b/BFS/include/dfatool_host.ah new file mode 100644 index 0000000..592e6ec --- /dev/null +++ b/BFS/include/dfatool_host.ah @@ -0,0 +1,27 @@ +#pragma once + +#include <sys/time.h> +#include "dfatool_host_dpu.ah" + +aspect DfatoolHostTiming : public DfatoolHostDPUTiming { + + virtual int getKernel() { return 1; } + + DfatoolHostTiming() { + element_size = sizeof(uint32_t); + } + + advice call("% input_params(...)"): after() { + printf("[>>] BFS | n_dpus=%u\n", NR_DPUS); + } + + advice call("% coo2csr(...)") : after() { + struct CSRGraph *g = tjp->result(); + input_size = g->numNodes; + printf("[--] BFS | n_dpus=%u n_elements=%lu\n", NR_DPUS, input_size); + } + + advice execution("% main(...)") : after() { + printf("[<<] BFS | n_dpus=%u n_elements=%lu\n", NR_DPUS, input_size); + } +}; diff --git a/BFS/support/graph.h b/BFS/include/graph.h index 2a19f67..2a19f67 100644 --- a/BFS/support/graph.h +++ b/BFS/include/graph.h diff --git a/BFS/support/params.h b/BFS/include/params.h index f9169bc..f9169bc 100644 --- a/BFS/support/params.h +++ b/BFS/include/params.h diff --git a/BFS/include/timer.h b/BFS/include/timer.h new file mode 100644 index 0000000..e85490f --- /dev/null +++ b/BFS/include/timer.h @@ -0,0 +1,8 @@ +#pragma once + +#define N_TIMERS 8 +#define startTimer start +#define stopTimer stop +#define zeroTimer zero +#include "../../include/timer_base.h" +#undef N_TIMERS diff --git a/BFS/support/utils.h b/BFS/include/utils.h index ccd8fbd..ccd8fbd 100644 --- a/BFS/support/utils.h +++ b/BFS/include/utils.h diff --git a/BFS/support/timer.h b/BFS/support/timer.h deleted file mode 100644 index 63b5567..0000000 --- a/BFS/support/timer.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef _TIMER_H_ -#define _TIMER_H_ - -#include <stdio.h> -#include <sys/time.h> - -typedef struct Timer { - struct timeval startTime[8]; - struct timeval stopTime[8]; - double time[8]; -} Timer; - -static void startTimer(Timer *timer, int i, int rep) -{ - if (rep == 0) { - timer->time[i] = 0.0; - } - gettimeofday(&timer->startTime[i], NULL); -} - -static void stopTimer(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); -} - -#endif diff --git a/include/dfatool_host_dpu.ah b/include/dfatool_host_dpu.ah index 0e03d31..010c18c 100644 --- a/include/dfatool_host_dpu.ah +++ b/include/dfatool_host_dpu.ah @@ -12,6 +12,8 @@ aspect DfatoolHostDPUTiming { double const M_to_Mi = 1.048576; /* 2^20 / 1e6 */ + virtual int getKernel() = 0; + advice call("% dpu_get_nr_dpus(...)") : after() { n_dpus = **(tjp->arg<1>()); } @@ -79,7 +81,7 @@ aspect DfatoolHostDPUTiming { tjp->filename(), tjp->line(), n_dpus, n_ranks, - kernel + 1, + getKernel(), input_size, input_size / n_dpus, latency_us, @@ -104,6 +106,22 @@ aspect DfatoolHostDPUTiming { ); } + advice call("% dpu_copy_from(...)") : 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); + printf("[::] dpu_copy_from @ %s:%d | n_dpus=%u n_ranks=%u payload_B=%lu | latency_us=%f throughput_MiBps=%f\n", + tjp->filename(), + tjp->line(), + n_dpus, n_ranks, + payload_size, + time_us, + payload_size / (time_us * M_to_Mi) + ); + } + advice call("% dpu_push_xfer(...)") : around() { size_t payload_size = *(tjp->arg<4>()); gettimeofday(&starttime, NULL); diff --git a/include/timer_base.h b/include/timer_base.h index fed8bec..dcc73b7 100644 --- a/include/timer_base.h +++ b/include/timer_base.h @@ -31,6 +31,11 @@ void stop(Timer *timer, int i) (timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec); } +void zero(Timer *timer, int i) +{ + timer->time[0] = 0; +} + #else #define dfatool_printf(fmt, ...) do {} while (0) @@ -50,4 +55,10 @@ void stop(Timer *timer, int i) (void)i; } +void zero(Timer *timer, int i) +{ + (void)timer; + (void)i; +} + #endif |