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
33run
44build
55doc /html
6+ discrete_voronoi.pgm
Original file line number Diff line number Diff line change 22#include < thrust/mr/new.h>
33#include < thrust/mr/pool.h>
44#include < thrust/mr/disjoint_pool.h>
5+ #include < thrust/device_vector.h>
6+ #include < thrust/device_ptr.h>
57
68#include < cassert>
79
@@ -43,6 +45,18 @@ int main()
4345 do_stuff_with_vector<thrust::host_vector<int , Alloc> >(alloc);
4446 }
4547
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+
4660 typedef thrust::mr::unsynchronized_pool_resource<
4761 thrust::mr::new_delete_resource
4862 > Pool;
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2018 NVIDIA Corporation
2+ * Copyright 2018-2019 NVIDIA Corporation
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * 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
3131 {
3232 }
3333
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
3535 {
3636 return upstream_resource->allocate (bytes, alignment);
3737 }
3838
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
4040 {
4141 return upstream_resource->deallocate (p, bytes, alignment);
4242 }
You can’t perform that action at this time.
0 commit comments