This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from NVIDIA/bugfix/atomic_gcc
Fix GCC/Clang only compilation of <cuda/std/atomic>
- Loading branch information
Showing
6 changed files
with
88 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef __LIBCUDACXX_ATOMIC_SCOPES_H | ||
#define __LIBCUDACXX_ATOMIC_SCOPES_H | ||
|
||
#ifndef __ATOMIC_BLOCK | ||
#define __ATOMIC_SYSTEM 0 // 0 indicates default | ||
#define __ATOMIC_DEVICE 1 | ||
#define __ATOMIC_BLOCK 2 | ||
#define __ATOMIC_THREAD 10 | ||
#endif //__ATOMIC_BLOCK | ||
|
||
enum thread_scope { | ||
thread_scope_system = __ATOMIC_SYSTEM, | ||
thread_scope_device = __ATOMIC_DEVICE, | ||
thread_scope_block = __ATOMIC_BLOCK, | ||
thread_scope_thread = __ATOMIC_THREAD | ||
}; | ||
|
||
#define _LIBCUDACXX_ATOMIC_SCOPE_TYPE ::cuda::thread_scope | ||
#define _LIBCUDACXX_ATOMIC_SCOPE_DEFAULT ::cuda::thread_scope::system | ||
|
||
struct __thread_scope_thread_tag { }; | ||
struct __thread_scope_block_tag { }; | ||
struct __thread_scope_device_tag { }; | ||
struct __thread_scope_system_tag { }; | ||
|
||
template<int _Scope> struct __scope_enum_to_tag { }; | ||
/* This would be the implementation once an actual thread-scope backend exists. | ||
template<> struct __scope_enum_to_tag<(int)thread_scope_thread> { | ||
using type = __thread_scope_thread_tag; }; | ||
Until then: */ | ||
template<> struct __scope_enum_to_tag<(int)thread_scope_thread> { | ||
using type = __thread_scope_block_tag; }; | ||
template<> struct __scope_enum_to_tag<(int)thread_scope_block> { | ||
using type = __thread_scope_block_tag; }; | ||
template<> struct __scope_enum_to_tag<(int)thread_scope_device> { | ||
using type = __thread_scope_device_tag; }; | ||
template<> struct __scope_enum_to_tag<(int)thread_scope_system> { | ||
using type = __thread_scope_system_tag; }; | ||
|
||
template <int _Scope> | ||
_LIBCUDACXX_INLINE_VISIBILITY auto constexpr __scope_tag() -> | ||
typename __scope_enum_to_tag<_Scope>::type { | ||
return typename __scope_enum_to_tag<_Scope>::type(); | ||
} | ||
|
||
#endif // __LIBCUDACXX_ATOMIC_SCOPES_H |