Skip to content

Commit

Permalink
buffer default to async transfer in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
burlen committed Nov 2, 2023
1 parent 8277dfe commit a60ddf2
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions hamr_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ class HAMR_EXPORT buffer
buffer(allocator alloc, const hamr::stream &strm, transfer sync = transfer::async);

/** Construct an empty buffer. This constructor will result in the default
* stream for the chosen technology with transfer::sync_host mode which
* synchronizes after data movement from a device to the host.
* stream for the chosen technology with transfer::async.
*
* @param[in] alloc a ::buffer_allocator indicates what technology
* manages the data internally
*/
buffer(allocator alloc) : buffer(alloc, stream(), transfer::sync_host) {}
buffer(allocator alloc) : buffer(alloc, stream(), transfer::async) {}

/** Construct a buffer with storage allocated but unitialized.
*
Expand All @@ -83,15 +82,14 @@ class HAMR_EXPORT buffer

/** Construct a buffer with storage allocated but unitialized. This
* constructor will result in the default stream for the chosen technology
* with transfer::sync_host mode which synchronizes after data movement from
* a device to the host.
* with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicates what technology
* manages the data internally
* @param[in] n_elem the initial size of the new buffer
*/
buffer(allocator alloc, size_t n_elem) :
buffer(alloc, stream(), transfer::sync_host, n_elem) {}
buffer(alloc, stream(), transfer::async, n_elem) {}

/** Construct a buffer with storage allocated and initialized to a single
* value.
Expand Down Expand Up @@ -123,9 +121,7 @@ class HAMR_EXPORT buffer

/** Construct a buffer with storage allocated and initialized to a single
* value. This constructor will result in the default stream for the chosen
* technology with transfer::sync_host mode which synchronizes after data
* movement from a device to the host. For fully asynchronous data transfers
* one must explicitly prtovide a stream and specify the asynchronous mode.
* technology with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicates what technology
* manages the data internally
Expand All @@ -134,7 +130,7 @@ class HAMR_EXPORT buffer
* contents
*/
buffer(allocator alloc, size_t n_elem, const T &val) :
buffer(alloc, stream(), transfer::sync_host, n_elem, val) {}
buffer(alloc, stream(), transfer::async, n_elem, val) {}

/** Construct a buffer with storage allocated and initialized to the array
* of values. This array is always assumed to be accessible on the host. Use
Expand Down Expand Up @@ -174,8 +170,7 @@ class HAMR_EXPORT buffer
* of values. This array is always assumed to be accessible on the host. Use
* one of the zero-copy constructors if the data is already accessible on
* the device. This constructor will result in the default stream for the
* chosen technology with transfer::sync_host mode which synchronizes after
* data movement from a device to the host.
* chosen technology with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicates what technology
* manages the data internally
Expand All @@ -185,7 +180,7 @@ class HAMR_EXPORT buffer
* initialize the buffer contents
*/
buffer(allocator alloc, size_t n_elem, const T *vals) :
buffer(alloc, stream(), transfer::sync_host, n_elem, vals) {}
buffer(alloc, stream(), transfer::async, n_elem, vals) {}

/** Construct by directly providing the buffer contents. This can be used
* for zero-copy transfer of data. One must also name the allocator type
Expand Down Expand Up @@ -241,8 +236,7 @@ class HAMR_EXPORT buffer
* allocator type and owner are used internally to know how to
* automatically move data during inter technology transfers. This
* constructor will result in the default stream for the chosen technology
* with transfer::sync_host mode which synchronizes after data movement from
* a device to the host.
* with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicating the technology
* backing the pointer
Expand All @@ -257,7 +251,7 @@ class HAMR_EXPORT buffer
*/
template <typename delete_func_t>
buffer(allocator alloc, size_t size, int owner, T *ptr, delete_func_t df)
: buffer(alloc, stream(), transfer::sync_host, size, owner, ptr, df) {}
: buffer(alloc, stream(), transfer::async, size, owner, ptr, df) {}

/** Construct by directly providing the buffer contents. This can be used
* for zero-copy transfer of data. One must also name the allocator type
Expand Down Expand Up @@ -316,8 +310,7 @@ class HAMR_EXPORT buffer
* ::buffer_allocator is used to create the deleter that will be called
* when this instance is finished with the memeory. Use this constructor to
* transfer ownership of the array. This constructor will result in the
* default stream for the chosen technology with transfer::sync_host mode
* which synchronizes after data movement from a device to the host.
* default stream for the chosen technology with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicating the technology
* backing the pointer
Expand All @@ -329,7 +322,7 @@ class HAMR_EXPORT buffer
* @param[in] ptr a pointer to the array
*/
buffer(allocator alloc, size_t size, int owner, T *ptr) :
buffer(alloc, stream(), transfer::sync_host, size, owner, ptr) {}
buffer(alloc, stream(), transfer::async, size, owner, ptr) {}

/** Construct by directly providing the buffer contents. This can be used
* for zero-copy transfer of data. One must also name the allocator type
Expand Down Expand Up @@ -379,8 +372,7 @@ class HAMR_EXPORT buffer
* allocator type and owner are used internally to know how to
* automatically move data during inter technology transfers. This
* constructor will result in the default stream for the chosen technology
* with transfer::sync_host mode which synchronizes after data movement from
* a device to the host.
* with transfer::async mode.
*
* @param[in] alloc a ::buffer_allocator indicating the technology
* backing the pointer
Expand All @@ -392,7 +384,7 @@ class HAMR_EXPORT buffer
* @param[in] data a shared pointer managing the data
*/
buffer(allocator alloc, size_t size, int owner, const std::shared_ptr<T> &data)
: buffer(alloc, stream(), transfer::sync_host, size, owner, data) {}
: buffer(alloc, stream(), transfer::async, size, owner, data) {}

/// copy construct from the passed buffer
template <typename U>
Expand Down Expand Up @@ -426,11 +418,8 @@ class HAMR_EXPORT buffer
buffer(allocator alloc, const hamr::stream &strm, const buffer<U> &other)
: buffer(alloc, strm, transfer::async, other) {}

/** Copy construct from the passed buffer, while specifying a potentially
* different allocator, stream, and synchronization behavior. This
* constructor will result in the default stream for the chosen technology
* with transfer::sync_host mode which synchronizes after data movement from
* a device to the host.
/** Copy construct from the passed buffer using the specified allocator.
* The stream and sync mode are obtained from the copied instance.
*
* @param[in] alloc a ::buffer_allocator indicates what technology
* manages the data internally
Expand Down

0 comments on commit a60ddf2

Please sign in to comment.