-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
138 lines (110 loc) · 3.56 KB
/
main.cpp
File metadata and controls
138 lines (110 loc) · 3.56 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <assert.h>
#include <Device.h>
#include <LaunchMode.h>
#include <Options.h>
#include <stdlib.h>
#include <Settings_GPU.h>
#include <iostream>
#include "cudaTools.h"
using namespace gpu;
using std::string;
using std::cout;
using std::endl;
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Imported *|
\*-------------------------------------*/
extern int mainImage(Settings& settings);
extern int mainAnimable(Settings& settings);
extern int mainBrutForce(Settings& settings);
extern int mainBarivox(Settings& settings);
extern int mainTest();
extern int mainTest();
/*--------------------------------------*\
|* Public *|
\*-------------------------------------*/
int main(int argc, char** argv);
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
static int use(Settings& settings, Options& option);
static int start(Settings& settings, Options& option);
static void initCuda(Settings& settings, Options& option);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Public *|
\*-------------------------------------*/
int main(int argc, char** argv)
{
// Server Cuda2: in [0,3] (4 Devices)
// Server Cuda3: in [0,2] (2 Devices)
int DEVICE_ID = 0;
bool IS_TEST = false;
//WARNING Pour lancer les tests du noyau de convolution, il faut modifier
// la constante KERNEL_CONVOLUTION_SIZE dans le fichier kernelConvolutionDevice
LaunchMode launchMode = LaunchMode::ANIMABLE; // IMAGE ANIMABLE BARIVOX FORCEBRUT
//DEVICE_ID is store 2 times but we haven't found any other option
Settings settings(launchMode, DEVICE_ID, argc, argv);
Options option(IS_TEST, DEVICE_ID);
return use(settings, option);
}
/*--------------------------------------*\
|* Public *|
\*-------------------------------------*/
int use(Settings& settings, Options& option)
{
initCuda(settings, option);
int isOk = start(settings, option);
Device::reset();
return isOk;
}
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
void initCuda(Settings& settings, Options& option)
{
int deviceId = settings.getDeviceId();
// Choose current device (state of host-thread)
Device::setDevice(deviceId);
assert(Device::isCuda());
// It can be usefull to preload driver, by example to practice benchmarking! (sometimes slow under linux)
Device::loadCudaDriver(deviceId);
// Device::loadCudaDriverAll();// Force driver to be load for all GPU
}
int start(Settings& settings, Options& option)
{
// print
{
// Device::printAll();
Device::printAllSimple();
Device::printCurrent();
//Device::print(option.getDeviceId());
}
if (option.isTest())
{
return mainTest();
}
else
{
switch (settings.getLauchMode())
{
case IMAGE:
return mainImage(settings);
case ANIMABLE:
return mainAnimable(settings);
case FORCEBRUT:
return mainBrutForce(settings);
case BARIVOX:
return mainBarivox(settings);
default:
return mainImage(settings);
}
}
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/