Skip to content
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

Rename udp_ibv_stream_config -> udp_ibv_config #106

Merged
merged 3 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/cpp-ibverbs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the :cpp:class:`spead2::recv::udp_ibv_reader` and
.. doxygenclass:: spead2::recv::udp_ibv_reader
:members: udp_ibv_reader

.. doxygenclass:: spead2::send::udp_ibv_stream_config
.. doxygenclass:: spead2::send::udp_ibv_config
:members:

.. doxygenclass:: spead2::send::udp_ibv_stream
Expand Down
4 changes: 2 additions & 2 deletions doc/migrate-3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ a "fluent" style e.g.:
spead2::send::stream_config().set_max_packet_size(9172).set_rate(1e6)

For :doc:`ibverbs <py-ibverbs>` streams the changes are more significant. There
is now a :py:class:`spead2.send.UdpIbvStreamConfig` class that works similarly
is now a :py:class:`spead2.send.UdpIbvConfig` class that works similarly
to :py:class:`spead2.send.StreamConfig`, but configures properties specific to
the ibverbs stream. The old constructor is still available (but deprecated);
however, the constants :py:data:`.UdpIbvStream.DEFAULT_BUFFER_SIZE` and
:py:data:`.UdpIbvStream.DEFAULT_MAX_POLL` have moved to the
:class:`~spead2.send.UdpIbvStreamConfig` class.
:class:`~spead2.send.UdpIbvConfig` class.

Substreams
----------
Expand Down
4 changes: 2 additions & 2 deletions doc/py-ibverbs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class, analogous to :py:class:`spead2.send.asyncio.UdpStream`.
There is an additional configuration class for ibverbs-specific
configuration:

.. py:class:: spead2.send.UdpIbvStreamConfig(*, endpoints=[], interface_address='', buffer_size=DEFAULT_BUFFER_SIZE, ttl=1, comp_vector=0, max_poll=DEFAULT_MAX_POLL, memory_regions=[])
.. py:class:: spead2.send.UdpIbvConfig(*, endpoints=[], interface_address='', buffer_size=DEFAULT_BUFFER_SIZE, ttl=1, comp_vector=0, max_poll=DEFAULT_MAX_POLL, memory_regions=[])

