In my program, I want to use two steps to new
an object:
- use
cudaMalloc
to get a raw memory - use
placement new
to construct the object at the raw pointer.
So I wonder whether this is feasible because the pointer returned by cudaMalloc
is on the host and the placement new
is also running on the host. If this is not OK, are there any other best practices to do this?
The purpose of this separation is that I want to use an Allocator
class and its derived classes to management the raw memory for different devices such as CPU and GPU. And then construct objects by using these raw memory returned by Allocator
.
Aucun commentaire:
Enregistrer un commentaire