228 :
229 host(
new T[count] { }),
230 size(count *
sizeof(T))
231 {
232 const int device = device::get();
233
234 prop.type = CU_MEM_ALLOCATION_TYPE_PINNED;
235 prop.location.type = CU_MEM_LOCATION_TYPE_DEVICE;
236 prop.location.id = device;
237 device::check(cuMemAddressReserve(&ptr, 2 * size, 0, 0, 0));
238
239
240 device::check(cuMemCreate(&handle, size, &prop, 0));
241 device::check(cuMemMap(ptr, size, 0, handle, 0));
242 device::check(cuMemMap(ptr + size, size, 0, handle, 0));
243
244 access.location.type = CU_MEM_LOCATION_TYPE_DEVICE;
245 access.location.id = device;
246 access.flags = CU_MEM_ACCESS_FLAGS_PROT_READWRITE;
247 device::check(cuMemSetAccess(ptr, 2 * size, &access, 1));
248 }
std::unique_ptr< T[]> host