:param List[Tuple[str, int]] endpoints: Peer endpoints (one per substream)
:param str interface_address: Hostname/IP address of the interface which
Expand Down Expand Up @@ -173,4 +173,4 @@ configuration:
:param config: Stream configuration
:type config: :py:class:`spead2.send.StreamConfig`
:param udp_ibv_config: Additional stream configuration
:type udp_ibv_config: :py:class:`spead2.send.UdpIbvStreamConfig`
:type udp_ibv_config: :py:class:`spead2.send.UdpIbvConfig`
38 changes: 19 additions & 19 deletions include/spead2/send_udp_ibv.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace send
/**
* Configuration for @ref udp_ibv_stream.
*/
class udp_ibv_stream_config
class udp_ibv_config
{
public:
typedef std::pair<const void *, std::size_t> memory_region;
Expand All @@ -68,7 +68,7 @@ class udp_ibv_stream_config
* It cannot be used as is, because the interface address and at least one
* endpoint must be supplied.
*/
udp_ibv_stream_config();
udp_ibv_config();

/// Get the configured endpoints
const std::vector<boost::asio::ip::udp::endpoint> &get_endpoints() const { return endpoints; }
Expand All @@ -77,13 +77,13 @@ class udp_ibv_stream_config
*
* @throws std::invalid_argument if any element of @a endpoints is not an IPv4 multicast address.
*/
udp_ibv_stream_config &set_endpoints(const std::vector<boost::asio::ip::udp::endpoint> &endpoints);
udp_ibv_config &set_endpoints(const std::vector<boost::asio::ip::udp::endpoint> &endpoints);
/**
* Append a single endpoint.
*
* @throws std::invalid_argument if @a endpoint is not an IPv4 multicast address.
*/
udp_ibv_stream_config &add_endpoint(const boost::asio::ip::udp::endpoint &endpoint);
udp_ibv_config &add_endpoint(const boost::asio::ip::udp::endpoint &endpoint);

/// Get the currently set interface address
const boost::asio::ip::address get_interface_address() const { return interface_address; }
Expand All @@ -92,7 +92,7 @@ class udp_ibv_stream_config
*
* @throws std::invalid_argument if @a interface_address is not an IPv4 address.
*/
udp_ibv_stream_config &set_interface_address(const boost::asio::ip::address &interface_address);
udp_ibv_config &set_interface_address(const boost::asio::ip::address &interface_address);

/// Get the currently configured buffer size.
std::size_t get_buffer_size() const { return buffer_size; }
Expand All @@ -103,12 +103,12 @@ class udp_ibv_stream_config
* used may be slightly different to round it to a whole number of
* packet-sized slots.
*/
udp_ibv_stream_config &set_buffer_size(std::size_t buffer_size);
udp_ibv_config &set_buffer_size(std::size_t buffer_size);

/// Get the IP TTL
std::uint8_t get_ttl() const { return ttl; }
/// Set the IP TTL
udp_ibv_stream_config &set_ttl(std::uint8_t ttl);
udp_ibv_config &set_ttl(std::uint8_t ttl);

/// Get the completion channel vector (see @ref set_comp_vector)
int get_comp_vector() const { return comp_vector; }
Expand All @@ -121,7 +121,7 @@ class udp_ibv_stream_config
* vectors and have them load-balanced, without concern for the number
* available.
*/
udp_ibv_stream_config &set_comp_vector(int comp_vector);
udp_ibv_config &set_comp_vector(int comp_vector);

/// Get maximum number of times to poll in a row (see @ref set_max_poll)
int get_max_poll() const { return max_poll; }
Expand All @@ -135,7 +135,7 @@ class udp_ibv_stream_config
*
* @throws std::invalid_argument if @a max_poll is zero.
*/
udp_ibv_stream_config &set_max_poll(int max_poll);
udp_ibv_config &set_max_poll(int max_poll);

/// Get currently registered memory regions
const std::vector<memory_region> &get_memory_regions() const { return memory_regions; }
Expand All @@ -148,9 +148,9 @@ class udp_ibv_stream_config
* Memory regions must not overlap; this is only validating when constructing
* the stream.
*/
udp_ibv_stream_config &set_memory_regions(const std::vector<memory_region> &memory_regions);
udp_ibv_config &set_memory_regions(const std::vector<memory_region> &memory_regions);
/// Append a memory region (see @ref set_memory_regions)
udp_ibv_stream_config &add_memory_region(const void *ptr, std::size_t size);
udp_ibv_config &add_memory_region(const void *ptr, std::size_t size);
};

class udp_ibv_stream : public stream
Expand All @@ -159,37 +159,37 @@ class udp_ibv_stream : public stream
/**
* Backwards-compatibility constructor (taking only a single endpoint).
*
* Refer to @ref udp_ibv_stream_config for an explanation of the arguments.
* Refer to @ref udp_ibv_config for an explanation of the arguments.
*
* @throws std::invalid_argument if @a endpoint is not an IPv4 multicast address
* @throws std::invalid_argument if @a interface_address is not an IPv4 address
*/
SPEAD2_DEPRECATED("use udp_ibv_stream_config")
SPEAD2_DEPRECATED("use udp_ibv_config")
udp_ibv_stream(
io_service_ref io_service,
const boost::asio::ip::udp::endpoint &endpoint,
const stream_config &config,
const boost::asio::ip::address &interface_address,
std::size_t buffer_size = udp_ibv_stream_config::default_buffer_size,
std::size_t buffer_size = udp_ibv_config::default_buffer_size,
int ttl = 1,
int comp_vector = 0,
int max_poll = udp_ibv_stream_config::default_max_poll);
int max_poll = udp_ibv_config::default_max_poll);

