| 3298 | */ |
| 3299 | template <typename type_> |
| 3300 | class unified_array { |
| 3301 | type_ *data_ = nullptr; |
| 3302 | std::size_t size_ = 0; |
| 3303 | |
| 3304 | public: |
| 3305 | unified_array(std::size_t size) : size_(size) { |
| 3306 | if (cudaMallocManaged(&data_, sizeof(type_) * size_) != cudaSuccess) throw std::bad_alloc(); |
| 3307 | } |
| 3308 | |
| 3309 | ~unified_array() noexcept { cudaFree(data_); } |
| 3310 | |
| 3311 | type_ *begin() const noexcept { return data_; } |
| 3312 | type_ *end() const noexcept { return data_ + size_; } |
| 3313 | type_ &operator[](std::size_t index) noexcept { return data_[index]; } |
| 3314 | type_ operator[](std::size_t index) const noexcept { return data_[index]; } |
| 3315 | std::size_t size() const noexcept { return size_; } |
| 3316 | }; |
| 3317 | |
| 3318 | template <typename> |
| 3319 | struct dependent_false : std::false_type {}; |
nothing calls this directly
no outgoing calls
no test coverage detected