CUDA bug: ARRAY_SIZE on CLI not being resized

The ARRAY_SIZE was being resized before the CLI args were read
This commit is contained in:
Tom Deakin 2015-07-27 16:49:36 +01:00
parent a74e7cee4c
commit ec9d73b8d5

View File

@ -150,22 +150,22 @@ int main(int argc, char *argv[])
<< "Version: " << VERSION_STRING << std::endl << "Version: " << VERSION_STRING << std::endl
<< "Implementation: CUDA" << std::endl << std::endl; << "Implementation: CUDA" << std::endl << std::endl;
if (ARRAY_SIZE % 1024 != 0)
{
unsigned int OLD_ARRAY_SIZE = ARRAY_SIZE;
ARRAY_SIZE -= ARRAY_SIZE % 1024;
std::cout
<< "Warning: array size must divide 1024" << std::endl
<< "Resizing array from " << OLD_ARRAY_SIZE
<< " to " << ARRAY_SIZE << std::endl;
}
try try
{ {
parseArguments(argc, argv); parseArguments(argc, argv);
if (NTIMES < 2) throw badntimes(); if (NTIMES < 2) throw badntimes();
if (ARRAY_SIZE % 1024 != 0)
{
unsigned int OLD_ARRAY_SIZE = ARRAY_SIZE;
ARRAY_SIZE -= ARRAY_SIZE % 1024;
std::cout
<< "Warning: array size must divide 1024" << std::endl
<< "Resizing array from " << OLD_ARRAY_SIZE
<< " to " << ARRAY_SIZE << std::endl;
}
// Check device index is in range // Check device index is in range
int count; int count;
cudaGetDeviceCount(&count); cudaGetDeviceCount(&count);