Logging opencl diagnostics also to log file.
This commit is contained in:
parent
afdbe0c6ef
commit
d3d866c92f
3 changed files with 17 additions and 11 deletions
|
@ -2479,7 +2479,10 @@ bool rai::handle_node_options (boost::program_options::variables_map & vm)
|
|||
rai::opencl_environment environment (error);
|
||||
if (!error)
|
||||
{
|
||||
environment.dump ();
|
||||
environment.dump (std::cout);
|
||||
std::stringstream stream;
|
||||
environment.dump (stream);
|
||||
BOOST_LOG (node.logging.log) << stream.str ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -411,7 +411,7 @@ rai::opencl_environment::opencl_environment (bool & error_a)
|
|||
}
|
||||
}
|
||||
|
||||
void rai::opencl_environment::dump ()
|
||||
void rai::opencl_environment::dump (std::ostream & stream)
|
||||
{
|
||||
auto index (0);
|
||||
auto device_count (0);
|
||||
|
@ -419,30 +419,30 @@ void rai::opencl_environment::dump ()
|
|||
{
|
||||
device_count += i.devices.size ();
|
||||
}
|
||||
std::cout << boost::str (boost::format ("Found %1% platforms and %2% devices\n") % platforms.size () % device_count);
|
||||
stream << boost::str (boost::format ("OpenCL found %1% platforms and %2% devices\n") % platforms.size () % device_count);
|
||||
for (auto i (platforms.begin ()), n (platforms.end ()); i != n; ++i, ++index)
|
||||
{
|
||||
std::vector <unsigned> queries = {CL_PLATFORM_PROFILE, CL_PLATFORM_VERSION, CL_PLATFORM_NAME, CL_PLATFORM_VENDOR, CL_PLATFORM_EXTENSIONS};
|
||||
std::cout << "Platform: " << index << std::endl;
|
||||
stream << "Platform: " << index << std::endl;
|
||||
for (auto j (queries.begin ()), m (queries.end ()); j != m; ++j)
|
||||
{
|
||||
size_t platformInfoCount = 0;
|
||||
clGetPlatformInfo(i->platform, *j, 0, nullptr, &platformInfoCount);
|
||||
std::vector <char> info (platformInfoCount);
|
||||
clGetPlatformInfo(i->platform, *j, info.size (), info.data (), nullptr);
|
||||
std::cout << info.data () << std::endl;
|
||||
stream << info.data () << std::endl;
|
||||
}
|
||||
for (auto j (i->devices.begin ()), m (i->devices.end ()); j != m; ++j)
|
||||
{
|
||||
std::vector <unsigned> queries = {CL_DEVICE_NAME, CL_DEVICE_VENDOR, CL_DEVICE_PROFILE};
|
||||
std::cout << "Device: " << j - i->devices.begin () << std::endl;
|
||||
stream << "Device: " << j - i->devices.begin () << std::endl;
|
||||
for (auto k (queries.begin ()), o (queries.end ()); k != o; ++k)
|
||||
{
|
||||
size_t platformInfoCount = 0;
|
||||
clGetDeviceInfo(*j, *k, 0, nullptr, &platformInfoCount);
|
||||
std::vector <char> info (platformInfoCount);
|
||||
clGetDeviceInfo(*j, *k, info.size (), info.data (), nullptr);
|
||||
std::cout << '\t' << info.data () << std::endl;
|
||||
stream << '\t' << info.data () << std::endl;
|
||||
}
|
||||
size_t deviceTypeCount = 0;
|
||||
clGetDeviceInfo(*j, CL_DEVICE_TYPE, 0, nullptr, &deviceTypeCount);
|
||||
|
@ -470,18 +470,18 @@ void rai::opencl_environment::dump ()
|
|||
device_type_string = "Unknown";
|
||||
break;
|
||||
}
|
||||
std::cout << '\t' << device_type_string << std::endl;
|
||||
stream << '\t' << device_type_string << std::endl;
|
||||
size_t compilerAvailableCount = 0;
|
||||
clGetDeviceInfo(*j, CL_DEVICE_COMPILER_AVAILABLE, 0, nullptr, &compilerAvailableCount);
|
||||
std::vector <uint8_t> compilerAvailableInfo (compilerAvailableCount);
|
||||
clGetDeviceInfo(*j, CL_DEVICE_COMPILER_AVAILABLE, compilerAvailableCount, compilerAvailableInfo.data (), 0);
|
||||
std::cout << '\t' << "Compiler available: " << (compilerAvailableInfo [0] ? "true" : "false") << std::endl;
|
||||
stream << '\t' << "Compiler available: " << (compilerAvailableInfo [0] ? "true" : "false") << std::endl;
|
||||
size_t computeUnitsAvailableCount = 0;
|
||||
clGetDeviceInfo(*j, CL_DEVICE_MAX_COMPUTE_UNITS, 0, nullptr, &computeUnitsAvailableCount);
|
||||
std::vector <uint8_t> computeUnitsAvailableInfo (computeUnitsAvailableCount);
|
||||
clGetDeviceInfo(*j, CL_DEVICE_MAX_COMPUTE_UNITS, computeUnitsAvailableCount, computeUnitsAvailableInfo.data (), 0);
|
||||
uint64_t computeUnits (computeUnitsAvailableInfo [0] | (computeUnitsAvailableInfo [1] << 8) | (computeUnitsAvailableInfo [2] << 16) | (computeUnitsAvailableInfo [3] << 24));
|
||||
std::cout << '\t' << "Compute units available: " << computeUnits << std::endl;
|
||||
stream << '\t' << "Compute units available: " << computeUnits << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -767,6 +767,9 @@ std::unique_ptr <rai::opencl_work> rai::opencl_work::create (bool create_a, rai:
|
|||
{
|
||||
auto error (false);
|
||||
rai::opencl_environment environment (error);
|
||||
std::stringstream stream;
|
||||
environment.dump (stream);
|
||||
BOOST_LOG (logging_a.log) << stream.str ();
|
||||
if (!error)
|
||||
{
|
||||
result.reset (new rai::opencl_work (error, config_a, environment, logging_a));
|
||||
|
|
|
@ -28,7 +28,7 @@ class opencl_environment
|
|||
{
|
||||
public:
|
||||
opencl_environment (bool &);
|
||||
void dump ();
|
||||
void dump (std::ostream & stream);
|
||||
std::vector <rai::opencl_platform> platforms;
|
||||
};
|
||||
union uint256_union;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue