Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 64c8632

Browse files
authored
Merge pull request #108 from NVIDIA/more-const-init
Added constexpr to synchronization object constructors
2 parents 1458b2c + 8e68ee8 commit 64c8632

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

include/cuda/std/barrier

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public:
4848
barrier(const barrier &) = delete;
4949
barrier & operator=(const barrier &) = delete;
5050

51-
_LIBCUDACXX_INLINE_VISIBILITY
51+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
5252
barrier(std::ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
5353
: std::__barrier_base<_CompletionF, _Sco>(__expected, __completion) {
5454
}

include/cuda/std/latch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA
2727
template<thread_scope _Sco>
2828
class latch : public std::__latch_base<_Sco> {
2929
public:
30-
_LIBCUDACXX_INLINE_VISIBILITY
30+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
3131
latch(std::ptrdiff_t __count)
3232
: std::__latch_base<_Sco>(__count) {
3333
}

include/cuda/std/semaphore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class counting_semaphore : public std::__semaphore_base<__least_max_value, _Sco>
2929
{
3030
static_assert(__least_max_value <= std::__semaphore_base<__least_max_value, _Sco>::max(), "");
3131
public:
32-
_LIBCUDACXX_INLINE_VISIBILITY
32+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
3333
counting_semaphore(ptrdiff_t __count = 0) : std::__semaphore_base<__least_max_value, _Sco>(__count) { }
3434
~counting_semaphore() = default;
3535

libcxx/include/barrier

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ private:
302302
}
303303
};
304304

305-
static inline _LIBCUDACXX_INLINE_VISIBILITY
306-
constexpr uint64_t __init(ptrdiff_t __count) _NOEXCEPT
305+
static inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
306+
uint64_t __init(ptrdiff_t __count) _NOEXCEPT
307307
{
308308
return (((1u << 31) - __count) << 32)
309309
| ((1u << 31) - __count);
@@ -312,7 +312,7 @@ private:
312312
public:
313313
__barrier_base() = default;
314314

315-
_LIBCUDACXX_INLINE_VISIBILITY
315+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
316316
__barrier_base(ptrdiff_t __count, __empty_completion = __empty_completion())
317317
: __phase_arrived_expected(__init(__count)) {
318318
}
@@ -369,7 +369,7 @@ public:
369369
template<class _CompletionF = __empty_completion>
370370
class barrier : public __barrier_base<_CompletionF> {
371371
public:
372-
_LIBCUDACXX_INLINE_VISIBILITY
372+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
373373
barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
374374
: __barrier_base<_CompletionF>(__count, __completion) {
375375
}

libcxx/include/latch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class __latch_base
7171
{
7272
_LIBCUDACXX_LATCH_ALIGNMENT __atomic_base<ptrdiff_t, _Sco> __counter;
7373
public:
74-
inline _LIBCUDACXX_INLINE_VISIBILITY
75-
constexpr explicit __latch_base(ptrdiff_t __expected)
74+
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
75+
explicit __latch_base(ptrdiff_t __expected)
7676
: __counter(__expected) { }
7777

7878
~__latch_base() = default;

libcxx/include/semaphore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public:
119119
return numeric_limits<ptrdiff_t>::max();
120120
}
121121

122-
_LIBCUDACXX_INLINE_VISIBILITY
123-
__atomic_semaphore_base(ptrdiff_t __count) : __count(__count) { }
122+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
123+
__atomic_semaphore_base(ptrdiff_t __count) noexcept : __count(__count) { }
124124

125125
~__atomic_semaphore_base() = default;
126126

@@ -190,7 +190,7 @@ public:
190190
_LIBCUDACXX_INLINE_VISIBILITY
191191
static constexpr ptrdiff_t max() noexcept { return 1; }
192192

193-
_LIBCUDACXX_INLINE_VISIBILITY
193+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
194194
__atomic_semaphore_base(ptrdiff_t __available) : __available(__available) { }
195195

196196
~__atomic_semaphore_base() = default;
@@ -428,7 +428,7 @@ class counting_semaphore : public __semaphore_base<__least_max_value, 0>
428428
{
429429
static_assert(__least_max_value <= __semaphore_base<__least_max_value, 0>::max(), "");
430430
public:
431-
_LIBCUDACXX_INLINE_VISIBILITY
431+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
432432
counting_semaphore(ptrdiff_t __count = 0) : __semaphore_base<__least_max_value, 0>(__count) { }
433433
~counting_semaphore() = default;
434434

0 commit comments

Comments
 (0)