Skip to content

CUDA:Stream

지원 여부 확인

디바이스 오버랩이 지원되야 한다.

cudaDeviceProp prop;
int nDevice;

cudaGetDevice(&nDevice);
cudaGetDeviceProperties(&prop, nDevice);

if (!prop.deviceOverlap)
    printf("Device will not handle overlaps, so no"
           "speed up from streams \n");

동기화

cudaDeviceSynchronize
스트림 안의 연산과 호스트 코드를 동기화할 필요가 있다면 사용.
  • 디바이스에서 이전에 시작된 모든 연산이 종료될 때까지 호스트 코드를 블록한다.
  • 따라서 이 함수의 사용은 다른 디바이스 스레드나 호스트 스레드를 멈추게(stall)하여서 성능 저하를 가져오게 된다.
cudaStreamSynchronize(stream)
특정 스트림 안에서 시작된 모든 연산이 끝날 때까지 호스트 스레드를 블록하는 방식이다.
cudaStreamQuery(stream)
특정 스트림 안의 모든 연산의 종료 여부를 테스트 할 수 있다.
cudaEventSynchronize(event), cudaEventQuery(event)
특정 이벤트의 기록 여부를 이용하여 동기화 한다.
cudaStreamWaitEvent(event)
스트림 안의 연산들을 특정 이벤트와 동기화시킬 수 있다.

See also

Favirite site