From 3de4b495fb176eba9a0eb517a4ce05903cb67acb Mon Sep 17 00:00:00 2001 From: Juan Gomez Luna Date: Wed, 16 Jun 2021 19:46:05 +0200 Subject: PrIM -- first commit --- HST-L/Makefile | 46 +++++++ HST-L/dpu/task.c | 142 +++++++++++++++++++ HST-L/host/app.c | 285 +++++++++++++++++++++++++++++++++++++++ HST-L/input/image_VanHateren.iml | Bin 0 -> 3145728 bytes HST-L/run.sh | 17 +++ HST-L/support/common.h | 45 +++++++ HST-L/support/params.h | 67 +++++++++ HST-L/support/timer.h | 59 ++++++++ 8 files changed, 661 insertions(+) create mode 100644 HST-L/Makefile create mode 100644 HST-L/dpu/task.c create mode 100644 HST-L/host/app.c create mode 100644 HST-L/input/image_VanHateren.iml create mode 100755 HST-L/run.sh create mode 100755 HST-L/support/common.h create mode 100644 HST-L/support/params.h create mode 100755 HST-L/support/timer.h (limited to 'HST-L') diff --git a/HST-L/Makefile b/HST-L/Makefile new file mode 100644 index 0000000..fb1ce5a --- /dev/null +++ b/HST-L/Makefile @@ -0,0 +1,46 @@ +DPU_DIR := dpu +HOST_DIR := host +BUILDDIR ?= bin +NR_TASKLETS ?= 16 +BL ?= 8 +NR_DPUS ?= 1 +NR_HISTO ?= 1 +ENERGY ?= 0 + +define conf_filename + ${BUILDDIR}/.NR_DPUS_$(1)_NR_TASKLETS_$(2)_BL_$(3)_NR_DPUS_$(4).conf +endef +CONF := $(call conf_filename,${NR_DPUS},${NR_TASKLETS},${BL},${NR_DPUS}) + +HOST_TARGET := ${BUILDDIR}/host_code +DPU_TARGET := ${BUILDDIR}/dpu_code + +COMMON_INCLUDES := support +HOST_SOURCES := $(wildcard ${HOST_DIR}/*.c) +DPU_SOURCES := $(wildcard ${DPU_DIR}/*.c) + +.PHONY: all clean test + +__dirs := $(shell mkdir -p ${BUILDDIR}) + +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} -DENERGY=${ENERGY} +DPU_FLAGS := ${COMMON_FLAGS} -O2 -DNR_TASKLETS=${NR_TASKLETS} -DBL=${BL} -DNR_HISTO=${NR_HISTO} + +all: ${HOST_TARGET} ${DPU_TARGET} + +${CONF}: + $(RM) $(call conf_filename,*,*) + touch ${CONF} + +${HOST_TARGET}: ${HOST_SOURCES} ${COMMON_INCLUDES} ${CONF} + $(CC) -o $@ ${HOST_SOURCES} ${HOST_FLAGS} + +${DPU_TARGET}: ${DPU_SOURCES} ${COMMON_INCLUDES} ${CONF} + dpu-upmem-dpurte-clang ${DPU_FLAGS} -o $@ ${DPU_SOURCES} + +clean: + $(RM) -r $(BUILDDIR) + +test: all + ./${HOST_TARGET} diff --git a/HST-L/dpu/task.c b/HST-L/dpu/task.c new file mode 100644 index 0000000..356b2f9 --- /dev/null +++ b/HST-L/dpu/task.c @@ -0,0 +1,142 @@ +/* +* Histogram (HST-L) with multiple tasklets +* +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../support/common.h" + +__host dpu_arguments_t DPU_INPUT_ARGUMENTS; + +// Array for communication between adjacent tasklets +uint32_t* message[NR_TASKLETS]; +// DPU histogram +uint32_t* histo_dpu; + +// Barrier +BARRIER_INIT(my_barrier, NR_TASKLETS); +ATOMIC_BIT_INIT(barriers_mutexes)[NR_HISTO]; +barrier_t barriers[NR_HISTO]; + +// Mutex +mutex_id_t my_mutex[NR_HISTO]; + +// Histogram in each tasklet +static void histogram(uint32_t* histo, uint32_t bins, T *input, uint32_t histo_id, unsigned int l_size){ + for(unsigned int j = 0; j < l_size; j++) { + T d = (input[j] * bins) >> DEPTH; + mutex_lock(my_mutex[histo_id]); + histo[d] += 1; + mutex_unlock(my_mutex[histo_id]); + } +} + +extern int main_kernel1(void); + +int (*kernels[nr_kernels])(void) = {main_kernel1}; + +int main(void) { + // Kernel + return kernels[DPU_INPUT_ARGUMENTS.kernel](); +} + +// main_kernel1 +int main_kernel1() { + unsigned int tasklet_id = me(); +#if PRINT + printf("tasklet_id = %u\n", tasklet_id); +#endif + unsigned int l_tasklet_id = tasklet_id / NR_HISTO; + unsigned int nr_l_tasklet = NR_TASKLETS / NR_HISTO; + unsigned int my_histo_id = tasklet_id & (NR_HISTO - 1); + + if (tasklet_id == 0){ // Initialize once the cycle counter + mem_reset(); // Reset the heap + // Initialize barriers + for (unsigned int each_barrier = 0; each_barrier < NR_HISTO; each_barrier++) { + barriers[each_barrier].wait_queue = 0xff; + barriers[each_barrier].count = nr_l_tasklet; + barriers[each_barrier].initial_count = nr_l_tasklet; + barriers[each_barrier].lock = (uint8_t) &ATOMIC_BIT_GET(barriers_mutexes)[each_barrier]; + } + } + // Barrier + barrier_wait(&my_barrier); + + uint32_t input_size_dpu_bytes = DPU_INPUT_ARGUMENTS.size; + uint32_t input_size_dpu_bytes_transfer = DPU_INPUT_ARGUMENTS.transfer_size; // Transfer input size per DPU in bytes + uint32_t bins = DPU_INPUT_ARGUMENTS.bins; + + // Address of the current processing block in MRAM + uint32_t base_tasklet = tasklet_id << BLOCK_SIZE_LOG2; + uint32_t mram_base_addr_A = (uint32_t)DPU_MRAM_HEAP_POINTER; + uint32_t mram_base_addr_histo = (uint32_t)(DPU_MRAM_HEAP_POINTER + input_size_dpu_bytes_transfer); + + // Initialize a local cache to store the MRAM block + T *cache_A = (T *) mem_alloc(BLOCK_SIZE); + + // Local histogram + if (tasklet_id < NR_HISTO){ // Allocate DPU histogram + uint32_t *histo = (uint32_t *) mem_alloc(bins * sizeof(uint32_t)); + message[tasklet_id] = histo; + } + // Barrier + barrier_wait(&barriers[my_histo_id]); + + uint32_t *my_histo = message[my_histo_id]; + + // Initialize local histogram + for(unsigned int i = l_tasklet_id; i < bins; i += nr_l_tasklet){ + my_histo[i] = 0; + } + // Barrier + barrier_wait(&barriers[my_histo_id]); + + // Compute histogram + for(unsigned int byte_index = base_tasklet; byte_index < input_size_dpu_bytes; byte_index += BLOCK_SIZE * NR_TASKLETS){ + + // Bound checking + uint32_t l_size_bytes = (byte_index + BLOCK_SIZE >= input_size_dpu_bytes) ? (input_size_dpu_bytes - byte_index) : BLOCK_SIZE; + + // Load cache with current MRAM block + mram_read((const __mram_ptr void*)(mram_base_addr_A + byte_index), cache_A, l_size_bytes); + + // Histogram in each tasklet + histogram(my_histo, bins, cache_A, my_histo_id, l_size_bytes >> DIV); + } + + // Barrier + barrier_wait(&my_barrier); + + uint32_t *histo_dpu = message[0]; + for (unsigned int i = tasklet_id; i < bins; i += NR_TASKLETS){ + uint32_t b = 0; + for (unsigned int j = 0; j < NR_HISTO; j++){ + b += *(message[j] + i); + } + histo_dpu[i] = b; + } + + // Barrier + barrier_wait(&my_barrier); + + // Write dpu histogram to current MRAM block + if(tasklet_id == 0){ + if(bins * sizeof(uint32_t) <= 2048) + mram_write(histo_dpu, (__mram_ptr void*)(mram_base_addr_histo), bins * sizeof(uint32_t)); + else + for(unsigned int offset = 0; offset < ((bins * sizeof(uint32_t)) >> 11); offset++){ + mram_write(histo_dpu + (offset << 9), (__mram_ptr void*)(mram_base_addr_histo + (offset << 11)), 2048); + } + } + + return 0; +} diff --git a/HST-L/host/app.c b/HST-L/host/app.c new file mode 100644 index 0000000..09ab578 --- /dev/null +++ b/HST-L/host/app.c @@ -0,0 +1,285 @@ +/** +* app.c +* HST-L Host Application Source File +* +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../support/common.h" +#include "../support/timer.h" +#include "../support/params.h" + +// Define the DPU Binary path as DPU_BINARY here +#ifndef DPU_BINARY +#define DPU_BINARY "./bin/dpu_code" +#endif + +#if ENERGY +#include +#endif + +// Pointer declaration +static T* A; +static unsigned int* histo_host; +static unsigned int* histo; + +// Create input arrays +static void read_input(T* A, const Params p) { + + char dctFileName[100]; + FILE *File = NULL; + + // Open input file + unsigned short temp; + sprintf(dctFileName, p.file_name); + if((File = fopen(dctFileName, "rb")) != NULL) { + for(unsigned int y = 0; y < p.input_size; y++) { + fread(&temp, sizeof(unsigned short), 1, File); + A[y] = (unsigned int)ByteSwap16(temp); + if(A[y] >= 4096) + A[y] = 4095; + } + fclose(File); + } else { + printf("%s does not exist\n", dctFileName); + exit(1); + } +} + +// Compute output in the host +static void histogram_host(unsigned int* histo, T* A, unsigned int bins, unsigned int nr_elements, int exp, unsigned int nr_of_dpus) { + if(!exp){ + for (unsigned int i = 0; i < nr_of_dpus; i++) { + for (unsigned int j = 0; j < nr_elements; j++) { + T d = A[j]; + histo[i * bins + ((d * bins) >> DEPTH)] += 1; + } + } + } + else{ + for (unsigned int j = 0; j < nr_elements; j++) { + T d = A[j]; + histo[(d * bins) >> DEPTH] += 1; + } + } +} + +// Main of the Host Application +int main(int argc, char **argv) { + + struct Params p = input_params(argc, argv); + + struct dpu_set_t dpu_set, dpu; + uint32_t nr_of_dpus; + +#if ENERGY + struct dpu_probe_t probe; + DPU_ASSERT(dpu_probe_init("energy_probe", &probe)); +#endif + + // Allocate DPUs and load binary + DPU_ASSERT(dpu_alloc(NR_DPUS, NULL, &dpu_set)); + DPU_ASSERT(dpu_load(dpu_set, DPU_BINARY, NULL)); + DPU_ASSERT(dpu_get_nr_dpus(dpu_set, &nr_of_dpus)); + printf("Allocated %d DPU(s)\n", nr_of_dpus); + + unsigned int i = 0; + unsigned int input_size; // Size of input image + unsigned int dpu_s = p.dpu_s; + if(p.exp == 0) + input_size = p.input_size * nr_of_dpus; // Size of input image + else if(p.exp == 1) + input_size = p.input_size; // Size of input image + else + input_size = p.input_size * dpu_s; // Size of input image + + const unsigned int input_size_8bytes = + ((input_size * sizeof(T)) % 8) != 0 ? roundup(input_size, 8) : input_size; // Input size per DPU (max.), 8-byte aligned + const unsigned int input_size_dpu = divceil(input_size, nr_of_dpus); // Input size per DPU (max.) + const unsigned int input_size_dpu_8bytes = + ((input_size_dpu * sizeof(T)) % 8) != 0 ? roundup(input_size_dpu, 8) : input_size_dpu; // Input size per DPU (max.), 8-byte aligned + + // Input/output allocation + A = malloc(input_size_dpu_8bytes * nr_of_dpus * sizeof(T)); + T *bufferA = A; + histo_host = malloc(p.bins * sizeof(unsigned int)); + histo = malloc(nr_of_dpus * p.bins * sizeof(unsigned int)); + + // Create an input file with arbitrary data + read_input(A, p); + if(p.exp == 0){ + for(unsigned int j = 1; j < nr_of_dpus; j++){ + memcpy(&A[j * input_size_dpu_8bytes], &A[0], input_size_dpu_8bytes * sizeof(T)); + } + } + else if(p.exp == 2){ + for(unsigned int j = 1; j < dpu_s; j++) + memcpy(&A[j * p.input_size], &A[0], p.input_size * sizeof(T)); + } + + // Timer declaration + Timer timer; + + printf("NR_TASKLETS\t%d\tBL\t%d\tinput_size\t%u\n", NR_TASKLETS, BL, input_size); + + // Loop over main kernel + for(int rep = 0; rep < p.n_warmup + p.n_reps; rep++) { + memset(histo_host, 0, p.bins * sizeof(unsigned int)); + memset(histo, 0, nr_of_dpus * p.bins * sizeof(unsigned int)); + + // Compute output on CPU (performance comparison and verification purposes) + if(rep >= p.n_warmup) + start(&timer, 0, rep - p.n_warmup); + histogram_host(histo_host, A, p.bins, p.input_size, 1, nr_of_dpus); + if(rep >= p.n_warmup) + stop(&timer, 0); + + printf("Load input data\n"); + if(rep >= p.n_warmup) + start(&timer, 1, rep - p.n_warmup); + // Input arguments + unsigned int kernel = 0; + i = 0; + dpu_arguments_t input_arguments[NR_DPUS]; + for(i=0; i= p.n_warmup) + stop(&timer, 1); + + printf("Run program on DPU(s) \n"); + // Run DPU kernel + if(rep >= p.n_warmup) { + start(&timer, 2, rep - p.n_warmup); + #if ENERGY + DPU_ASSERT(dpu_probe_start(&probe)); + #endif + } + DPU_ASSERT(dpu_launch(dpu_set, DPU_SYNCHRONOUS)); + if(rep >= p.n_warmup) { + stop(&timer, 2); + #if ENERGY + DPU_ASSERT(dpu_probe_stop(&probe)); + #endif + } + +#if PRINT + { + unsigned int each_dpu = 0; + printf("Display DPU Logs\n"); + DPU_FOREACH (dpu_set, dpu) { + printf("DPU#%d:\n", each_dpu); + DPU_ASSERT(dpulog_read_for_dpu(dpu.dpu, stdout)); + each_dpu++; + } + } +#endif + + printf("Retrieve results\n"); + i = 0; + if(rep >= p.n_warmup) + start(&timer, 3, rep - p.n_warmup); + // PARALLEL RETRIEVE TRANSFER + DPU_FOREACH(dpu_set, dpu, i) { + DPU_ASSERT(dpu_prepare_xfer(dpu, histo + p.bins * i)); + } + DPU_ASSERT(dpu_push_xfer(dpu_set, DPU_XFER_FROM_DPU, DPU_MRAM_HEAP_POINTER_NAME, input_size_dpu_8bytes * sizeof(T), p.bins * sizeof(unsigned int), DPU_XFER_DEFAULT)); + + // Final histogram merging + for(i = 1; i < nr_of_dpus; i++){ + for(unsigned int j = 0; j < p.bins; j++){ + histo[j] += histo[j + i * p.bins]; + } + } + if(rep >= p.n_warmup) + stop(&timer, 3); + + } + + // Print timing results + printf("CPU "); + print(&timer, 0, p.n_reps); + printf("CPU-DPU "); + print(&timer, 1, p.n_reps); + printf("DPU Kernel "); + print(&timer, 2, p.n_reps); + printf("DPU-CPU "); + print(&timer, 3, p.n_reps); + + #if ENERGY + double energy; + DPU_ASSERT(dpu_probe_get(&probe, DPU_ENERGY, DPU_AVERAGE, &energy)); + printf("DPU Energy (J): %f\t", energy); + #endif + + + // Check output + bool status = true; + if(p.exp == 1) + for (unsigned int j = 0; j < p.bins; j++) { + if(histo_host[j] != histo[j]){ + status = false; +#if PRINT + printf("%u - %u: %u -- %u\n", j, j, histo_host[j], histo[j]); +#endif + } + } + else if(p.exp == 2) + for (unsigned int j = 0; j < p.bins; j++) { + if(dpu_s * histo_host[j] != histo[j]){ + status = false; +#if PRINT + printf("%u - %u: %u -- %u\n", j, j, dpu_s * histo_host[j], histo[j]); +#endif + } + } + else + for (unsigned int j = 0; j < p.bins; j++) { + if(nr_of_dpus * histo_host[j] != histo[j]){ + status = false; +#if PRINT + printf("%u - %u: %u -- %u\n", j, j, nr_of_dpus * histo_host[j], histo[j]); +#endif + } + } + if (status) { + printf("[" ANSI_COLOR_GREEN "OK" ANSI_COLOR_RESET "] Outputs are equal\n"); + } else { + printf("[" ANSI_COLOR_RED "ERROR" ANSI_COLOR_RESET "] Outputs differ!\n"); + } + + // Deallocation + free(A); + free(histo_host); + free(histo); + DPU_ASSERT(dpu_free(dpu_set)); + + return status ? 0 : -1; +} diff --git a/HST-L/input/image_VanHateren.iml b/HST-L/input/image_VanHateren.iml new file mode 100644 index 0000000..1ae6047 Binary files /dev/null and b/HST-L/input/image_VanHateren.iml differ diff --git a/HST-L/run.sh b/HST-L/run.sh new file mode 100755 index 0000000..d2a072f --- /dev/null +++ b/HST-L/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +for i in 1 +do + for b in 64 128 256 512 1024 2048 4096 + do + for k in 1 2 4 8 16 + do + NR_DPUS=$i NR_TASKLETS=$k BL=10 make all + wait + ./bin/host_code -w 2 -e 5 -b ${b} > profile/HSTL_${b}_tl${k}_dpu${i}.txt + wait + make clean + wait + done + done +done diff --git a/HST-L/support/common.h b/HST-L/support/common.h new file mode 100755 index 0000000..30df40d --- /dev/null +++ b/HST-L/support/common.h @@ -0,0 +1,45 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +// Transfer size between MRAM and WRAM +#ifdef BL +#define BLOCK_SIZE_LOG2 BL +#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2) +#else +#define BLOCK_SIZE_LOG2 8 +#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2) +#define BL BLOCK_SIZE_LOG2 +#endif + +// Data type +#define T uint32_t +#define DIV 2 // Shift right to divide by sizeof(T) +#define REGS (BLOCK_SIZE >> 2) // 32 bits + +// Pixel depth +#define DEPTH 12 +#define ByteSwap16(n) (((((unsigned int)n) << 8) & 0xFF00) | ((((unsigned int)n) >> 8) & 0x00FF)) + +// Structures used by both the host and the dpu to communicate information +typedef struct { + uint32_t size; + uint32_t transfer_size; + uint32_t bins; + enum kernels { + kernel1 = 0, + nr_kernels = 1, + } kernel; +} dpu_arguments_t; + +#ifndef ENERGY +#define ENERGY 0 +#endif +#define PRINT 0 + +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_GREEN "\x1b[32m" +#define ANSI_COLOR_RESET "\x1b[0m" + +#define divceil(n, m) (((n)-1) / (m) + 1) +#define roundup(n, m) ((n / m) * m + m) +#endif diff --git a/HST-L/support/params.h b/HST-L/support/params.h new file mode 100644 index 0000000..e29449b --- /dev/null +++ b/HST-L/support/params.h @@ -0,0 +1,67 @@ +#ifndef _PARAMS_H_ +#define _PARAMS_H_ + +#include "common.h" + +typedef struct Params { + unsigned int input_size; + unsigned int bins; + int n_warmup; + int n_reps; + const char *file_name; + int exp; + int dpu_s; +}Params; + +static void usage() { + fprintf(stderr, + "\nUsage: ./program [options]" + "\n" + "\nGeneral options:" + "\n -h help" + "\n -w # of untimed warmup iterations (default=1)" + "\n -e # of timed repetition iterations (default=3)" + "\n -x Weak (0) or strong (1, 2) scaling (default=0)" + "\n" + "\nBenchmark-specific options:" + "\n -i input size (default=1536*1024 elements)" + "\n -b histogram size (default=256 bins)" + "\n -f input image file (default=../input/image_VanHateren.iml)" + "\n"); +} + +struct Params input_params(int argc, char **argv) { + struct Params p; + p.input_size = 1536 * 1024; + p.bins = 256; + p.n_warmup = 1; + p.n_reps = 3; + p.exp = 0; + p.file_name = "./input/image_VanHateren.iml"; + p.dpu_s = 64; + + int opt; + while((opt = getopt(argc, argv, "hi:b:w:e:f:x:z:")) >= 0) { + switch(opt) { + case 'h': + usage(); + exit(0); + break; + case 'i': p.input_size = atoi(optarg); break; + case 'b': p.bins = atoi(optarg); break; + case 'w': p.n_warmup = atoi(optarg); break; + case 'e': p.n_reps = atoi(optarg); break; + case 'f': p.file_name = optarg; break; + case 'x': p.exp = atoi(optarg); break; + case 'z': p.dpu_s = atoi(optarg); break; + default: + fprintf(stderr, "\nUnrecognized option!\n"); + usage(); + exit(0); + } + } + assert(NR_DPUS > 0 && "Invalid # of dpus!"); + + return p; +} +#endif diff --git a/HST-L/support/timer.h b/HST-L/support/timer.h new file mode 100755 index 0000000..eedc385 --- /dev/null +++ b/HST-L/support/timer.h @@ -0,0 +1,59 @@ +/* + * 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 + +typedef struct Timer{ + + struct timeval startTime[4]; + struct timeval stopTime[4]; + double time[4]; + +}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); +} + +void print(Timer *timer, int i, int REP) { printf("Time (ms): %f\t", timer->time[i] / (1000 * REP)); } -- cgit v1.2.3