본문 바로가기

School Study/Multi Core Programming

CUDA Event

CUDA Event
→ Stream 내부 명령에 흐름 중, 특정 지점에 표시를 남기는 것(일종의 표시 → marker)

  • Creation and Destruction
    • cudaError_t cudaEventCreate (cudaEvent_t* event);
    • cudaError_t cudaEventDestory (cudaEvent_t event);
  • Recording Events
    • cudaError_t cudaEventRecord (cudaEvent_t event, cudaStream_t stream = 0);
      • stream에 event 발생 위치를 표시함
      • stream에서 꺼내질 때 정보가 event에 기록됨
  • Synchronization / Querying
    • cudaError_t cudaEventSynchronize (cudaEvent_t event);
      • 해당 event 발생까지 대기
    • cudaError_t cudaEventQuery (cudaEvent_t event);
      • 해당 event 발생 여부 확인
  • Measure the elasped time
    • cudaError_t cudaEventElapsedTime (float* ms, cudaEvent_t start, cudaEvent_t stop);
      • start와 end 사이에 소요된 시간을 milliseconds 단위로 계산

[시간 측정 사용 예시]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//create two events
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
 
cudaEventRecord(start); //record start event on the default stream
 
kernel <<< grid, block >>> (arguments); //execute kernel
 
cudaEventRecord(stop); //record stop event on the default stream
cudaEventSynchronize(stop); //wait until the stop event completes
 
//calculate the elapsed time between two events
float time;
cudaEventElapsedTime(&time, start, stop);
 
//clean up the two events
cudaEventDestroy(start);
cudaEventDestroy(stop);
cs

 

'School Study > Multi Core Programming' 카테고리의 다른 글

CUDA Stream & Concurrent Execution  (0) 2019.05.21
Synchronization in CUDA  (0) 2019.05.21
Maximizing Memory Throughput  (0) 2019.05.14
CUDA Memory Model  (0) 2019.05.07
CUDA Execution Model  (0) 2019.05.07