From 0cc860707a52b9d76275f92bda160566e7de4474 Mon Sep 17 00:00:00 2001 From: Jun Saito Date: Tue, 19 Sep 2017 09:59:05 -0700 Subject: [PATCH] OpenMP multithreading --- setup.py | 6 +++- src/ImageProcessing.h | 78 +++++++++++++++++++------------------------ src/OpticalFlow.cpp | 1 + 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/setup.py b/setup.py index c3ce742..479a59a 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,11 @@ sourcefiles = ['pyflow.pyx', ] sourcefiles.extend(glob("src/*.cpp")) -extensions = [Extension("pyflow", sourcefiles, include_dirs=[numpy.get_include()])] +extensions = [Extension("pyflow", + sourcefiles, + include_dirs=[numpy.get_include()], + extra_compile_args=['-fopenmp'], + extra_link_args=['-lgomp'])] setup( name="pyflow", version="1.0", diff --git a/src/ImageProcessing.h b/src/ImageProcessing.h index ec9fd3b..7e2fdf5 100644 --- a/src/ImageProcessing.h +++ b/src/ImageProcessing.h @@ -249,19 +249,17 @@ template void ImageProcessing::hfiltering(const T1* pSrcImage,T2* pDstImage,int width,int height,int nChannels,const double* pfilter1D,int fsize) { memset(pDstImage,0,sizeof(T2)*width*height*nChannels); - T2* pBuffer; - double w; - int i,j,l,k,offset,jj; - for(i=0;i void ImageProcessing::hfiltering_transpose(const T1* pSrcImage,T2* pDstImage,int width,int height,int nChannels,const double* pfilter1D,int fsize) { memset(pDstImage,0,sizeof(T2)*width*height*nChannels); - const T1* pBuffer; - double w; - int i,j,l,k,offset,jj; - for(i=0;i void ImageProcessing::vfiltering(const T1* pSrcImage,T2* pDstImage,int width,int height,int nChannels,const double* pfilter1D,int fsize) { memset(pDstImage,0,sizeof(T2)*width*height*nChannels); - T2* pBuffer; - double w; - int i,j,l,k,offset,ii; - for(i=0;i void ImageProcessing::vfiltering_transpose(const T1* pSrcImage,T2* pDstImage,int width,int height,int nChannels,const double* pfilter1D,int fsize) { memset(pDstImage,0,sizeof(T2)*width*height*nChannels); - const T1* pBuffer; - double w; - int i,j,l,k,offset,ii; - for(i=0;i