File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ thrust/system/cuda/detail/.gitignore
3
3
run
4
4
build
5
5
doc /html
6
+ discrete_voronoi.pgm
Original file line number Diff line number Diff line change 2
2
#include < thrust/mr/new.h>
3
3
#include < thrust/mr/pool.h>
4
4
#include < thrust/mr/disjoint_pool.h>
5
+ #include < thrust/device_vector.h>
6
+ #include < thrust/device_ptr.h>
5
7
6
8
#include < cassert>
7
9
@@ -43,6 +45,18 @@ int main()
43
45
do_stuff_with_vector<thrust::host_vector<int , Alloc> >(alloc);
44
46
}
45
47
48
+ {
49
+ // use the global device_ptr-flavored device memory resource
50
+ typedef thrust::device_ptr_memory_resource<thrust::device_memory_resource> Resource;
51
+ thrust::mr::polymorphic_adaptor_resource<thrust::device_ptr<void > > adaptor (
52
+ thrust::mr::get_global_resource<Resource>()
53
+ );
54
+ typedef thrust::mr::polymorphic_allocator<int , thrust::device_ptr<void > > Alloc;
55
+ Alloc alloc (&adaptor);
56
+
57
+ do_stuff_with_vector<thrust::device_vector<int , Alloc> >(alloc);
58
+ }
59
+
46
60
typedef thrust::mr::unsynchronized_pool_resource<
47
61
thrust::mr::new_delete_resource
48
62
> Pool;
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2018 NVIDIA Corporation
2
+ * Copyright 2018-2019 NVIDIA Corporation
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -31,12 +31,12 @@ class polymorphic_adaptor_resource THRUST_FINAL : public memory_resource<Pointer
31
31
{
32
32
}
33
33
34
- virtual void * do_allocate (std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
34
+ virtual Pointer do_allocate (std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
35
35
{
36
36
return upstream_resource->allocate (bytes, alignment);
37
37
}
38
38
39
- virtual void do_deallocate (void * p, std::size_t bytes, std::size_t alignment) THRUST_OVERRIDE
39
+ virtual void do_deallocate (Pointer p, std::size_t bytes, std::size_t alignment) THRUST_OVERRIDE
40
40
{
41
41
return upstream_resource->deallocate (p, bytes, alignment);
42
42
}
You can’t perform that action at this time.
0 commit comments