2014-06-16 3 views
0

48KB 데이터 블록 (고정 메모리 사용)을 전송 중이며 cuda 이벤트는 5GB/초로 증가하지만 Windows로 돌아갈 때에는 절반 만 볼 수 있습니다. 속도. 이것은 단지 피할 수없는 운전자 오버 헤드입니까, 아니면 이것을 완화 할 수있는 방법이 있습니까? 아래의 테스트 프로그램에서 프로세스를 캡슐화했습니다.이벤트를 사용하는 CUDA 전송 타이밍 대 windows

void transferUp(size_t size) 
{ 

StopWatchWin timer; 
timer.start(); 

float tUpCopyStart,tUpCopyStop; 

cudaEvent_t sendUpStopEvent,sendUpStartEvent; 
checkCudaErrors(cudaEventCreate(&sendUpStartEvent)); 
checkCudaErrors(cudaEventCreate(&sendUpStopEvent)); 

unsigned *cpu_sending = (unsigned *)malloc(size); 
checkCudaErrors(cudaHostAlloc(&cpu_sending, size*sizeof(unsigned), cudaHostAllocPortable)); 

unsigned *gpu_receiving; 
checkCudaErrors(cudaMalloc(&gpu_receiving, size*sizeof(unsigned))); 

tUpCopyStart = timer.getTime(); 
checkCudaErrors(cudaEventRecord(sendUpStartEvent)); 

checkCudaErrors(cudaMemcpyAsync(gpu_receiving, cpu_sending, size*sizeof(unsigned), cudaMemcpyHostToDevice)); 

checkCudaErrors(cudaEventRecord(sendUpStopEvent)); 
checkCudaErrors(cudaEventSynchronize(sendUpStopEvent)); 
tUpCopyStop = timer.getTime(); 

double sendTimeWindows = tUpCopyStop - tUpCopyStart; 

float sendTimeCuda; 
checkCudaErrors(cudaEventElapsedTime(&sendTimeCuda,sendUpStartEvent,sendUpStopEvent)); 

float GbSec_cuda = (size*sizeof(unsigned)/1000)/(sendTimeCuda*1000); 
float GbSec_win = (size*sizeof(unsigned)/1000)/(sendTimeWindows*1000); 

printf("size=%06d bytes eventTime=%.03fms windowsTime=%0.3fms cudaSpeed=%.01f gb/s winSpeed=%.01f gb/s\n", 
size*sizeof(unsigned),sendTimeCuda,sendTimeWindows,GbSec_cuda,GbSec_win); 

checkCudaErrors(cudaEventDestroy(sendUpStartEvent)); 
checkCudaErrors(cudaEventDestroy(sendUpStopEvent)); 

checkCudaErrors(cudaFreeHost(cpu_sending)); 
checkCudaErrors(cudaFree(gpu_receiving)); 

} 
+0

TCC에서 실행 중이십니까? –

+0

Tiny C 컴파일러? 아니요, Visual Studio 2010입니다. – sedona2222

+1

@ sedona2222 : TCC = Tesla Compute Cluster, Windows 플랫폼의 CUDA 용 전용 비 디스플레이 드라이버 – talonmies

답변

1

이 작은 동작 타이밍의 오버 헤드는 측정을 압도합니다.

작은 호스트 -> 장치 사본 (예 : 64K 이하)의 경우 CUDA 드라이버는 데이터를 명령 버퍼로 인라인하기 때문에 실제로 memcpy 호출은 비동기 적으로 수행됩니다. 그러나 코드에서 cudaEventSynchronize()을 호출하면 CPU가 계속 실행되는 대신 대기하게됩니다.

관련 문제