You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2024/04/04 00:26:35 UTC
Re: [PR] GH-40078: [C++] Import/Export ArrowDeviceArrayStream [arrow]
felipecrv commented on code in PR #40807:
URL: https://github.com/apache/arrow/pull/40807#discussion_r1550652287
##########
cpp/src/arrow/c/helpers.h:
##########
@@ -84,6 +92,14 @@ inline void ArrowArrayMove(struct ArrowArray* src, struct ArrowArray* dest) {
ArrowArrayMarkReleased(src);
}
+inline void ArrowDeviceArrayMove(struct ArrowDeviceArray* src,
+ struct ArrowDeviceArray* dest) {
+ assert(dest != src);
+ assert(!ArrowDeviceArrayIsReleased(src));
+ memcpy(dest, src, sizeof(struct ArrowDeviceArray));
Review Comment:
Why is `ArrowDeviceArrayMove` in the opposite direction of `memcpy`, `memmove`...?
##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -2052,7 +2065,19 @@ Status ExportStreamNext(const std::shared_ptr<ChunkedArray>& src, int64_t i,
}
}
-template <typename T>
+Status ExportDeviceStreamNext(const std::shared_ptr<ChunkedArray>& src, int64_t i,
+ std::shared_ptr<Device::SyncEvent> sync,
+ struct ArrowDeviceArray* out_array) {
+ if (i >= src->num_chunks()) {
+ // End of stream
+ ArrowArrayMarkReleased(&out_array->array);
+ return Status::OK();
+ } else {
+ return ExportDeviceArray(*src->chunk(static_cast<int>(i)), sync, out_array);
Review Comment:
`std::move(sync)` to save on an atomic ref-count update.
##########
cpp/src/arrow/c/helpers.h:
##########
@@ -84,6 +92,14 @@ inline void ArrowArrayMove(struct ArrowArray* src, struct ArrowArray* dest) {
ArrowArrayMarkReleased(src);
}
+inline void ArrowDeviceArrayMove(struct ArrowDeviceArray* src,
+ struct ArrowDeviceArray* dest) {
+ assert(dest != src);
+ assert(!ArrowDeviceArrayIsReleased(src));
+ memcpy(dest, src, sizeof(struct ArrowDeviceArray));
Review Comment:
Oh... the others are inverted too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org