Tests: Added double precision check

This commit is contained in:
Philippe Tillet
2015-07-26 21:35:39 -07:00
parent 4715723e61
commit 5f78dedbcd
8 changed files with 62 additions and 32 deletions

View File

@@ -144,6 +144,39 @@ std::string Device::extensions() const
}
}
std::pair<unsigned int, unsigned int> Device::nv_compute_capability() const
{
switch(backend_)
{
case OPENCL:
return std::pair<unsigned int, unsigned int>(ocl::info<CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV>(h_.cl()), ocl::info<CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV>(h_.cl()));
#ifdef ISAAC_WITH_CUDA
case CUDA:
return std::pair<unsigned int, unsigned int>(cuGetInfo<CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR>(), cuGetInfo<CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR>());
#endif
default:
throw;
}
}
bool Device::fp64_support() const
{
switch(backend_)
{
case OPENCL:
return ocl::info<CL_DEVICE_DOUBLE_FP_CONFIG>(h_.cl());
#ifdef ISAAC_WITH_CUDA
case CUDA:
return true;
#endif
default:
throw;
}
}
#ifdef ISAAC_WITH_CUDA
#define CUDACASE(CUNAME) case CUDA: return cuGetInfo<CUNAME>();
#else
@@ -168,24 +201,6 @@ WRAP_ATTRIBUTE(size_t, warp_wavefront_size, CU_DEVICE_ATTRIBUTE_WARP_SIZE, CL_DE
WRAP_ATTRIBUTE(size_t, clock_rate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, CL_DEVICE_MAX_CLOCK_FREQUENCY)
std::pair<unsigned int, unsigned int> Device::nv_compute_capability() const
{
switch(backend_)
{
case OPENCL:
return std::pair<unsigned int, unsigned int>(ocl::info<CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV>(h_.cl()), ocl::info<CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV>(h_.cl()));
#ifdef ISAAC_WITH_CUDA
case CUDA:
return std::pair<unsigned int, unsigned int>(cuGetInfo<CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR>(), cuGetInfo<CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR>());
#endif
default:
throw;
}
}
}

View File

@@ -106,7 +106,7 @@ Program::Program(Context const & context, std::string const & source) : backend_
std::string fname(cache_path + sha1);
//Load cached program
const char * build_opt = "";
std::string build_opt;
if(cache_path.size())
{
std::ifstream cached(fname, std::ios::binary);
@@ -120,7 +120,7 @@ Program::Program(Context const & context, std::string const & source) : backend_
char* cbuffer = buffer.data();
h_.cl() = clCreateProgramWithBinary(context_.h_.cl(), devices.size(), devices.data(), &len, (const unsigned char **)&cbuffer, NULL, &err);
ocl::check(err);
ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt, NULL, NULL));
ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt.c_str(), NULL, NULL));
return;
}
}
@@ -129,7 +129,7 @@ Program::Program(Context const & context, std::string const & source) : backend_
const char * csrc = source.c_str();
h_.cl() = clCreateProgramWithSource(context_.h_.cl(), 1, &csrc, &srclen, &err);
try{
ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt, NULL, NULL));
ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt.c_str(), NULL, NULL));
}catch(ocl::exception::build_program_failure const & e){
for(std::vector<cl_device_id>::const_iterator it = devices.begin(); it != devices.end(); ++it)
{