Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-36488: [C++] Import/Export ArrowDeviceArray#36489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ab982494d0ac9330256c1d59120858c15b02d3bcb6ff2dd19a858ccb6e7de49f0deaab849457b9244ea4f79d2a25e1939f1ca39b8d90ce9eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,6 +20,7 @@ | ||
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <memory> | ||
| #include <optional> | ||
| #include <string> | ||
| #include <string_view> | ||
| #include <utility> | ||
| @@ -57,18 +58,31 @@ class ARROW_EXPORT Buffer { | ||
| /// | ||
| /// \note The passed memory must be kept alive through some other means | ||
| Buffer(const uint8_t* data, int64_t size) | ||
| : is_mutable_(false), is_cpu_(true), data_(data), size_(size), capacity_(size) { | ||
| : is_mutable_(false), | ||
| is_cpu_(true), | ||
| data_(data), | ||
| size_(size), | ||
| capacity_(size), | ||
| device_type_(DeviceAllocationType::kCPU) { | ||
| SetMemoryManager(default_cpu_memory_manager()); | ||
| } | ||
| Buffer(const uint8_t* data, int64_t size, std::shared_ptr<MemoryManager> mm, | ||
| std::shared_ptr<Buffer> parent = NULLPTR) | ||
| std::shared_ptr<Buffer> parent = NULLPTR, | ||
| std::optional<DeviceAllocationType> device_type = std::nullopt) | ||
| : is_mutable_(false), | ||
| data_(data), | ||
| size_(size), | ||
| capacity_(size), | ||
| parent_(std::move(parent)) { | ||
| // SetMemoryManager will also set device_type_ | ||
| SetMemoryManager(std::move(mm)); | ||
| // if a device type is specified, use that instead. for example: | ||
| // CUDA_HOST. The CudaMemoryManager will set device_type_ to CUDA, | ||
| // but you can specify CUDA_HOST as the device type to override it. | ||
| if (device_type != std::nullopt) { | ||
| device_type_ = device_type; | ||
| } | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would a DCHECK be useful here to confirm that MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly, we'd have to add a | ||
| } | ||
| Buffer(uintptr_t address, int64_t size, std::shared_ptr<MemoryManager> mm, | ||
| @@ -240,6 +254,8 @@ class ARROW_EXPORT Buffer { | ||
| const std::shared_ptr<MemoryManager>& memory_manager() const { return memory_manager_; } | ||
| std::optional<DeviceAllocationType> device_type() const { return device_type_; } | ||
| std::shared_ptr<Buffer> parent() const { return parent_; } | ||
| /// \brief Get a RandomAccessFile for reading a buffer | ||
| @@ -294,6 +310,7 @@ class ARROW_EXPORT Buffer { | ||
| const uint8_t* data_; | ||
| int64_t size_; | ||
| int64_t capacity_; | ||
| std::optional<DeviceAllocationType> device_type_; | ||
westonpace marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this optional, are there any cases where the information is not available? | ||
| // null by default, but may be set | ||
| std::shared_ptr<Buffer> parent_; | ||
| @@ -309,6 +326,7 @@ class ARROW_EXPORT Buffer { | ||
| void SetMemoryManager(std::shared_ptr<MemoryManager> mm) { | ||
| memory_manager_ = std::move(mm); | ||
| is_cpu_ = memory_manager_->is_cpu(); | ||
| device_type_ = memory_manager_->device()->device_type(); | ||
| } | ||
| private: | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.