-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
57 lines (46 loc) · 1.46 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
#include "gui/mainwindow.h"
#include <QApplication>
#include <qtextstream.h>
#include "core/VolumeReader.h"
void chooseBestDevice()
{
// choose the best device as the current device
int num_devices = 0;
int maxComputeCapability = 0;
checkCudaErrors(cudaGetDeviceCount(&num_devices));
printf("%d devices found on this platform:\n", num_devices);
int choice = 0;
for(int i = 0; i < num_devices; ++i)
{
cudaDeviceProp property;
checkCudaErrors(cudaGetDeviceProperties(&property, i));
char *name = property.name;
int computeCapability = property.major * 10 + property.minor;
printf("%d Device name: %s\t Compute capability: %d.%d\n", i, name, property.major, property.minor);
choice = maxComputeCapability > computeCapability ? choice : i;
maxComputeCapability = maxComputeCapability > computeCapability ? maxComputeCapability : computeCapability;
}
printf("Choice device %d\n", choice);
fflush(stdout);
checkCudaErrors(cudaSetDevice(choice));
}
int main(int argc, char *argv[])
{
chooseBestDevice();
QApplication a(argc, argv);
// load stylesheet
QFile f(":qdarkstyle/style.qss");
if (!f.exists())
{
printf("Unable to set stylesheet, file not found\n");
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
a.setStyleSheet(ts.readAll());
}
MainWindow w;
w.show();
return a.exec();
}