/**
* Constructor.
*
* @param io_service I/O service for sending data
* @param config Common stream configuration
* @param udp_ibv_config Class-specific stream configuration
* @param ibv_config Class-specific stream configuration
*
* @throws std::invalid_argument if @a udp_ibv_config does not an interface address set.
* @throws std::invalid_argument if @a udp_ibv_config does not have any endpoints set.
* @throws std::invalid_argument if @a ibv_config does not have an interface address set.
* @throws std::invalid_argument if @a ibv_config does not have any endpoints set.
* @throws std::invalid_argument if memory regions overlap.
*/
udp_ibv_stream(
io_service_ref io_service,
const stream_config &config,
const udp_ibv_stream_config &udp_ibv_config);
const udp_ibv_config &ibv_config);
};

} // namespace send
Expand Down
62 changes: 31 additions & 31 deletions src/py_send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class udp_stream_wrapper : public Base
* hand. We store a separate copy in the wrapper in a Python-centric format.
* When constructing the stream, we make a copy with the C++ view.
*/
class udp_ibv_stream_config_wrapper : public udp_ibv_stream_config
class udp_ibv_config_wrapper : public udp_ibv_config
{
public:
std::vector<std::pair<std::string, std::uint16_t>> py_endpoints;
Expand Down Expand Up @@ -439,17 +439,17 @@ class udp_ibv_stream_wrapper : public Base
make_address(pool->get_io_service(), interface_address),
buffer_size, ttl, comp_vector, max_poll)
{
deprecation_warning("pass a UdpIbvStreamConfig");
deprecation_warning("pass a UdpIbvConfig");
}

udp_ibv_stream_wrapper(
std::shared_ptr<thread_pool> pool,
const stream_config &config,
const udp_ibv_stream_config &udp_ibv_config,
const udp_ibv_config &ibv_config,
std::vector<py::buffer_info> &&buffer_infos)
: Base(pool,
config,
udp_ibv_config),
ibv_config),
buffer_infos(std::move(buffer_infos))
{
}
Expand Down Expand Up @@ -542,36 +542,36 @@ static py::class_<T> udp_ibv_stream_register(py::module &m, const char *name)
"thread_pool"_a, "multicast_group"_a, "port"_a,
"config"_a = stream_config(),
"interface_address"_a,
"buffer_size"_a = udp_ibv_stream_config::default_buffer_size,
"buffer_size"_a = udp_ibv_config::default_buffer_size,
"ttl"_a = 1,
"comp_vector"_a = 0,
"max_poll"_a = udp_ibv_stream_config::default_max_poll)
"max_poll"_a = udp_ibv_config::default_max_poll)
.def(py::init([](std::shared_ptr<thread_pool_wrapper> thread_pool,
const stream_config &config,
const udp_ibv_stream_config_wrapper &udp_ibv_config_wrapper)
const udp_ibv_config_wrapper &ibv_config_wrapper)
{
udp_ibv_stream_config udp_ibv_config = udp_ibv_config_wrapper;
udp_ibv_config.set_endpoints(
udp_ibv_config ibv_config = ibv_config_wrapper;
ibv_config.set_endpoints(
make_endpoints<boost::asio::ip::udp>(
thread_pool->get_io_service(),
udp_ibv_config_wrapper.py_endpoints));
udp_ibv_config.set_interface_address(
ibv_config_wrapper.py_endpoints));
ibv_config.set_interface_address(
make_address(thread_pool->get_io_service(),
udp_ibv_config_wrapper.py_interface_address));
ibv_config_wrapper.py_interface_address));
std::vector<std::pair<const void *, std::size_t>> regions;
std::vector<py::buffer_info> buffer_infos;
regions.reserve(udp_ibv_config_wrapper.py_memory_regions.size());
regions.reserve(ibv_config_wrapper.py_memory_regions.size());
buffer_infos.reserve(regions.size());
for (auto &buffer : udp_ibv_config_wrapper.py_memory_regions)
for (auto &buffer : ibv_config_wrapper.py_memory_regions)
{
buffer_infos.push_back(request_buffer_info(buffer, PyBUF_C_CONTIGUOUS));
regions.emplace_back(
buffer_infos.back().ptr,
buffer_infos.back().itemsize * buffer_infos.back().size);
}
udp_ibv_config.set_memory_regions(regions);
ibv_config.set_memory_regions(regions);

