Skip to content

Parallelize building kmeans index in flann - #3458

Merged
opencv-pushbot merged 3 commits into
opencv:masterfrom
thorikawa:kmeans-index-parallel
Dec 1, 2014
Merged

opencv-pushbot merged 3 commits into
opencv:masterfrom
thorikawa:kmeans-index-parallel

Conversation

@thorikawa

Copy link
Copy Markdown
Contributor

I improved k-means index in flann module by parallelize computing distances between datas and centers. It would be great if you have a chance to review and merge it. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is possible memory leak in case of exception. So, please, use cv::AutoBuffer<bool>, which is safer.

@ilya-lavrenov

Copy link
Copy Markdown
Contributor

@ilya-lavrenov ilya-lavrenov self-assigned this Nov 27, 2014
- Use cv::AutoBuffer rather than new allocation
- Fix "assignment operator could not be generated" warning
@thorikawa

Copy link
Copy Markdown
Contributor Author

Hi @ilya-lavrenov,

I have benchmarked it using this code and Caltech 101 dataset. Here is the summary. (All unit is millisecond)

Benchmark1

Environment

Mac OS X 10.9.5
2.5 GHz Intel Core i7
Memory: 16GB

Before

poly@Rewlloola:~/workspace/opencv-flann-kmeans-perf$ ./main my_101_list.txt
TIME_EXTRACT_FEATURES = 18590.8
TIME_CLUSTERING = 25890.9

After

poly@Rewlloola:~/workspace/opencv-flann-kmeans-perf$ ./main my_101_list.txt TIME_EXTRACT_FEATURES = 18885.3
TIME_CLUSTERING = 10507.2

Benchmark2

Environment

Amazon Linux 2014.09.1
4 vCPU
Memory: 15GB

Before

[ec2-user@ip-172-31-3-55 opencv-flann-kmeans-benchmark]$ ./main 101_list.txt
TIME_EXTRACT_FEATURES = 30485.6
TIME_CLUSTERING = 36245.2

After

[ec2-user@ip-172-31-3-55 opencv-flann-kmeans-benchmark]$ LD_LIBRARY_PATH=/usr/local/opencv-3.0.0-beta/lib ./main 101_list.txt
TIME_EXTRACT_FEATURES = 30379.3
TIME_CLUSTERING = 21507.7

The amount of improvement depends on the number of cpus, but i would say it provides a lot of gains.

@thorikawa

Copy link
Copy Markdown
Contributor Author

Also I've fixed warnings. Please review it again. Thanks!

@ilya-lavrenov

Copy link
Copy Markdown
Contributor

👍

@opencv-pushbot
opencv-pushbot merged commit 553bb79 into opencv:master Dec 1, 2014
@thorikawa
thorikawa deleted the kmeans-index-parallel branch December 2, 2014 11:50
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants