다음은 추력, cublas 및 curand가 혼합 된 일부 코드에서 실행중인 CUDA 프로파일 러 (nvprof)의 로그 파일입니다. 첫 번째 커널은 내가 작성한 커널이므로 아무런 문제가 없다. 그러나 상당한 실행 시간을 차지하는 2 행에서 5 행을 해석하는 방법을 모르겠습니다.CUDA 프로파일 러 로그 파일 해석
> Time(%) Time Calls Avg Min Max Name % s ms ms ms
>
> 28.12 6.82 24,543.00 0.28 0.01 0.64 dev_update_dW1(doub....)
> 23.78 5.77 12,272.00 0.47 0.46 0.49 void thrust::system::cud....
> 14.32 3.47 12,272.00 0.28 0.28 0.29 void thrust::system::cud....
> 10.82 2.62 12,272.00 0.21 0.21 0.22 void thrust::system::cud....
> 4.93 1.20 24,544.00 0.05 0.05 0.05 void thrust::system::cud....
> 3.98 0.96 12,272.00 0.08 0.08 0.09 Act_dAct(double*, long, double*, double*)
5 라인 2 회 전액 아래에 인쇄됩니다
2 라인 : 무효 추력 :: 시스템 :: CUDA :: 자세히 :: 자세히 :: launch_closure_by_value>, 추력 : : counting_iterator < __int64, thrust :: use_default, thrust :: use_default, thrust :: use_default>, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type , 추력 :: null_type, 추력 :: null_type >>, __int64, 추력 :: 튜플, 추력 :: 세부 :: 정상 _iterator, 추력 :: 시스템 :: cuda :: 세부 :: 태그, 추력 :: use_default, thrust :: use_default >>, thr UST :: 시스템 :: 자세히 :: 일반 :: 자세히 :: max_element_reduction>, 추력 :: 시스템 :: CUDA :: 자세히 :: 자세히 :: blocked_thread_array >> (더블)
3 라인 : void thrust :: system :: cuda :: detail :: launch_closure_by_value>, 추력 :: detail :: normal_iterator>, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type, 추력 : : null_type, 추력 :: null_type, 추력 :: null_type, 추력 :: null_type >>, 부호없는 int, 추력 :: 세부 :: device_unary_transform_functor, 추력 :: 시스템 :: cuda :: detail :: detail :: blocked_thread_array >> (이중)
제 4 행 : void thrust :: system :: cuda :: detail :: launch_closure_by_value>, double, thrust :: use_default>, __int64, double, thrust :: detail :: normal_iterator>, thrust :: 플러스, thrust :: 시스템 :: 쿠다 :: 상세히 :: 상세히 :: blocked_thread_array >> (exp_functor)
5 행 : 공극 추력 :: 시스템 :: 쿠다 :: 상세히 :: 상세히 :: launch_closure_by_value, 부호 INT, 추력 :: 상세히 :: device_generate_functor> :: 추력 시스템 :: 쿠다 :: 상세히 :: 상세히 :: blocked_thread_array >> (이단)
편집 :이 함수 (이 softmax)가
즉 MA를 사용 낮은 수준 x_element 및 transform_reduce
void Softmax_ThrustMatrix(thrust::device_vector<double>& mat, int Nrow, int Ncol, thrust::device_vector<double>& Outmat) {
thrust::device_vector<double> x(Ncol, 0.0);
thrust::device_vector<double> v(Ncol, 0.0);
thrust::device_vector<double>::iterator mx;
double tmp = 0.0, logsm=0.0;
dim3 grid, block;
block.x = 16;
block.y = 1;
grid.x = Ncol/block.x + 1;
grid.y = 1;
for (int i=0; i < Nrow; i++) {
GetRow<<<grid,block>>>(thrust::raw_pointer_cast(&mat[0]), i, Nrow, Ncol, thrust::raw_pointer_cast(&x[0]));
mx = thrust::max_element(x.begin(), x.end());
tmp = thrust::transform_reduce(x.begin(), x.end(), exp_functor(*mx), 0.0, thrust::plus<double>());
logsm = *mx + log(tmp);
thrust::transform(x.begin(), x.end(), v.begin(), exp_functor(logsm));
SetRow<<<grid,block>>>(thrust::raw_pointer_cast(&v[0]), i, Nrow, Ncol, thrust::raw_pointer_cast(&Outmat[0]));
}
}