diff options
Diffstat (limited to 'TRNS/host')
-rw-r--r-- | TRNS/host/app.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/TRNS/host/app.c b/TRNS/host/app.c index 452b894..c178a19 100644 --- a/TRNS/host/app.c +++ b/TRNS/host/app.c @@ -7,16 +7,32 @@ #include <stdlib.h> #include <stdbool.h> #include <string.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 + #include <unistd.h> #include <getopt.h> #include <assert.h> #include <math.h> -#include "../support/common.h" -#include "../support/timer.h" -#include "../support/params.h" +#include "common.h" +#include "timer.h" +#include "params.h" #define XSTR(x) STR(x) #define STR(x) #x @@ -26,18 +42,13 @@ #define DPU_BINARY "./bin/dpu_code" #endif -#if ENERGY -#include <dpu_probe.h> -#endif - -#include <dpu_management.h> -#include <dpu_target_macros.h> - // Pointer declaration static T* A_host; static T* A_backup; static T* A_result; +unsigned int kernel = 0; + // Create input arrays static void read_input(T* A, unsigned int nr_elements) { srand(0); @@ -84,10 +95,10 @@ int main(int argc, char **argv) { N_ = p.exp == 0 ? N_ * NR_DPUS : N_; // Input/output allocation - A_host = malloc(M_ * m * N_ * n * sizeof(T)); - A_backup = malloc(M_ * m * N_ * n * sizeof(T)); - A_result = malloc(M_ * m * N_ * n * sizeof(T)); - T* done_host = malloc(M_ * n); // Host array to reset done array of step 3 + A_host = (T*)malloc(M_ * m * N_ * n * sizeof(T)); + A_backup = (T*)malloc(M_ * m * N_ * n * sizeof(T)); + A_result = (T*)malloc(M_ * m * N_ * n * sizeof(T)); + T* done_host = (T*)malloc(M_ * n); // Host array to reset done array of step 3 memset(done_host, 0, M_ * n); // Create an input file with arbitrary data @@ -131,6 +142,7 @@ int main(int argc, char **argv) { DPU_ASSERT(dpu_load(dpu_set, DPU_BINARY, NULL)); stop(&timer, 2); DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &nr_of_dpus)); + DPU_ASSERT(dpu_get_nr_ranks(dpu_set, &nr_of_ranks)); } else if (first_round){ start(&timer, 1, 0); DPU_ASSERT(dpu_alloc(active_dpus, NULL, &dpu_set)); @@ -174,8 +186,8 @@ int main(int argc, char **argv) { start(&timer, 5, !first_round); } - unsigned int kernel = 0; - dpu_arguments_t input_arguments = {m, n, M_, kernel}; + kernel = 0; + dpu_arguments_t input_arguments = {m, n, M_, (enum kernels)kernel}; // transfer control instructions to DPUs (run first program part) DPU_FOREACH(dpu_set, dpu, i) { DPU_ASSERT(dpu_prepare_xfer(dpu, &input_arguments)); @@ -215,7 +227,7 @@ int main(int argc, char **argv) { start(&timer, 7, !first_round); } kernel = 1; - dpu_arguments_t input_arguments2 = {m, n, M_, kernel}; + dpu_arguments_t input_arguments2 = {m, n, M_, (enum kernels)kernel}; DPU_FOREACH(dpu_set, dpu, i) { DPU_ASSERT(dpu_prepare_xfer(dpu, &input_arguments2)); } @@ -299,7 +311,9 @@ int main(int argc, char **argv) { } if (status) { printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); +#if DFATOOL_TIMING unsigned long input_size = M_ * m * N_ * n; +#endif if (rep >= p.n_warmup) { /* * timer 0: CPU version @@ -313,35 +327,35 @@ int main(int argc, char **argv) { * timer 8: run DPU program (second kernel) * timer 9: read transposed matrix */ - printf("[::] TRNS-UPMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_type=%s n_elements=%lu numa_node_rank=%d ", + dfatool_printf("[::] TRNS-UPMEM | n_dpus=%d n_ranks=%d n_tasklets=%d e_type=%s n_elements=%lu numa_node_rank=%d ", NR_DPUS, nr_of_ranks, NR_TASKLETS, XSTR(T), input_size, numa_node_rank); - printf("| latency_cpu_us=%f latency_realloc_us=%f latency_load_us=%f latency_write_us=%f latency_kernel_us=%f latency_read_us=%f", + dfatool_printf("| latency_cpu_us=%f latency_realloc_us=%f latency_load_us=%f latency_write_us=%f latency_kernel_us=%f latency_read_us=%f", timer.time[0], // CPU timer.time[1], // free + alloc timer.time[2], // load timer.time[3] + timer.time[4] + timer.time[5] + timer.time[7], // write timer.time[6] + timer.time[8], // kernel timer.time[9]); // read - printf(" latency_write1_us=%f latency_write2_us=%f latency_write3_us=%f latency_write4_us=%f latency_kernel1_us=%f latency_kernel2_us=%f", + dfatool_printf(" latency_write1_us=%f latency_write2_us=%f latency_write3_us=%f latency_write4_us=%f latency_kernel1_us=%f latency_kernel2_us=%f", timer.time[3], timer.time[4], timer.time[5], timer.time[7], timer.time[6], timer.time[8]); - printf(" throughput_cpu_MBps=%f throughput_upmem_kernel_MBps=%f throughput_upmem_total_MBps=%f", + dfatool_printf(" throughput_cpu_MBps=%f throughput_upmem_kernel_MBps=%f throughput_upmem_total_MBps=%f", input_size * sizeof(T) / timer.time[0], input_size * sizeof(T) / (timer.time[6] + timer.time[8]), input_size * sizeof(T) / (timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9])); - printf(" throughput_upmem_wxr_MBps=%f throughput_upmem_lwxr_MBps=%f throughput_upmem_alwxr_MBps=%f", + dfatool_printf(" throughput_upmem_wxr_MBps=%f throughput_upmem_lwxr_MBps=%f throughput_upmem_alwxr_MBps=%f", input_size * sizeof(T) / (timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9]), input_size * sizeof(T) / (timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9]), input_size * sizeof(T) / (timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9])); - printf(" throughput_cpu_MOpps=%f throughput_upmem_kernel_MOpps=%f throughput_upmem_total_MOpps=%f", + dfatool_printf(" throughput_cpu_MOpps=%f throughput_upmem_kernel_MOpps=%f throughput_upmem_total_MOpps=%f", input_size / timer.time[0], input_size / (timer.time[6] + timer.time[8]), input_size / (timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9])); - printf(" throughput_upmem_wxr_MOpps=%f throughput_upmem_lwxr_MOpps=%f throughput_upmem_alwxr_MOpps=%f\n", + dfatool_printf(" throughput_upmem_wxr_MOpps=%f throughput_upmem_lwxr_MOpps=%f throughput_upmem_alwxr_MOpps=%f\n", input_size / (timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9]), input_size / (timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9]), input_size / (timer.time[1] + timer.time[2] + timer.time[3] + timer.time[4] + timer.time[5] + timer.time[6] + timer.time[7] + timer.time[8] + timer.time[9])); |