user3195869
user3195869

Reputation: 95

threading issue with armadillo fft2

I'm using the armadillo c++ library to do 2D fourier transforms, and I'm finding that the results are inconsistent when I use multiple threads. Specifically, I'm getting different results from the fft2 function.

The data I'm passing to fft2 is thread-local. I've also verified that the input data is not affected by the presence of other threads working on parallel problems. fft2 is producing different results if there are other threads also calling fft2. Does anyone know about threading issues with fft2? Or, armadillo in general?

Upvotes: 0

Views: 163

Answers (1)

darcamo
darcamo

Reputation: 3493

Armadillo itself does not seem to have any kind of state that could make it not thread-safe (maybe the random generation part could be a problem). That is, it seems to be thread-save as long as the libraries it depends on are thread-safe.

I also had problems in the past with incorrect results when using multithreading. In my case the culprit was openblas, which I was compiling myself. In order to investigate the problem, I had created a small project to check that results from some SVD and matrix multiplications were the same when running in parallel and serially. They were not. Then I stumbled into an issue in openblas repository about thread safity, where I saw a flag that I could set in CMake (USE_LOCKING) when compiling openblas. After setting USE_LOCKING to true when compiling openblas I had no more problems with wrong results given by armadillo.

You are probably experience something similar, but regarding the fft2 library. Specially since you mention that other performing work in other threads does not pose a problem if they are not related to fft2. Thus, you should check if fft2 is thread-safe instead of thinking about armadillo.

Upvotes: 1

Related Questions