| 881 | |
| 882 | template <typename T> |
| 883 | DeviceMemory<T> StreamExecutor::AllocateZeroed() { |
| 884 | DeviceMemoryBase buf = Allocate(sizeof(T), /*memory_space=*/0); |
| 885 | if (buf.is_null()) { |
| 886 | return DeviceMemory<T>{}; |
| 887 | } |
| 888 | |
| 889 | DeviceMemory<T> result(buf); |
| 890 | bool ok = SynchronousMemZero(&result, sizeof(T)).ok(); |
| 891 | if (!ok) { |
| 892 | Deallocate(&result); |
| 893 | return DeviceMemory<T>{}; |
| 894 | } |
| 895 | |
| 896 | return result; |
| 897 | } |
| 898 | |
| 899 | template <typename T> |
| 900 | DeviceMemory<T> StreamExecutor::GetSubBuffer(DeviceMemory<T> *parent, |