From 022ceb2d3560cb6013aea58ac9e1fe46f3b88893 Mon Sep 17 00:00:00 2001 From: gfuse Date: Mon, 23 Aug 2021 18:17:37 +0200 Subject: [PATCH] debug files --- GPU_version/vio/include/vio/cl_class.h | 9 +++++---- GPU_version/vio/src/feature_detection.cpp | 6 +++--- GPU_version/vio/src/sparse_img_align_gpu.cpp | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/GPU_version/vio/include/vio/cl_class.h b/GPU_version/vio/include/vio/cl_class.h index 8f1cd4c..b3c89eb 100644 --- a/GPU_version/vio/include/vio/cl_class.h +++ b/GPU_version/vio/include/vio/cl_class.h @@ -58,7 +58,7 @@ public: assert(error == CL_SUCCESS); event.wait(); memcpy(Map_buf,buf,sizeof(T) * i.first.second); - if(queue->enqueueUnmapMemObject(i.first.first,Map_buf,NULL,&event)!=CL_SUCCESS)std::cerr<<"Reload buffer on GPU failed"<<'\n'; + assert(queue->enqueueUnmapMemObject(i.first.first,Map_buf,NULL,&event)==CL_SUCCESS); event.wait(); } @@ -178,10 +178,11 @@ public: return queue->finish(); } + /* template - void read(size_t id1/*kernal ID*/,size_t id2/*buffer ID*/, T* out){ - queue->enqueueReadBuffer(_kernels.at(id1).read(id2).first, CL_TRUE, 0, sizeof(T) * _kernels.at(id1).read(id2).second, out); - } + void read(size_t id1/*kernal ID*///,size_t id2/*buffer ID*/, T* out){ + // queue->enqueueReadBuffer(_kernels.at(id1).read(id2).first, CL_TRUE, 0, sizeof(T) * _kernels.at(id1).read(id2).second, out); + // } template void read(size_t id1/*kernal ID*/,size_t id2/*buffer ID*/,size_t size/*size*/, T* out){ cl_int error; diff --git a/GPU_version/vio/src/feature_detection.cpp b/GPU_version/vio/src/feature_detection.cpp index 13f9bef..0df817b 100644 --- a/GPU_version/vio/src/feature_detection.cpp +++ b/GPU_version/vio/src/feature_detection.cpp @@ -80,10 +80,10 @@ void FastDetector::detect( int icorner[1]={0}; gpu_fast_->reload_buf(0,2,icorner); gpu_fast_->run(0,img.cols,img.rows); - cl_int2 fast_corners[350000]; - gpu_fast_->read(0,1,fast_corners); int count[1]={0}; - gpu_fast_->read(0,2,count); + gpu_fast_->read(0,2,1,count); + cl_int2 fast_corners[350000]; + gpu_fast_->read(0,1,count[0],fast_corners); for(uint i=0;iimg_pyr[L].cols || fast_corners[i].y>img_pyr[L].rows || fast_corners[i].y<0) diff --git a/GPU_version/vio/src/sparse_img_align_gpu.cpp b/GPU_version/vio/src/sparse_img_align_gpu.cpp index 2e5efde..aec6f46 100644 --- a/GPU_version/vio/src/sparse_img_align_gpu.cpp +++ b/GPU_version/vio/src/sparse_img_align_gpu.cpp @@ -73,7 +73,7 @@ size_t SparseImgAlignGpu::run(FramePtr ref_frame, FramePtr cur_frame) optimize(T_cur); } cl_float3 pos[1]={0}; - residual_->read(1,2,pos); + residual_->read(1,2,1,pos); cur_frame->T_f_w_ = SE2_5(pos[0].x,pos[0].y,pos[0].z); return 1; } @@ -137,7 +137,7 @@ void SparseImgAlignGpu::update() { /// TODO the update situation may have a smarter solution cl_float3 pos[1]={0.0,0.0,0.0}; - residual_->read(1,2,pos); + residual_->read(1,2,1,pos); Sophus::SE2 update = Sophus::SE2(pos[0].z,Eigen::Vector2d(pos[0].x,pos[0].y)) * Sophus::SE2::exp(-1.0*x_); pos[0].x=(float)update.translation()(0); pos[0].y=(float)update.translation()(1);