MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / unified_array

Class unified_array

less_slow.cpp:3300–3316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3298 */
3299template <typename type_>
3300class 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
3318template <typename>
3319struct dependent_false : std::false_type {};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected