forked from HiPerCoRe/cuFFTAdvisor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.cpp
More file actions
67 lines (57 loc) · 1.95 KB
/
validator.cpp
File metadata and controls
67 lines (57 loc) · 1.95 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
#include "validator.h"
namespace cuFFTAdvisor {
void Validator::validate(int x, int y, int z, int n, int device,
int maxSignalInc, int maxMemMB,
bool allowTrans, bool squareOnly) {
validate(x, y, z, n, device);
if (maxSignalInc <= 0) {
throw std::logic_error(
"Max signal (perc) increase must be positive. Wrong input or int "
"overflow\n");
}
if (maxMemMB <= 0) {
throw std::logic_error(
"Max memory must be positive. Wrong input or int overflow\n");
}
if (maxMemMB > std::ceil(toMB(getTotalMemory(device)))) {
throw std::logic_error("Selected device does not have that much memory.\n");
}
if (allowTrans && squareOnly) {
throw std::logic_error("Incompatible parameters. See help for detailed info.\n");
}
}
void Validator::validate(int device) {
int devices = getDeviceCount(); // This function call returns 0 if
// there are no CUDA capable devices.
if (0 == devices) {
throw std::logic_error(
"There are no available device(s) that support CUDA\n");
}
if ((device < 0) || (device >= devices)) {
throw std::logic_error(
"No such CUDA device available. Wrong input or int overflow\n");
}
}
void Validator::validate(int x, int y, int z, int n, int device) {
if ((x <= 0) || (INT_MAX == x)) {
throw std::logic_error(
"X dim must be positive and < INT_MAX. Wrong input or int overflow.\n");
}
if (y <= 0) {
throw std::logic_error(
"Y dim must be positive. Wrong input or int overflow.\n");
}
if (z <= 0) {
throw std::logic_error(
"Z dim must be positive. Wrong input or int overflow.\n");
}
if (n <= 0) {
throw std::logic_error(
"N dim must be positive. Wrong input or int overflow.\n");
}
if (device < 0) {
throw std::logic_error("Device identifier must be positive. Wrong input.");
}
validate(device);
}
} // namespace cuFFTAdvisor