|
29 | 29 |
|
30 | 30 | #include <chrono> |
31 | 31 | #include <iostream> |
32 | | -#include <thread> |
33 | 32 | #include <optional> |
| 33 | +#include <thread> |
34 | 34 |
|
35 | 35 | #define ORE_OPENCL_MAX_N_DEV_INFO 1024U |
36 | 36 | #define ORE_OPENCL_MAX_N_DEV_INFO_LARGE 65536U |
@@ -394,13 +394,13 @@ OpenClContext::~OpenClContext() { |
394 | 394 | } |
395 | 395 |
|
396 | 396 | for (Size i = 0; i < kernel_.size(); ++i) { |
397 | | - if (disposed_[i]) |
| 397 | + if (disposed_[i] || !hasKernel_[i]) |
398 | 398 | continue; |
399 | 399 | releaseKernel(kernel_[i], "ore kernel"); |
400 | 400 | } |
401 | 401 |
|
402 | 402 | for (Size i = 0; i < program_.size(); ++i) { |
403 | | - if (disposed_[i]) |
| 403 | + if (disposed_[i] || !hasKernel_[i]) |
404 | 404 | continue; |
405 | 405 | releaseProgram(program_[i], "ore program"); |
406 | 406 | } |
@@ -556,8 +556,10 @@ void OpenClContext::init() { |
556 | 556 | void OpenClContext::disposeCalculation(const std::size_t id) { |
557 | 557 | QL_REQUIRE(!disposed_[id - 1], "OpenClContext::disposeCalculation(): id " << id << " was already disposed."); |
558 | 558 | disposed_[id - 1] = true; |
559 | | - releaseKernel(kernel_[id - 1], "kernel id " + std::to_string(id) + " (during dispose())"); |
560 | | - releaseProgram(program_[id - 1], "program id " + std::to_string(id) + " (during dispose())"); |
| 559 | + if (hasKernel_[id - 1]) { |
| 560 | + releaseKernel(kernel_[id - 1], "kernel id " + std::to_string(id) + " (during dispose())"); |
| 561 | + releaseProgram(program_[id - 1], "program id " + std::to_string(id) + " (during dispose())"); |
| 562 | + } |
561 | 563 | } |
562 | 564 |
|
563 | 565 | std::pair<std::size_t, bool> OpenClContext::initiateCalculation(const std::size_t n, const std::size_t id, |
@@ -691,6 +693,10 @@ void OpenClContext::updateVariatesPool() { |
691 | 693 |
|
692 | 694 | std::size_t fpSize = settings_.useDoublePrecision ? sizeof(double) : sizeof(float); |
693 | 695 |
|
| 696 | + QL_REQUIRE(!settings_.useDoublePrecision || supportsDoublePrecision(), |
| 697 | + "OpenClContext::updateVariatesPool(): double precision is configured for this calculation, but not " |
| 698 | + "supported by the device. Switch to single precision or use an appropriate device."); |
| 699 | + |
694 | 700 | cl_event initEvent; |
695 | 701 | if (variatesPoolSize_ == 0) { |
696 | 702 |
|
@@ -1279,7 +1285,6 @@ void OpenClContext::finalizeCalculation(std::vector<double*>& output) { |
1279 | 1285 | // build kernel if necessary |
1280 | 1286 |
|
1281 | 1287 | if (!hasKernel_[currentId_ - 1]) { |
1282 | | - |
1283 | 1288 | std::string fpTypeStr = settings_.useDoublePrecision ? "double" : "float"; |
1284 | 1289 | std::string fpEpsStr = settings_.useDoublePrecision ? "0x1.0p-52" : "0x1.0p-23f"; |
1285 | 1290 | std::string fpSuffix = settings_.useDoublePrecision ? std::string() : "f"; |
@@ -1466,7 +1471,6 @@ void OpenClContext::finalizeCalculation(std::vector<double*>& output) { |
1466 | 1471 | } |
1467 | 1472 |
|
1468 | 1473 | for (std::size_t part = 0; part < kernel_[currentId_ - 1].size(); ++part) { |
1469 | | - |
1470 | 1474 | bool initFromValues = part > 0; |
1471 | 1475 | bool cacheToValues = currentSsa_.size() > 1 && part < currentSsa_.size() - 1; |
1472 | 1476 | bool generateOutputValues = part == currentSsa_.size() - 1; |
|
0 commit comments