11// Author: Arjun Ramaswami
22
3+ #define _POSIX_C_SOURCE 199309L
34#include <stdio.h>
45#include <stdlib.h>
56#include <stdbool.h>
67#include <math.h>
78#include "helper.h"
9+ #include <time.h>
10+ #include <sys/time.h>
11+ #include <math.h>
12+ #define _USE_MATH_DEFINES
813
914/**
1015 * \brief create random single precision complex floating point values
@@ -71,14 +76,21 @@ void print_config(int N, int dim, int iter, int inv, int sp, int use_bram){
7176
7277/**
7378 * \brief print time taken for fpga and fftw runs to a file
79+ * \param total_api_time: time taken to call iter times the host code
7480 * \param timing: kernel execution and pcie transfer timing
7581 * \param N: fft size
7682 * \param dim: number of dimensions of size
7783 * \param iter: number of iterations of each transformation (if BATCH mode)
7884 * \param inv: 1 if backward transform
7985 * \param single precision floating point transformation
8086 */
81- void display_measures (double pcie_rd , double pcie_wr , double exec_t , int N , int dim , int iter , int inv , int sp ){
87+ void display_measures (double total_api_time , double pcie_rd , double pcie_wr , double exec_t , int N , int dim , int iter , int inv , int sp ){
88+
89+ double avg_api_time = 0.0 ;
90+
91+ if (total_api_time != 0.0 ){
92+ avg_api_time = total_api_time / iter ;
93+ }
8294
8395 double pcie_read = pcie_rd / iter ;
8496 double pcie_write = pcie_wr / iter ;
@@ -106,4 +118,18 @@ void display_measures(double pcie_rd, double pcie_wr, double exec_t, int N, int
106118 printf ("Kernel Execution = %.2lfms\n" , exec );
107119 printf ("PCIe Read = %.2lfms\n" , pcie_read );
108120 printf ("Throughput = %.2lfGFLOPS/s | %.2lf GB/s\n" , gflops , gBytes_per_sec );
121+ printf ("Avg API runtime = %.2lfms\n" , avg_api_time );
122+ }
123+
124+ /**
125+ * \brief compute walltime in milliseconds
126+ * \return time in milliseconds
127+ */
128+ double getTimeinMilliseconds (){
129+ struct timespec a ;
130+ if (clock_gettime (CLOCK_MONOTONIC , & a ) != 0 ){
131+ fprintf (stderr , "Error in getting wall clock time \n" );
132+ exit (EXIT_FAILURE );
133+ }
134+ return (double )(a .tv_nsec ) * 1.0e-6 + (double )(a .tv_sec ) * 1.0E3 ;
109135}
0 commit comments