Skip to content

[GPU] Replace CV_XADD by C++11 method #3987

@SunBlack

Description

@SunBlack

Currently we are using proprietary code here

#ifdef __GNUC__
#if !defined WIN32 && (defined __i486__ || defined __i586__ || defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__)
#define CV_XADD __sync_fetch_and_add
#else
#include <ext/atomicity.h>
#define CV_XADD __gnu_cxx::__exchange_and_add
#endif
#elif defined WIN32 || defined _WIN32
#include <intrin.h>
#define CV_XADD(addr,delta) _InterlockedExchangeAdd((long volatile*)(addr), (delta))
#else
template<typename _Tp> static inline _Tp CV_XADD(_Tp* addr, _Tp delta)
{ int tmp = *addr; *addr += delta; return tmp; }
#endif

I don't know why there is a thread-safety reference counter, but we can replace CV_XADD by atomic operations of C++11 (I believe atomic_fetch_add should fit)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions