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 #179 from NVIDIA/feature/atomic_refactor
Refactor <atomic> and move implementation to libcxx
- Loading branch information
Showing
21 changed files
with
3,104 additions
and
2,436 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// UNSUPPORTED: libcpp-has-no-threads, pre-sm-60 | ||
// UNSUPPORTED: windows && pre-sm-70 | ||
|
||
// <cuda/atomic> | ||
|
||
// cuda::atomic<key> | ||
|
||
// Original test issue: | ||
// https://github.com/NVIDIA/libcudacxx/issues/160 | ||
|
||
#include <cuda/atomic> | ||
|
||
template <typename T> | ||
__host__ __device__ | ||
constexpr bool unused(T &&) {return true;} | ||
|
||
int main(int argc, char ** argv) | ||
{ | ||
// Test default aligned user type | ||
{ | ||
struct key { | ||
int32_t a; | ||
int32_t b; | ||
}; | ||
static_assert(alignof(key) == 4, ""); | ||
cuda::atomic<key> k; | ||
auto r = k.load(); | ||
k.store(r); | ||
(void)k.exchange(r); | ||
unused(r); | ||
} | ||
// Test forcibly aligned user type | ||
{ | ||
struct alignas(8) key { | ||
int32_t a; | ||
int32_t b; | ||
}; | ||
static_assert(alignof(key) == 8, ""); | ||
cuda::atomic<key> k; | ||
auto r = k.load(); | ||
k.store(r); | ||
(void)k.exchange(r); | ||
unused(r); | ||
} | ||
return 0; | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.