return new T(std::move(thread_pool), config, udp_ibv_config, std::move(buffer_infos));
return new T(std::move(thread_pool), config, ibv_config, std::move(buffer_infos));
}),
"thread_pool"_a,
"config"_a = stream_config(),
Expand Down Expand Up @@ -873,25 +873,25 @@ py::module register_module(py::module &parent)
}

#if SPEAD2_USE_IBV
py::class_<udp_ibv_stream_config_wrapper>(m, "UdpIbvStreamConfig")
.def(py::init(&data_class_constructor<udp_ibv_stream_config_wrapper>))
.def_readwrite("endpoints", &udp_ibv_stream_config_wrapper::py_endpoints)
.def_readwrite("memory_regions", &udp_ibv_stream_config_wrapper::py_memory_regions)
.def_readwrite("interface_address", &udp_ibv_stream_config_wrapper::py_interface_address)
py::class_<udp_ibv_config_wrapper>(m, "UdpIbvConfig")
.def(py::init(&data_class_constructor<udp_ibv_config_wrapper>))
.def_readwrite("endpoints", &udp_ibv_config_wrapper::py_endpoints)
.def_readwrite("memory_regions", &udp_ibv_config_wrapper::py_memory_regions)
.def_readwrite("interface_address", &udp_ibv_config_wrapper::py_interface_address)
.def_property("buffer_size",
SPEAD2_PTMF(udp_ibv_stream_config_wrapper, get_buffer_size),
SPEAD2_PTMF_VOID(udp_ibv_stream_config_wrapper, set_buffer_size))
SPEAD2_PTMF(udp_ibv_config_wrapper, get_buffer_size),
SPEAD2_PTMF_VOID(udp_ibv_config_wrapper, set_buffer_size))
.def_property("ttl",
SPEAD2_PTMF(udp_ibv_stream_config_wrapper, get_ttl),
SPEAD2_PTMF_VOID(udp_ibv_stream_config_wrapper, set_ttl))
SPEAD2_PTMF(udp_ibv_config_wrapper, get_ttl),
SPEAD2_PTMF_VOID(udp_ibv_config_wrapper, set_ttl))
.def_property("comp_vector",
SPEAD2_PTMF(udp_ibv_stream_config_wrapper, get_comp_vector),
SPEAD2_PTMF_VOID(udp_ibv_stream_config_wrapper, set_comp_vector))
SPEAD2_PTMF(udp_ibv_config_wrapper, get_comp_vector),
SPEAD2_PTMF_VOID(udp_ibv_config_wrapper, set_comp_vector))
.def_property("max_poll",
SPEAD2_PTMF(udp_ibv_stream_config_wrapper, get_max_poll),
SPEAD2_PTMF_VOID(udp_ibv_stream_config_wrapper, set_max_poll))
.def_readonly_static("DEFAULT_BUFFER_SIZE", &udp_ibv_stream_config_wrapper::default_buffer_size)
.def_readonly_static("DEFAULT_MAX_POLL", &udp_ibv_stream_config_wrapper::default_max_poll);
SPEAD2_PTMF(udp_ibv_config_wrapper, get_max_poll),
SPEAD2_PTMF_VOID(udp_ibv_config_wrapper, set_max_poll))
.def_readonly_static("DEFAULT_BUFFER_SIZE", &udp_ibv_config_wrapper::default_buffer_size)
.def_readonly_static("DEFAULT_MAX_POLL", &udp_ibv_config_wrapper::default_max_poll);

{
auto stream_class = udp_ibv_stream_register<udp_ibv_stream_wrapper<stream_wrapper<udp_ibv_stream>>>(m, "UdpIbvStream");
Expand Down