void free(view_type& rng) { Allocator allocator; if(rng.data()) allocator.deallocate(rng.data(), rng.size()); #ifdef VERBOSE std::cerr << util::type_printer<DeviceCoordinator>::print() << "::free()" << std::endl; #endif impl::reset(rng); }
std::pair<CudaEvent, view_type> copy(const ArrayView< value_type, HostCoordinator< value_type, PinnedAllocator< value_type, alignment>>> &from, view_type &to) { assert(from.size()==to.size()); #ifdef VERBOSE using oType = ArrayView< value_type, HostCoordinator< value_type, PinnedAllocator< value_type, alignment>>>; std::cout << util::pretty_printer<DeviceCoordinator>::print(*this) << "::" << util::blue("copy") << "(asynchronous, " << from.size() << ")" << "\n " << util::type_printer<oType>::print() << " @ " << from.data() << util::yellow(" -> ") << util::type_printer<view_type>::print() << " @ " << to.data() << std::endl; #endif auto status = cudaMemcpy( reinterpret_cast<void*>(to.begin()), reinterpret_cast<const void*>(from.begin()), from.size()*sizeof(value_type), cudaMemcpyHostToDevice ); if(status != cudaSuccess) { std::cerr << util::red("error") << " bad CUDA memcopy, unable to copy " << sizeof(T)*from.size() << " bytes from host to device"; exit(-1); } CudaEvent event; return std::make_pair(event, to); }
// fill memory void set(view_type &rng, value_type value) { gpu::fill<value_type>(rng.data(), value, rng.size()); }