Don't try to free OpenCL objects that are 0 handles. Don't run opencl test if a context can't be created.

This commit is contained in:
clemahieu 2017-01-17 19:41:28 -06:00
commit ffebcf389c
2 changed files with 22 additions and 11 deletions

View file

@ -45,15 +45,17 @@ TEST (work, opencl)
{
rai::logging logging (rai::unique_path ());
auto work (rai::opencl_work::create (true, {0, 1, 1024 * 1024}, logging));
ASSERT_NE (nullptr, work);
rai::work_pool pool (std::move (work));
ASSERT_NE (nullptr, pool.opencl);
rai::uint256_union root;
for (auto i (0); i < 1; ++i)
if (work != nullptr)
{
rai::random_pool.GenerateBlock (root.bytes.data (), root.bytes.size ());
auto result (pool.generate (root));
ASSERT_FALSE (pool.work_validate (root, result));
rai::work_pool pool (std::move (work));
ASSERT_NE (nullptr, pool.opencl);
rai::uint256_union root;
for (auto i (0); i < 1; ++i)
{
rai::random_pool.GenerateBlock (root.bytes.data (), root.bytes.size ());
auto result (pool.generate (root));
ASSERT_FALSE (pool.work_validate (root, result));
}
}
}

View file

@ -691,9 +691,18 @@ logging (logging_a)
rai::opencl_work::~opencl_work ()
{
clReleaseKernel (kernel);
clReleaseProgram (program);
clReleaseContext (context);
if (kernel != 0)
{
clReleaseKernel (kernel);
}
if (program != 0)
{
clReleaseProgram (program);
}
if (context != 0)
{
clReleaseContext (context);
}
}
boost::optional <uint64_t> rai::opencl_work::generate_work (rai::work_pool & pool_a, rai::uint256_union const & root_a)