WIP: v1 recursive

This commit is contained in:
2024-11-20 00:15:57 +02:00
parent f591127e16
commit 6246c02420
16 changed files with 29579 additions and 106 deletions
+33 -10
View File
@@ -13,11 +13,12 @@
#include <unistd.h>
#include <cstdio>
#include <v0.hpp>
#include <v1.hpp>
#include <matrix.hpp>
#include <utils.hpp>
#include <config.h>
#include "matrix.hpp"
#include "v0.hpp"
#include "v1.hpp"
#include "utils.hpp"
#include "config.h"
// Global session data
session_t session;
@@ -108,8 +109,7 @@ bool get_options(int argc, char* argv[]){
return status;
}
NAMESPACE_VERSION;
#ifndef TESTING
int main(int argc, char* argv[]) try {
// Instantiate matrixes
MatrixDst Corpus;
@@ -117,6 +117,12 @@ int main(int argc, char* argv[]) try {
MatrixIdx Idx;
MatrixDst Dst;
#if CODE_VERSION == V0
using namespace v0;
#else
using namespace v1;
#endif
// try to read command line
if (!get_options(argc, argv))
exit(1);
@@ -132,17 +138,21 @@ int main(int argc, char* argv[]) try {
timer.stop();
timer.print_dt("Load hdf5 files");
// Prepare output memory
Idx.resize(Query.rows(), session.k);
Dst.resize(Query.rows(), session.k);
// Do the search
logger << "Start knnsearch ...";
timer.start();
if (session.queryMtx)
knnsearch(Corpus, Query, session.k, Idx, Dst);
knnsearch(Corpus, Query, 0, session.k, session.k, Idx, Dst);
else
knnsearch(Corpus, Corpus, session.k, Idx, Dst);
knnsearch(Corpus, Corpus, 0, session.k, session.k, Idx, Dst);
timer.stop();
logger << " Done" << logger.endl;
timer.print_dt("knnsearch");
// Store data
timer.start();
Mtx::store<MatrixIdx, IdxHDF5Type>(session.outMtxFile, session.outMtxIdxDataSet, Idx);
@@ -158,4 +168,17 @@ catch (std::exception& e) {
exit(1);
}
#elif defined TESTING
#include <gtest/gtest.h>
#include <exception>
GTEST_API_ int main(int argc, char **argv) try {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what() << '\n';
}
#endif