1

How can I perform atomic operations like atomicCAS with ArrayFire to avoid locking?

(that is the same across all backends)

Mehran Khazaeizadeh
  • 1,021
  • 1
  • 7
  • 13
  • ArrayFire provides building block functionality that can run on batch of data in parallel. AtomicCAS style operations are what the name says, for fine grain control over elements of given input based on the algorithm, usually they are not used in the same style as how a given algorithm is run on data. Kindly share your use case so that we can help accordingly. – pradeep Sep 16 '20 at 06:04
  • Thanks, I guessed so. I've used the `max` reduction method of ArrayFire, but it seems to be sequential somehow because it took much longer than iterating over data using `gfor`. I know the right way is to use the `max` method but for now I wanted to use a faster method, so I wanted to use `gfor` with possibly available `atomicCAS` method. What do you suggest for my case? – Mehran Khazaeizadeh Sep 17 '20 at 21:03
  • I am not sure what to suggest or why would parallelised version would be slower without looking at some code. Please share a standalone snippet if that is possible so that I can debug and suggest work around. – pradeep Sep 22 '20 at 15:40
  • Thanks. There is nothing special about it but its execution time grows with data size (it is noticeable; while with hardware processing it should not take that much; when iterating over data using empty gfor it finishes much faster than executing the max method). `const auto maxValue = af::max(data);` byte_t is equivalent to u8. I'm using the cpu backend (mkl loads successfully). – Mehran Khazaeizadeh Sep 22 '20 at 18:34
  • CPU backend reduction is handwritten pure old serial reduction. Hence, it will increase in runtime as data size grows as expected. CPU backend is currently useful for quick prototyping without the need of a GPU based setup and then run the code without the need to recompilation on a system with GPU be it via CUDA or OpenCL backend. For speedups, you need to run this code on other backends and check if the performance is not as expected. – pradeep Sep 23 '20 at 02:53
  • Sorry forgot about the atomicCAS query, I am still not clear on this. Kindly reach out to us on our slack channel. Here's the invite - https://join.slack.com/t/arrayfire-org/shared_invite/MjI4MjIzMDMzMTczLTE1MDI5ODg4NzYtN2QwNGE3ODA5OQ – pradeep Sep 23 '20 at 02:55
  • Thanks for invitation. It was nice if arrayFire would use mkl built-in methods for such operations: https://software.intel.com/content/www/us/en/develop/documentation/oneapi-mkl-dpcpp-developer-reference/top/summary-statistics/summary-statistics-routines/mkl-stats-min-max.html – Mehran Khazaeizadeh Sep 23 '20 at 23:10
  • Feel free to raise the request on our github project page and we will try to look into as soon as possible. – pradeep Sep 24 '20 at 04:57

0 Answers0