Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix libcudacxx example #3013

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libcudacxx/examples/concurrent_hash_table.cu
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
// TODO: It would be great if this example could NOT depend on Thrust.
#include <thrust/allocate_unique.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/host_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/pair.h>
#include <thrust/system/cuda/vector.h>
#include <thrust/universal_allocator.h>
#include <thrust/universal_vector.h>

#include <cassert>
#include <cstdio>
Expand All @@ -24,7 +26,7 @@ template <typename Key,
typename Value,
typename Hash = thrust::identity<Key>,
typename KeyEqual = thrust::equal_to<Key>,
typename MemoryResource = thrust::universal_raw_memory_resource>
typename MemoryResource = thrust::universal_memory_resource>
struct concurrent_hash_table
{
// Elements transition from state_empty -> state_reserved ->
Expand Down Expand Up @@ -185,8 +187,8 @@ int main()

auto freq = thrust::allocate_unique<table>(thrust::universal_allocator<table>{}, 8);

thrust::cuda::universal_vector<int> input = [] {
thrust::cuda::universal_vector<int> v(2048);
thrust::universal_vector<int> input = [] {
thrust::universal_vector<int> v(2048);
std::mt19937 gen(1337);
std::uniform_int_distribution<long> dis(0, 7);
thrust::generate(v.begin(), v.end(), [&] {
Expand Down Expand Up @@ -216,8 +218,8 @@ int main()

auto freq = thrust::allocate_unique<table>(thrust::universal_allocator<table>{}, 8, identity_modulo<int>(4));

thrust::cuda::universal_vector<int> input = [] {
thrust::cuda::universal_vector<int> v(2048);
thrust::universal_vector<int> input = [] {
thrust::universal_vector<int> v(2048);
std::mt19937 gen(1337);
std::uniform_int_distribution<long> dis(0, 7);
thrust::generate(v.begin(), v.end(), [&] {
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/examples/trie.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ THE SOFTWARE.

*/

#include <cuda/std/atomic>
#include <cuda/atomic>
#include <cuda/std/cstddef>
#include <cuda/std/cstdint>

Expand Down
6 changes: 3 additions & 3 deletions libcudacxx/examples/trie_mt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ struct trie
{
struct ref
{
std::atomic<trie*> ptr = LIBCUDACXX_ATOMIC_VAR_INIT(nullptr);
std::atomic<trie*> ptr = ATOMIC_VAR_INIT(nullptr);
// the flag will protect against multiple pointer updates
std::atomic_flag flag = LIBCUDACXX_ATOMIC_VAR_INIT(0);
std::atomic_flag flag = ATOMIC_VAR_INIT(0);
} next[26];
std::atomic<int> count = LIBCUDACXX_ATOMIC_VAR_INIT(0);
std::atomic<int> count = ATOMIC_VAR_INIT(0);
};
int index_of(char c)
{
Expand Down
Loading