-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Changes from all commits
ab98249
4d0ac93
30256c1
d591208
58c15b0
2d3bcb6
ff2dd19
a858ccb
6e7de49
f0deaab
849457b
9244ea4
f79d2a2
5e1939f
1ca39b8
d90ce9e
File filter
Filter by extension
Conversations
Jump to
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
Member
Author
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.
Show resolved
Hide resolved
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.