Commit ec373647 authored by Nikita Shulga's avatar Nikita Shulga

Use std::atomic in getExpTab32f and getLogTab32f

Reads and writes to volatile bool are not guaranteed to be atomic.
parent 626bfbf3
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels_core.hpp" #include "opencl_kernels_core.hpp"
#include <atomic>
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include "mathfuncs.hpp" #include "mathfuncs.hpp"
...@@ -2119,8 +2120,8 @@ const double* getExpTab64f() ...@@ -2119,8 +2120,8 @@ const double* getExpTab64f()
const float* getExpTab32f() const float* getExpTab32f()
{ {
static float CV_DECL_ALIGNED(64) expTab_f[EXPTAB_MASK+1]; static float CV_DECL_ALIGNED(64) expTab_f[EXPTAB_MASK+1];
static volatile bool expTab_f_initialized = false; static std::atomic<bool> expTab_f_initialized(false);
if (!expTab_f_initialized) if (!expTab_f_initialized.load())
{ {
for( int j = 0; j <= EXPTAB_MASK; j++ ) for( int j = 0; j <= EXPTAB_MASK; j++ )
expTab_f[j] = (float)expTab[j]; expTab_f[j] = (float)expTab[j];
...@@ -2401,8 +2402,8 @@ const double* getLogTab64f() ...@@ -2401,8 +2402,8 @@ const double* getLogTab64f()
const float* getLogTab32f() const float* getLogTab32f()
{ {
static float CV_DECL_ALIGNED(64) logTab_f[(LOGTAB_MASK+1)*2]; static float CV_DECL_ALIGNED(64) logTab_f[(LOGTAB_MASK+1)*2];
static volatile bool logTab_f_initialized = false; static std::atomic<bool> logTab_f_initialized(false);
if (!logTab_f_initialized) if (!logTab_f_initialized.load())
{ {
for (int j = 0; j < (LOGTAB_MASK+1)*2; j++) for (int j = 0; j < (LOGTAB_MASK+1)*2; j++)
logTab_f[j] = (float)logTab[j]; logTab_f[j] = (float)logTab[j];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment