11 #include <utils/logger.hpp>
18 #if ENABLE_MULTITHREADING && ENABLE_OPENMP
21 #if ENABLE_MULTITHREADING && ENABLE_MPI
25 _INITIALIZE_EASYLOGGINGPP
34 LINFO << oxford_dataset;
36 std::stringstream index_output_file;
37 index_output_file << oxford_dataset.
location() <<
"/index/" << num_clusters <<
".index";
40 double total_time = 0.0;
41 uint32_t num_validate = 16;
42 uint32_t total_iterations = 256;
43 for(uint32_t i=0; i<total_iterations; i++) {
45 std::shared_ptr<InvertedIndex::MatchResults> matches =
47 if(matches ==
nullptr) {
48 LERROR <<
"Error while running search.";
52 total_time += (end_time - start_time);
56 cv::Mat keypoints_0, descriptors_0;
57 std::shared_ptr<SimpleDataset::SimpleImage> query_image = std::static_pointer_cast<
SimpleDataset::SimpleImage>(oxford_dataset.image(i));
58 const std::string &query_keypoints_location = oxford_dataset.
location(query_image->feature_path(
"keypoints"));
59 const std::string &query_descriptors_location = oxford_dataset.location(query_image->feature_path(
"descriptors"));
62 std::vector<int> validated(num_validate, 0);
63 #if ENABLE_MULTITHREADING && ENABLE_OPENMP
64 #pragma omp parallel for schedule(dynamic)
66 for(int32_t j=0; j<(int32_t)num_validate; j++) {
67 cv::Mat keypoints_1, descriptors_1;
68 std::shared_ptr<SimpleDataset::SimpleImage> match_image = std::static_pointer_cast<
SimpleDataset::SimpleImage>(oxford_dataset.image(matches->matches[j]));
69 const std::string &match_keypoints_location = oxford_dataset.
location(match_image->feature_path(
"keypoints"));
70 const std::string &match_descriptors_location = oxford_dataset.location(match_image->feature_path(
"descriptors"));
74 cv::detail::MatchesInfo match_info;
80 html_output.
add_match(i, matches->matches, oxford_dataset, std::make_shared< std::vector<int> >(validated));
81 html_output.
write(oxford_dataset.location() +
"/results/matches/");
88 std::stringstream timings_file_name;
89 timings_file_name << oxford_dataset.location() +
"/results/times.index." << ii.num_clusters() <<
".csv";
90 std::ofstream ofs(timings_file_name.str(), std::ios::app);
91 if((
size_t)ofs.tellp() == 0) {
92 std::stringstream header;
93 header <<
"machine\ttime(s)\titerations\tmultithreading\topenmp\tmpi\t" << std::endl;
94 ofs.write(header.str().c_str(), header.str().size());
96 std::stringstream timing;
100 ofs.write(timing.str().c_str(), timing.str().size());
107 int main(
int argc,
char *argv[]) {
108 #if ENABLE_MULTITHREADING && ENABLE_MPI
109 MPI::Init(argc, argv);
110 int rank = MPI::COMM_WORLD.Get_rank();
116 #if ENABLE_MULTITHREADING && ENABLE_MPI