Why is there difference in Time mesure between cudaEventSynchronize and cudaDevice Synchronize

Hello,

I fanced on the problem in the way of time measurement of CUDA code.

I want to know the reason why there is deifference between “cudaEventSynchronize” and “cudaDeviceSynchronize”.

I made very simple sample code of 1D-FIR FILTER by using CUDA unified memory as below.

I mesured the process time of kernel(GPU);GPU is Geforc GTX750Ti.
I used two way to measure time,one is cudaEventSynchronize and another is cudaDeviceSynchronize.

The result is as blow URL.
I checked the profile by Nsight.

I wonder why was there long interval when the CudaDeviceSynchronize was used.

https://www.dropbox.com/s/lc80bzv7w2xpikn/cudaTime_Measure.pdf?dl=0

=============code=============

#define _USE_MATH_DEFINES
// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <timer.h>

// includes, project
#include <cuda_runtime.h>
#include <helper_functions.h>
#include <helper_cuda.h>

#define dataLen 2434
#define tapNo 33

int LoopRound = 4;
int dataLength = 2434;

int tapNum = 33;

float elapsed_time0_ms=0.0f;
float elapsed_time1_ms=0.0f;

int i;

cudaEvent_t ustart0, ustop0;
cudaEvent_t ustart1, ustop1;
cudaEvent_t ustart2, ustop2;

////
//* GPU(Kernel Code) *//
//
//

//Unifyed Memory Kernel Code
global void FIR_1D_Kernel(float *srcData,float *blurData,float *filter,int halfTap,int tapNum ,int dataLength)
{

	unsigned int ix = threadIdx.x + blockIdx.x*blockDim.x;
	
	

    int i = 0;
	
	if((ix >= halfTap) && (ix<(dataLength + tapNum -1 - halfTap))){
	
		float sum = 0.0f;
		//Convolituon 
		for(i= 0 ;i <tapNum ;++i){
			sum += filter[i]*srcData[ix-halfTap+i];
		}

		//Filter Out Shift
		blurData[ix-halfTap] = sum;
		

	}//if

}

//***************************
// MAIN Function (Host CPU)
//***************************

int main(int argc, char *argv)
{

//GPU Setting

//Set device
checkCudaErrors(cudaSetDevice(0));

//CUDA Time MeasureEvent Create

cudaEventCreate( &ustart0 );
cudaEventCreate( &ustop0  );
cudaEventCreate( &ustart1 );
cudaEventCreate( &ustop1  );
cudaEventCreate( &ustart2 );
cudaEventCreate( &ustop2  );

//*********************************************//
//
1D FIR FILTER Unifyed Memory Sample Code **//
//**********************************************//

FILE *fp0;

float *srcData;
float *blurData;
float *filter;


//Input Data
float src[dataLen]
={
	-4.000000,3.000000,10.000000,8.000000,-4.000000,-51.000000,-23.000000,136.000000,-20.000000,-104.000000,26.000000,26.000000,-59.000000,155.000000,-34.000000,-145.000000,50.000000,13.000000,76.000000,16.000000,-47.000000,-95.000000,4.000000,152.000000,-3.000000,-69.000000,-53.000000,-7.000000,117.000000,-33.000000,-13.000000,-18.000000,-9.000000,3.000000,20.000000,38.000000,-72.000000,33.000000,21.000000,-93.000000,55.000000,106.000000,-77.000000,-90.000000,44.000000,56.000000,-16.000000,78.000000,-153.000000,-39.000000,147.000000,77.000000,-130.000000,-142.000000,181.000000,63.000000,-123.000000,34.000000,-21.000000,-45.000000,92.000000,39.000000,-59.000000,-96.000000,52.000000,121.000000,-76.000000,-65.000000,59.000000,23.000000,-27.000000,-83.000000,152.000000,-71.000000,30.000000,-94.000000,48.000000,47.000000,52.000000,-144.000000,-13.000000,176.000000,-138.000000,32.000000,54.000000,-62.000000,-25.000000,3.000000,152.000000,-115.000000,-84.000000,60.000000,126.000000,-134.000000,-36.000000,117.000000,-6.000000,-55.000000,-101.000000,131.000000,22.000000,87.000000,-273.000000,45.000000,211.000000,-78.000000,-108.000000,85.000000,37.000000,-93.000000,9.000000,2.000000,86.000000,-11.000000,8.000000,-208.000000,88.000000,210.000000,-104.000000,-33.000000,-145.000000,163.000000,36.000000,-43.000000,-71.000000,54.000000,39.000000,-85.000000,96.000000,-118.000000,104.000000,-53.000000,-12.000000,91.000000,-71.000000,-48.000000,51.000000,7.000000,56.000000,-113.000000,81.000000,-8.000000,-132.000000,190.000000,-11.000000,-159.000000,82.000000,48.000000,43.000000,-135.000000,-29.000000,64.000000,163.000000,-90.000000,-171.000000,59.000000,138.000000,-57.000000,-32.000000,25.000000,-11.000000,-56.000000,73.000000,-65.000000,173.000000,-149.000000,-78.000000,89.000000,97.000000,-116.000000,55.000000,-47.000000,-32.000000,62.000000,50.000000,-72.000000,26.000000,-42.000000,-69.000000,225.000000,-89.000000,-91.000000,-18.000000,102.000000,73.000000,-165.000000,25.000000,82.000000,-77.000000,80.000000,-69.000000,30.000000,10.000000,-76.000000,73.000000,26.000000,-3.000000,-112.000000,86.000000,-35.000000,62.000000,-3.000000,-40.000000,-59.000000,73.000000,20.000000,-34.000000,-11.000000,35.000000,-26.000000,-42.000000,95.000000,-40.000000,-77.000000,139.000000,-114.000000,58.000000,-61.000000,86.000000,-12.000000,-111.000000,136.000000,-66.000000,14.000000,5.000000,-19.000000,25.000000,-12.000000,-27.000000,65.000000,-62.000000,-10.000000,111.000000,-137.000000,-4.000000,100.000000,30.000000,-145.000000,-40.000000,119.000000,51.000000,-56.000000,-104.000000,-17.000000,136.000000,8.000000,-88.000000,-10.000000,5.000000,-8.000000,39.000000,23.000000,-57.000000,62.000000,-95.000000,4.000000,131.000000,16.000000,-95.000000,-74.000000,105.000000,68.000000,-61.000000,11.000000,9.000000,-66.000000,88.000000,49.000000,-85.000000,-51.000000,123.000000,-21.000000,-44.000000,-11.000000,20.000000,21.000000,-3.000000,-35.000000,16.000000,1.000000,-4.000000,-4.000000,-2.000000,0.000000,0.000000,-1.000000,-1.000000,-1.000000,-1.000000,-2.000000,-3.000000,-2.000000,0.000000,2.000000,-2.000000,-9.000000,-12.000000,-3.000000,13.000000,17.000000,-7.000000,-43.000000,-34.000000,97.000000,-13.000000,-70.000000,16.000000,76.000000,-104.000000,27.000000,43.000000,6.000000,-31.000000,-36.000000,10.000000,114.000000,-149.000000,18.000000,167.000000,-167.000000,-56.000000,69.000000,204.000000,-181.000000,-97.000000,-3.000000,167.000000,-7.000000,-26.000000,-134.000000,33.000000,127.000000,-83.000000,3.000000,0.000000,28.000000,5.000000,-91.000000,24.000000,135.000000,-121.000000,53.000000,-24.000000,-29.000000,35.000000,15.000000,15.000000,-18.000000,-29.000000,26.000000,10.000000,2.000000,-4.000000,-1.000000,-19.000000,21.000000,25.000000,-3.000000,-38.000000,-29.000000,81.000000,-21.000000,-40.000000,84.000000,-7.000000,-133.000000,13.000000,168.000000,2.000000,-89.000000,-98.000000,47.000000,129.000000,-34.000000,-2.000000,-109.000000,34.000000,96.000000,-42.000000,-39.000000,58.000000,-62.000000,-28.000000,115.000000,-4.000000,-88.000000,-31.000000,73.000000,70.000000,-51.000000,-86.000000,33.000000,60.000000,15.000000,-29.000000,-57.000000,51.000000,58.000000,-28.000000,-87.000000,22.000000,103.000000,-22.000000,-97.000000,34.000000,46.000000,-24.000000,-5.000000,-22.000000,37.000000,49.000000,-147.000000,8.000000,147.000000,-14.000000,-105.000000,-41.000000,92.000000,60.000000,-72.000000,-37.000000,-6.000000,47.000000,86.000000,-109.000000,-90.000000,100.000000,83.000000,-61.000000,-50.000000,-34.000000,41.000000,82.000000,-44.000000,-30.000000,-28.000000,0.000000,39.000000,36.000000,-29.000000,-42.000000,5.000000,20.000000,41.000000,-22.000000,-7.000000,-43.000000,29.000000,66.000000,-21.000000,-64.000000,-1.000000,74.000000,0.000000,-40.000000,17.000000,2.000000,-55.000000,62.000000,39.000000,-51.000000,-18.000000,10.000000,-15.000000,30.000000,43.000000,-59.000000,-17.000000,-8.000000,45.000000,21.000000,-33.000000,-22.000000,4.000000,5.000000,29.000000,4.000000,-54.000000,14.000000,18.000000,7.000000,-4.000000,-6.000000,-18.000000,8.000000,35.000000,-29.000000,-7.000000,-9.000000,30.000000,26.000000,-65.000000,-11.000000,32.000000,44.000000,-15.000000,-51.000000,-23.000000,44.000000,45.000000,-29.000000,-13.000000,-35.000000,13.000000,48.000000,-11.000000,-31.000000,23.000000,-14.000000,-23.000000,57.000000,-3.000000,-53.000000,14.000000,28.000000,14.000000,-35.000000,-11.000000,20.000000,16.000000,10.000000,-26.000000,-33.000000,47.000000,18.000000,-4.000000,-63.000000,14.000000,58.000000,10.000000,-74.000000,25.000000,-1.000000,47.000000,-41.000000,-8.000000,12.000000,1.000000,41.000000,-58.000000,-24.000000,57.000000,26.000000,-25.000000,-42.000000,-3.000000,47.000000,11.000000,0.000000,-43.000000,-15.000000,51.000000,-8.000000,20.000000,-42.000000,-5.000000,35.000000,-13.000000,0.000000,-13.000000,11.000000,30.000000,-39.000000,-11.000000,14.000000,18.000000,11.000000,-22.000000,-31.000000,15.000000,66.000000,-59.000000,-28.000000,53.000000,6.000000,-35.000000,-11.000000,44.000000,-16.000000,-14.000000,-1.000000,19.000000,19.000000,-85.000000,72.000000,-2.000000,-16.000000,0.000000,-4.000000,-14.000000,35.000000,-15.000000,10.000000,-19.000000,-4.000000,2.000000,25.000000,5.000000,-38.000000,11.000000,10.000000,7.000000,6.000000,-56.000000,65.000000,4.000000,-56.000000,21.000000,25.000000,-10.000000,-22.000000,25.000000,2.000000,-6.000000,-28.000000,23.000000,38.000000,-41.000000,-25.000000,39.000000,6.000000,-14.000000,-8.000000,8.000000,-2.000000,7.000000,-10.000000,15.000000,-29.000000,6.000000,43.000000,-34.000000,-32.000000,44.000000,4.000000,-15.000000,-5.000000,-7.000000,6.000000,31.000000,-35.000000,2.000000,8.000000,6.000000,-4.000000,0.000000,-12.000000,3.000000,11.000000,13.000000,-33.000000,12.000000,16.000000,-18.000000,-4.000000,0.000000,33.000000,-3.000000,-34.000000,-37.000000,43.000000,81.000000,-66.000000,-76.000000,77.000000,-1.000000,10.000000,-27.000000,-4.000000,2.000000,26.000000,2.000000,-46.000000,16.000000,13.000000,27.000000,-22.000000,-15.000000,-20.000000,19.000000,45.000000,-14.000000,-20.000000,-39.000000,6.000000,78.000000,-9.000000,-62.000000,-5.000000,37.000000,16.000000,-15.000000,-20.000000,1.000000,29.000000,-9.000000,-33.000000,19.000000,48.000000,-50.000000,-25.000000,2.000000,70.000000,-9.000000,-43.000000,-43.000000,35.000000,50.000000,17.000000,-82.000000,-10.000000,59.000000,-7.000000,5.000000,-15.000000,-23.000000,33.000000,17.000000,-15.000000,-27.000000,8.000000,44.000000,-17.000000,0.000000,-15.000000,-8.000000,17.000000,34.000000,-22.000000,-28.000000,17.000000,-3.000000,-4.000000,24.000000,-6.000000,-14.000000,-33.000000,23.000000,59.000000,-37.000000,-30.000000,-4.000000,22.000000,55.000000,-47.000000,-29.000000,17.000000,20.000000,20.000000,-4.000000,-30.000000,-18.000000,51.000000,16.000000,-24.000000,-57.000000,48.000000,25.000000,-21.000000,-9.000000,-19.000000,12.000000,14.000000,15.000000,-45.000000,-8.000000,27.000000,-9.000000,18.000000,-28.000000,-3.000000,-16.000000,48.000000,-12.000000,-5.000000,-44.000000,30.000000,32.000000,-15.000000,-42.000000,51.000000,-38.000000,19.000000,10.000000,-28.000000,35.000000,-20.000000,-23.000000,39.000000,18.000000,-71.000000,38.000000,31.000000,-28.000000,-22.000000,26.000000,15.000000,-38.000000,36.000000,12.000000,-77.000000,50.000000,23.000000,-2.000000,-41.000000,15.000000,-14.000000,8.000000,62.000000,-47.000000,-40.000000,7.000000,44.000000,13.000000,-36.000000,-12.000000,17.000000,9.000000,-20.000000,21.000000,-21.000000,36.000000,-48.000000,21.000000,6.000000,4.000000,-26.000000,17.000000,13.000000,-11.000000,-7.000000,0.000000,-17.000000,53.000000,-25.000000,-16.000000,-1.000000,8.000000,15.000000,-18.000000,20.000000,-16.000000,-24.000000,34.000000,17.000000,-37.000000,0.000000,14.000000,3.000000,8.000000,-27.000000,5.000000,23.000000,-12.000000,-28.000000,36.000000,-7.000000,7.000000,-28.000000,11.000000,2.000000,7.000000,16.000000,-15.000000,-44.000000,48.000000,4.000000,-17.000000,2.000000,5.000000,12.000000,-52.000000,34.000000,40.000000,-44.000000,-16.000000,50.000000,-35.000000,-11.000000,32.000000,11.000000,-10.000000,-56.000000,29.000000,55.000000,-19.000000,-52.000000,14.000000,33.000000,-15.000000,9.000000,-9.000000,-1.000000,-10.000000,4.000000,16.000000,3.000000,-9.000000,-8.000000,-14.000000,13.000000,28.000000,-7.000000,-24.000000,0.000000,-9.000000,31.000000,11.000000,-20.000000,-22.000000,10.000000,21.000000,-6.000000,11.000000,-38.000000,27.000000,-5.000000,-8.000000,29.000000,-25.000000,2.000000,-1.000000,-1.000000,2.000000,16.000000,-3.000000,-26.000000,0.000000,16.000000,20.000000,-21.000000,-16.000000,24.000000,-10.000000,-15.000000,27.000000,12.000000,-46.000000,14.000000,13.000000,11.000000,-10.000000,-23.000000,6.000000,32.000000,-17.000000,-5.000000,5.000000,-27.000000,16.000000,36.000000,-18.000000,-36.000000,25.000000,7.000000,-18.000000,7.000000,17.000000,9.000000,-58.000000,28.000000,20.000000,-22.000000,47.000000,-33.000000,-71.000000,98.000000,-9.000000,-23.000000,-11.000000,0.000000,34.000000,-37.000000,13.000000,20.000000,-23.000000,-19.000000,31.000000,22.000000,-44.000000,-6.000000,8.000000,52.000000,-43.000000,-19.000000,23.000000,-10.000000,17.000000,4.000000,-9.000000,-21.000000,2.000000,17.000000,20.000000,5.000000,-51.000000,-6.000000,21.000000,54.000000,-8.000000,-76.000000,17.000000,31.000000,6.000000,-7.000000,9.000000,-42.000000,17.000000,27.000000,-11.000000,-16.000000,5.000000,24.000000,-28.000000,6.000000,-1.000000,19.000000,-18.000000,-17.000000,38.000000,-8.000000,11.000000,-51.000000,21.000000,27.000000,3.000000,-8.000000,-24.000000,1.000000,28.000000,-16.000000,-9.000000,40.000000,-35.000000,5.000000,-21.000000,15.000000,36.000000,-29.000000,2.000000,-21.000000,9.000000,18.000000,5.000000,-18.000000,7.000000,-39.000000,43.000000,24.000000,-54.000000,24.000000,-10.000000,0.000000,10.000000,8.000000,11.000000,-64.000000,40.000000,9.000000,20.000000,-41.000000,8.000000,17.000000,-16.000000,-5.000000,20.000000,22.000000,-27.000000,-47.000000,44.000000,1.000000,61.000000,-68.000000,-37.000000,23.000000,65.000000,-43.000000,12.000000,-26.000000,-15.000000,49.000000,5.000000,-26.000000,-20.000000,17.000000,20.000000,0.000000,-2.000000,-44.000000,23.000000,31.000000,-15.000000,0.000000,-21.000000,14.000000,4.000000,-9.000000,16.000000,-19.000000,7.000000,41.000000,-73.000000,10.000000,28.000000,35.000000,-31.000000,-32.000000,3.000000,13.000000,42.000000,4.000000,-75.000000,28.000000,24.000000,-11.000000,41.000000,-27.000000,-37.000000,17.000000,34.000000,27.000000,-12.000000,-52.000000,-4.000000,52.000000,30.000000,-11.000000,-32.000000,-25.000000,29.000000,41.000000,0.000000,-25.000000,-31.000000,48.000000,-16.000000,-10.000000,2.000000,53.000000,-54.000000,-8.000000,-37.000000,77.000000,46.000000,-141.000000,25.000000,66.000000,-9.000000,-60.000000,16.000000,39.000000,-59.000000,46.000000,-15.000000,-12.000000,-13.000000,-4.000000,43.000000,8.000000,-27.000000,-70.000000,49.000000,70.000000,-39.000000,-7.000000,-68.000000,46.000000,58.000000,-10.000000,-51.000000,-52.000000,85.000000,47.000000,-85.000000,-32.000000,56.000000,23.000000,-33.000000,-28.000000,39.000000,-14.000000,-31.000000,68.000000,-25.000000,-39.000000,-20.000000,87.000000,-22.000000,-24.000000,-30.000000,31.000000,18.000000,10.000000,-17.000000,-31.000000,12.000000,22.000000,35.000000,-57.000000,-6.000000,41.000000,-16.000000,-37.000000,85.000000,-33.000000,-31.000000,-14.000000,15.000000,43.000000,29.000000,-104.000000,3.000000,46.000000,25.000000,8.000000,-62.000000,-28.000000,60.000000,43.000000,-70.000000,-2.000000,6.000000,17.000000,17.000000,-20.000000,-36.000000,31.000000,43.000000,-56.000000,2.000000,12.000000,18.000000,-19.000000,-9.000000,32.000000,8.000000,-58.000000,16.000000,43.000000,4.000000,-7.000000,-78.000000,66.000000,23.000000,-30.000000,47.000000,-93.000000,40.000000,35.000000,7.000000,-40.000000,-5.000000,-16.000000,66.000000,-7.000000,-26.000000,-80.000000,98.000000,2.000000,-9.000000,-48.000000,18.000000,16.000000,-25.000000,40.000000,-15.000000,-34.000000,22.000000,-30.000000,64.000000,-24.000000,-30.000000,16.000000,-17.000000,53.000000,-63.000000,18.000000,59.000000,-36.000000,-105.000000,100.000000,57.000000,-52.000000,-41.000000,-16.000000,38.000000,48.000000,-38.000000,-40.000000,28.000000,18.000000,-21.000000,-10.000000,11.000000,12.000000,8.000000,-37.000000,-6.000000,10.000000,41.000000,-4.000000,-54.000000,-6.000000,69.000000,-23.000000,-38.000000,13.000000,33.000000,10.000000,-84.000000,37.000000,86.000000,-55.000000,-94.000000,109.000000,-17.000000,9.000000,15.000000,-107.000000,72.000000,41.000000,-23.000000,-10.000000,-32.000000,14.000000,49.000000,-29.000000,-45.000000,66.000000,21.000000,-95.000000,-11.000000,124.000000,-48.000000,-36.000000,-9.000000,57.000000,-49.000000,-12.000000,45.000000,44.000000,-85.000000,-38.000000,50.000000,48.000000,24.000000,-78.000000,-81.000000,107.000000,55.000000,-83.000000,21.000000,-14.000000,-1.000000,-40.000000,94.000000,3.000000,-39.000000,-80.000000,38.000000,97.000000,-14.000000,-88.000000,-2.000000,55.000000,28.000000,-59.000000,28.000000,-20.000000,20.000000,-7.000000,-6.000000,18.000000,25.000000,-75.000000,2.000000,98.000000,-55.000000,-7.000000,-13.000000,32.000000,-38.000000,6.000000,71.000000,-59.000000,-25.000000,23.000000,-6.000000,20.000000,34.000000,-53.000000,-43.000000,70.000000,34.000000,-89.000000,30.000000,8.000000,32.000000,-31.000000,-3.000000,-29.000000,57.000000,-18.000000,31.000000,-55.000000,3.000000,7.000000,53.000000,-26.000000,-24.000000,5.000000,-67.000000,169.000000,-57.000000,-111.000000,52.000000,55.000000,12.000000,-89.000000,31.000000,38.000000,-14.000000,17.000000,-79.000000,32.000000,68.000000,-1.000000,-82.000000,-12.000000,67.000000,35.000000,-75.000000,-7.000000,47.000000,-12.000000,-22.000000,50.000000,-26.000000,-58.000000,49.000000,47.000000,-34.000000,-17.000000,-4.000000,-14.000000,39.000000,45.000000,-50.000000,-57.000000,23.000000,78.000000,4.000000,-63.000000,-61.000000,80.000000,49.000000,-33.000000,-46.000000,17.000000,-43.000000,106.000000,-20.000000,-43.000000,-29.000000,30.000000,34.000000,-9.000000,-16.000000,7.000000,-40.000000,-2.000000,92.000000,10.000000,-121.000000,-15.000000,126.000000,-22.000000,-42.000000,13.000000,10.000000,-44.000000,40.000000,39.000000,-39.000000,-14.000000,6.000000,-17.000000,83.000000,-65.000000,-25.000000,100.000000,-70.000000,-48.000000,63.000000,55.000000,-20.000000,-136.000000,74.000000,93.000000,-26.000000,-72.000000,-39.000000,53.000000,83.000000,-53.000000,-43.000000,36.000000,-81.000000,64.000000,70.000000,-14.000000,-97.000000,11.000000,46.000000,-27.000000,52.000000,4.000000,-61.000000,28.000000,17.000000,-64.000000,38.000000,100.000000,-44.000000,-153.000000,67.000000,124.000000,-38.000000,-49.000000,-80.000000,12.000000,177.000000,-14.000000,-199.000000,-31.000000,176.000000,3.000000,-64.000000,-42.000000,3.000000,22.000000,11.000000,-8.000000,-14.000000,-7.000000,1.000000,2.000000,0.000000,-2.000000,-2.000000,-1.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000,1.000000,1.000000,0.000000,-2.000000,-2.000000,3.000000,9.000000,7.000000,-6.000000,-17.000000,-9.000000,22.000000,45.000000,10.000000,-115.000000,41.000000,61.000000,-26.000000,-13.000000,29.000000,-4.000000,-55.000000,43.000000,13.000000,-41.000000,50.000000,5.000000,-8.000000,-95.000000,32.000000,95.000000,-46.000000,57.000000,-110.000000,-13.000000,45.000000,20.000000,61.000000,-39.000000,-62.000000,-100.000000,173.000000,-3.000000,57.000000,-152.000000,6.000000,-5.000000,79.000000,78.000000,-85.000000,-103.000000,77.000000,-29.000000,102.000000,-39.000000,-41.000000,95.000000,-216.000000,49.000000,260.000000,-107.000000,-135.000000,-20.000000,93.000000,11.000000,63.000000,-69.000000,-85.000000,93.000000,-112.000000,150.000000,43.000000,-170.000000,10.000000,41.000000,77.000000,-81.000000,-12.000000,27.000000,11.000000,-21.000000,-23.000000,63.000000,-43.000000,-60.000000,84.000000,81.000000,-97.000000,-109.000000,-14.000000,276.000000,-36.000000,-191.000000,-115.000000,258.000000,36.000000,-124.000000,3.000000,-42.000000,52.000000,8.000000,103.000000,-121.000000,-63.000000,68.000000,3.000000,119.000000,-44.000000,-244.000000,159.000000,173.000000,-159.000000,-72.000000,87.000000,19.000000,42.000000,-146.000000,75.000000,-14.000000,78.000000,-59.000000,-18.000000,-7.000000,26.000000,-6.000000,0.000000,-8.000000,62.000000,-68.000000,-52.000000,66.000000,25.000000,-26.000000,41.000000,-81.000000,-23.000000,94.000000,10.000000,-77.000000,71.000000,-113.000000,85.000000,82.000000,-157.000000,9.000000,59.000000,109.000000,-113.000000,-85.000000,29.000000,105.000000,73.000000,-149.000000,-60.000000,36.000000,113.000000,9.000000,-99.000000,-19.000000,61.000000,-21.000000,-45.000000,136.000000,-87.000000,-47.000000,13.000000,65.000000,-3.000000,-63.000000,43.000000,-56.000000,81.000000,32.000000,-77.000000,-104.000000,154.000000,28.000000,-27.000000,-99.000000,46.000000,25.000000,23.000000,-31.000000,-11.000000,27.000000,21.000000,-26.000000,-104.000000,74.000000,149.000000,-93.000000,-70.000000,-60.000000,59.000000,85.000000,121.000000,-205.000000,-133.000000,193.000000,14.000000,18.000000,-95.000000,75.000000,-16.000000,-134.000000,114.000000,46.000000,48.000000,-63.000000,-160.000000,52.000000,151.000000,66.000000,-207.000000,17.000000,45.000000,-8.000000,63.000000,-60.000000,21.000000,5.000000,-122.000000,120.000000,73.000000,-132.000000,63.000000,-69.000000,29.000000,-27.000000,166.000000,-120.000000,-114.000000,118.000000,64.000000,-131.000000,77.000000,7.000000,-72.000000,73.000000,13.000000,-57.000000,-52.000000,95.000000,65.000000,-129.000000,49.000000,-9.000000,-27.000000,-11.000000,95.000000,56.000000,-220.000000,31.000000,160.000000,-54.000000,-43.000000,15.000000,-70.000000,81.000000,64.000000,-66.000000,-103.000000,87.000000,-8.000000,80.000000,-70.000000,19.000000,-118.000000,129.000000,-29.000000,44.000000,-24.000000,-54.000000,23.000000,-24.000000,60.000000,27.000000,-19.000000,-71.000000,-62.000000,154.000000,46.000000,-125.000000,2.000000,80.000000,-208.000000,223.000000,15.000000,-32.000000,-158.000000,22.000000,170.000000,31.000000,-258.000000,132.000000,77.000000,-31.000000,-134.000000,65.000000,142.000000,-149.000000,56.000000,-3.000000,-62.000000,30.000000,93.000000,-102.000000,22.000000,62.000000,-103.000000,2.000000,113.000000,-75.000000,-21.000000,139.000000,-162.000000,-83.000000,265.000000,-76.000000,-94.000000,0.000000,9.000000,101.000000,-17.000000,-101.000000,-70.000000,199.000000,58.000000,-260.000000,112.000000,-1.000000,21.000000,17.000000,-17.000000,-2.000000,-74.000000,41.000000,109.000000,-22.000000,-161.000000,44.000000,104.000000,-24.000000,56.000000,-152.000000,-39.000000,142.000000,51.000000,-40.000000,-101.000000,3.000000,-3.000000,155.000000,-87.000000,12.000000,-87.000000,13.000000,92.000000,-33.000000,51.000000,-77.000000,-118.000000,247.000000,-125.000000,15.000000,22.000000,-68.000000,43.000000,24.000000,-7.000000,-12.000000,-107.000000,146.000000,102.000000,-200.000000,-88.000000,104.000000,224.000000,-142.000000,-143.000000,-25.000000,179.000000,69.000000,-153.000000,-55.000000,62.000000,88.000000,-78.000000,-14.000000,31.000000,34.000000,-102.000000,15.000000,116.000000,-59.000000,48.000000,-146.000000,-8.000000,230.000000,-114.000000,-65.000000,97.000000,-111.000000,29.000000,85.000000,-22.000000,-41.000000,-7.000000,-26.000000,137.000000,-99.000000,-89.000000,181.000000,-82.000000,-22.000000,58.000000,-123.000000,119.000000,10.000000,-104.000000,107.000000,-7.000000,-110.000000,20.000000,117.000000,-60.000000,0.000000,-38.000000,18.000000,82.000000,-186.000000,113.000000,117.000000,-66.000000,-166.000000,44.000000,158.000000,-7.000000,-150.000000,56.000000,84.000000,-109.000000,-18.000000,119.000000,-19.000000,-88.000000,59.000000,-28.000000,-31.000000,102.000000,-50.000000,-48.000000,46.000000,-4.000000,-72.000000,109.000000,14.000000,-103.000000,-18.000000,68.000000,23.000000,8.000000,-76.000000,-5.000000,77.000000,-28.000000,-28.000000,4.000000,40.000000,50.000000,-109.000000,-52.000000,108.000000,45.000000,20.000000,-128.000000,-34.000000,73.000000,25.000000,125.000000,-172.000000,-59.000000,87.000000,10.000000,33.000000,48.000000,-137.000000,-8.000000,8.000000,122.000000,-21.000000,-7.000000,-137.000000,10.000000,142.000000,19.000000,-98.000000,-17.000000,20.000000,-6.000000,59.000000,-12.000000,-42.000000,-18.000000,25.000000,54.000000,-14.000000,-69.000000,-65.000000,217.000000,-70.000000,-102.000000,35.000000,28.000000,37.000000,-23.000000,-12.000000,-68.000000,96.000000,39.000000,-107.000000,33.000000,-34.000000,61.000000,86.000000,-124.000000,-110.000000,177.000000,12.000000,14.000000,-202.000000,90.000000,143.000000,-109.000000,0.000000,-67.000000,96.000000,30.000000,-56.000000,-23.000000,-83.000000,127.000000,118.000000,-129.000000,-171.000000,117.000000,129.000000,-57.000000,-28.000000,-14.000000,-104.000000,174.000000,-31.000000,-76.000000,80.000000,-25.000000,-61.000000,61.000000,-13.000000,63.000000,-131.000000,79.000000,20.000000,-47.000000,33.000000,8.000000,-80.000000,86.000000,17.000000,-68.000000,-6.000000,25.000000,78.000000,-88.000000,-11.000000,-7.000000,41.000000,55.000000,-13.000000,-143.000000,94.000000,-7.000000,-1.000000,94.000000,-100.000000,-85.000000,188.000000,-162.000000,82.000000,12.000000,42.000000,-123.000000,16.000000,-1.000000,132.000000,-8.000000,-175.000000,56.000000,31.000000,5.000000,94.000000,-37.000000,-146.000000,2.000000,61.000000,176.000000,-71.000000,-158.000000,30.000000,-11.000000,102.000000,42.000000,-40.000000,-149.000000,181.000000,-150.000000,40.000000,97.000000,16.000000,-121.000000,32.000000,-28.000000,27.000000,51.000000,2.000000,-54.000000,-18.000000,46.000000,-1.000000,-26.000000,-57.000000,184.000000,-103.000000,-78.000000,69.000000,15.000000,-51.000000,77.000000,39.000000,-198.000000,50.000000,183.000000,-21.000000,-230.000000,67.000000,124.000000,27.000000,-70.000000,-105.000000,114.000000,-39.000000,-14.000000,126.000000,-89.000000,-89.000000,110.000000,-43.000000,5.000000,29.000000,0.000000,-29.000000,-35.000000,83.000000,-69.000000,32.000000,-15.000000,44.000000,5.000000,-83.000000,10.000000,92.000000,-38.000000,-53.000000,92.000000,-40.000000,-75.000000,90.000000,28.000000,-87.000000,26.000000,30.000000,-37.000000,78.000000,-91.000000,-35.000000,101.000000,23.000000,-90.000000,24.000000,-68.000000,129.000000,-86.000000,102.000000,-111.000000,-6.000000,-13.000000,110.000000,27.000000,-141.000000,-7.000000,69.000000,43.000000,-100.000000,100.000000,-107.000000,130.000000,-107.000000,-52.000000,107.000000,48.000000,-52.000000,-106.000000,65.000000,101.000000,-145.000000,78.000000,-11.000000,9.000000,-14.000000,-29.000000,76.000000,-111.000000,89.000000,19.000000,-40.000000,-69.000000,125.000000,-35.000000,-69.000000,-4.000000,147.000000,-56.000000,-105.000000,3.000000,148.000000,-77.000000,-27.000000,-53.000000,166.000000,-59.000000,-122.000000,69.000000,21.000000,81.000000,-69.000000,-127.000000,112.000000,84.000000,-98.000000,-31.000000,43.000000,81.000000,-171.000000,51.000000,167.000000,-155.000000,-60.000000,123.000000,6.000000,-48.000000,-83.000000,145.000000,32.000000,-146.000000,-82.000000,192.000000,130.000000,-215.000000,-99.000000,120.000000,74.000000,-53.000000,48.000000,-64.000000,-73.000000,116.000000,-81.000000,102.000000,-4.000000,-71.000000,-36.000000,54.000000,-18.000000,20.000000,93.000000,-133.000000,-1.000000,22.000000,-12.000000,39.000000,70.000000,-99.000000,-54.000000,9.000000,141.000000,-62.000000,-62.000000,99.000000,-147.000000,125.000000,-88.000000,99.000000,-17.000000,40.000000,-206.000000,96.000000,134.000000,-15.000000,-92.000000,-53.000000,59.000000,92.000000,-18.000000,-116.000000,123.000000,133.000000,108.000000,-80.000000,-269.000000,-40.000000,416.000000,719.000000,252.000000,-1002.000000,-1609.000000,167.000000,2717.000000,3280.000000,-1794.000000,-13247.000000,13255.000000
};

//Filter Coeff
float coeff[tapNo]
={
	0.008379,0.010392,0.012711,0.015332,0.018239,0.021398,0.024757,0.028249,0.031789,0.035279,0.038612,
	0.041677,0.044365,0.046575,0.048221,0.049236,0.049579,0.049236,0.048221,0.046575,0.044365,0.041677,
	0.038612,0.035279,0.031789,0.028249,0.024757,0.021398,0.018239,0.015332,0.012711,0.010392,0.008379

};

int halfTap = (int)(tapNum-1)/2;


//CUDA Timer Start0
 cudaEventRecord( ustart0, 0 );

 //unifyed Memory Allocete
  cudaMallocManaged(&srcData, sizeof(float)*(dataLength + tapNum -1));
  cudaMallocManaged(&blurData,sizeof(float)*dataLength);
  cudaMallocManaged(&filter,  sizeof(float)*tapNum);
  

//CUDA Timer End0
cudaEventRecord( ustop0, 0 );
cudaEventSynchronize( ustop0 );
 
 cudaEventElapsedTime( &elapsed_time0_ms, ustart0, ustop0 );	

//Time Disp
printf(“Unified Memory Allocated Time\n\n”);
printf( “cudaMalllocManaged Time: %8.2f ms\n”, elapsed_time0_ms );

// Data Initialize//
    for(i=  0 ; i < (dataLength + tapNum -1) ; i++){
		    if(i<halfTap){
             srcData[i] =src[0];
			} else	if(i >= (dataLength + halfTap)){
              srcData[i] = src[dataLength-1];
			}else{
			srcData[i] = src[i-halfTap];
			}

            
    }

	//Extend Input Data check File
	fp0=fopen("SrcDataExt0.txt","w");
	for(i=0 ;i < dataLength+tapNum-1;++i){
	 fprintf(fp0,"No;%4d %8.4lf\n",i,srcData[i]);
	}
	fclose(fp0);


//Filter Coeff. Setting
	for(i = 0 ;i < tapNum;i++){
		filter[i] = coeff[i];
	}

for(int loop= 0; loop < LoopRound ;++loop){

//CUDA Timer Start1
cudaEventRecord( ustart1, 0 );

//Kernel Set
	
	dim3 blockDim(64,1);

	int gridDim_x =  (int) ( (dataLength + tapNum -1 + blockDim.x -1)/blockDim.x);

	dim3 gridDim(gridDim_x, 1);

 //CUDA 1D-FIR Kernel Func Call

 FIR_1D_Kernel<<<gridDim,blockDim>>>(srcData,blurData,filter,halfTap,tapNum,dataLength);

//CUDA Timer End1
cudaEventRecord( ustop1, 0 );
cudaEventSynchronize(ustop1 );

 cudaEventElapsedTime( &elapsed_time1_ms, ustart1, ustop1 );

//Time Disp
printf( “CUDA API:FIR_1D Filter: %8.2f[mSEC]\n”, elapsed_time1_ms );
}

//1D FIR Output Result

 fp0 = fopen("1D_FIR_Result0.txt","w");
 
  for(i =0 ; i < dataLength;++i){
   fprintf(fp0,"No:%5d blurData:%lf\n",i,blurData[i]);
  }
  fclose(fp0);

for(int loop= 0; loop < LoopRound ;++loop){

//CUDA Timer Start1
StartTimer();

//Kernel Set
	
	dim3 blockDim(64,1);

	int gridDim_x =  (int) ( (dataLength + tapNum -1 + blockDim.x -1)/blockDim.x);

	dim3 gridDim(gridDim_x, 1);

 //CUDA 1D-FIR Kernel Func Call

 FIR_1D_Kernel<<<gridDim,blockDim>>>(srcData,blurData,filter,halfTap,tapNum,dataLength);

//CUDA Timer End1
cudaDeviceSynchronize();
 //時間表示
 printf( "Timer DeviceSync:FIR_1D Filter: %8.2f[mSEC]\n", GetTimer() );

}

// 1D FIR Output Result

 fp0 = fopen("1D_FIR_Result1.txt","w");
 
  for(i =0 ; i < dataLength;++i){
   fprintf(fp0,"No:%5d blurData:%lf\n",i,blurData[i]);
  }
  fclose(fp0);

//Unified Memory 時間計測のEvent Release
cudaEventDestroy( ustart0 );
cudaEventDestroy( ustop0 );
cudaEventDestroy( ustart1 );
cudaEventDestroy( ustop1 );

//Unified Memory Area Release
cudaFree(srcData);
cudaFree(blurData);
cudaFree(filter);

//GPU Reset
cudaDeviceReset();

    return 0;

}