-
Notifications
You must be signed in to change notification settings - Fork 26
/
main.cpp
70 lines (57 loc) · 2.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <iostream>
#include "gpusim.h"
using gpusim::Fingerprint;
using gpusim::GPUSimServer;
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("GPUSimilarity");
QCommandLineParser parser;
parser.setApplicationDescription("GPUSimilarity Backend: Not meant to be "
"called directly.");
const QCommandLineOption helpOption = parser.addHelpOption();
QCommandLineOption cpuOnlyOption("cpu_only",
"Perform searches only on CPU");
parser.addOption(cpuOnlyOption);
QCommandLineOption gpuBitcountOption(
"gpu_bitcount", "Define the fingerprint bitcount on the GPU",
"Bitcount", "0");
parser.addOption(gpuBitcountOption);
if (!parser.parse(QCoreApplication::arguments())) {
qDebug() << parser.errorText();
return 1;
}
if (parser.isSet(helpOption)) {
qDebug() << "Arg parsing is only done in a reasonable way in"
" the python gpusim_server.py. Handling here is very "
"error prone"
" and not intended for direct use.";
return 1;
}
bool ok = false;
auto gpu_bitcount = parser.value(gpuBitcountOption).toInt(&ok);
if (!ok) {
qDebug() << "GPU Bitcount must be an integer";
return 1;
}
if (parser.isSet(cpuOnlyOption) && gpu_bitcount != 0) {
qDebug() << "--cpu_only and --gpu_bitcount are incompatible options";
return 1;
}
auto db_fnames = parser.positionalArguments();
for (auto filename : db_fnames) {
bool file_exists = QFileInfo(filename).exists();
if (!file_exists) {
qDebug() << "File: \"" << qPrintable(filename) << "\" not found.";
return 1;
}
}
GPUSimServer gpusim(db_fnames, gpu_bitcount);
gpusim.setUseGPU(!parser.isSet(cpuOnlyOption));
app.exec();
return 0;
};