Fix the polymorphic adaptor to actually use its template parameter.
Github
MODIFY
.gitignore
.gitignore
@@ -54,6 +54,7 @@ compile_commands.json
CTestTestfile.cmake
build
doc/html
+discrete_voronoi.pgm
# End of https://www.gitignore.io/api/c++,cmake

MODIFY
examples/mr_basic.cu
examples/mr_basic.cu
#include <thrust/mr/new.h>
#include <thrust/mr/pool.h>
#include <thrust/mr/disjoint_pool.h>
+#include <thrust/device_vector.h>
+#include <thrust/device_ptr.h>
#include <cassert>
@@ -43,6 +45,18 @@ int main()
do_stuff_with_vector<thrust::host_vector<int, Alloc> >(alloc);
}
+ {
+ // use the global device_ptr-flavored device memory resource
+ typedef thrust::device_ptr_memory_resource<thrust::device_memory_resource> Resource;
+ thrust::mr::polymorphic_adaptor_resource<thrust::device_ptr<void> > adaptor(
+ thrust::mr::get_global_resource<Resource>()
+ );
+ typedef thrust::mr::polymorphic_allocator<int, thrust::device_ptr<void> > Alloc;
+ Alloc alloc(&adaptor);
+
+ do_stuff_with_vector<thrust::device_vector<int, Alloc> >(alloc);
+ }
+
typedef thrust::mr::unsynchronized_pool_resource<
thrust::mr::new_delete_resource
> Pool;

MODIFY
thrust/mr/polymorphic_adaptor.h
thrust/mr/polymorphic_adaptor.h
/*
- * Copyright 2018 NVIDIA Corporation
+ * Copyright 2018-2019 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,12 +31,12 @@ public:
{
}
- virtual void * do_allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
+ virtual Pointer do_allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
{
return upstream_resource->allocate(bytes, alignment);
}
- virtual void do_deallocate(void * p, std::size_t bytes, std::size_t alignment) THRUST_OVERRIDE
+ virtual void do_deallocate(Pointer p, std::size_t bytes, std::size_t alignment) THRUST_OVERRIDE
{
return upstream_resource->deallocate(p, bytes, alignment);
}

Fix the polymorphic adaptor to actually use its template parameter.

Github #968