CUDA: select number to times from CLI
This commit is contained in:
parent
0edd0646a6
commit
30305d83e0
@ -11,7 +11,7 @@
|
||||
|
||||
#define DATATYPE double
|
||||
unsigned int ARRAY_SIZE = 50000000;
|
||||
#define NTIMES 10
|
||||
unsigned int NTIMES = 10;
|
||||
|
||||
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
|
||||
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
|
||||
@ -37,6 +37,14 @@ struct invaliddevice : public std::exception
|
||||
}
|
||||
};
|
||||
|
||||
struct badntimes : public std::exception
|
||||
{
|
||||
virtual const char * what () const throw ()
|
||||
{
|
||||
return "Chosen number of times is invalid, must be >= 2";
|
||||
}
|
||||
};
|
||||
|
||||
size_t sizes[4] = {
|
||||
2 * sizeof(DATATYPE) * ARRAY_SIZE,
|
||||
2 * sizeof(DATATYPE) * ARRAY_SIZE,
|
||||
@ -145,6 +153,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
parseArguments(argc, argv);
|
||||
|
||||
if (NTIMES < 2) throw badntimes();
|
||||
|
||||
// Check device index is in range
|
||||
int count;
|
||||
cudaGetDeviceCount(&count);
|
||||
@ -344,6 +354,14 @@ void parseArguments(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[i], "--numtimes") || !strcmp(argv[i], "-n"))
|
||||
{
|
||||
if (++i >= argc || !parseUInt(argv[i], &NTIMES))
|
||||
{
|
||||
std::cout << "Invalid number of times" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
|
||||
{
|
||||
std::cout << std::endl;
|
||||
@ -353,6 +371,7 @@ void parseArguments(int argc, char *argv[])
|
||||
std::cout << " --list List available devices" << std::endl;
|
||||
std::cout << " --device INDEX Select device at INDEX" << std::endl;
|
||||
std::cout << " -s --arraysize SIZE Use SIZE elements in the array" << std::endl;
|
||||
std::cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << std::endl;
|
||||
std::cout << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user