Check for double support in OpenCL

This commit is contained in:
Tom Deakin 2015-07-31 16:54:11 +01:00
parent fd8bf0ef60
commit 3bb92747ba
2 changed files with 11 additions and 0 deletions

View File

@ -93,6 +93,14 @@ struct badmemsize : public std::exception
} }
}; };
struct nodouble : public std::exception
{
virtual const char * what () const throw ()
{
return "Device does not support double precision, please use --float";
}
};
template < typename T > template < typename T >
void check_solution(void* a_in, void* b_in, void* c_in) void check_solution(void* a_in, void* b_in, void* c_in)
{ {

View File

@ -165,6 +165,9 @@ int main(int argc, char *argv[])
std::string name = getDeviceName(device); std::string name = getDeviceName(device);
std::cout << "Using OpenCL device " << name << std::endl; std::cout << "Using OpenCL device " << name << std::endl;
// Check device can do double precision if requested
if (!useFloat && !device.getInfo<CL_DEVICE_DOUBLE_FP_CONFIG>()) throw nodouble();
// Check buffers fit on the device // Check buffers fit on the device
status = "Getting device memory sizes"; status = "Getting device memory sizes";
cl_ulong totalmem = device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>(); cl_ulong totalmem = device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>();