def main(): args = get_args() logging.basicConfig(level=getattr(logging, args.log.upper())) dtype = np.dtype(args.dtype) elements = args.heap_size // (args.items * dtype.itemsize) heap_size = elements * args.items * dtype.itemsize if heap_size != args.heap_size: logging.warn('Heap size is not an exact multiple: using %d instead of %d', heap_args, args.heap_size) bug_compat = spead2.BUG_COMPAT_PYSPEAD_0_5_2 if args.pyspead else 0 item_group = spead2.send.ItemGroup( descriptor_frequency=args.descriptors, flavour=spead2.Flavour(4, 64, args.addr_bits, bug_compat)) for i in range(args.items): item_group.add_item(id=None, name='Test item {}'.format(i), description='A test item with arbitrary value', shape=(elements,), dtype=dtype, value=np.zeros((elements,), dtype=dtype)) if args.affinity is not None and len(args.affinity) > 0: spead2.ThreadPool.set_affinity(args.affinity[0]) thread_pool = spead2.ThreadPool(args.threads, args.affinity[1:] + args.affinity[:1]) else: thread_pool = spead2.ThreadPool(args.threads) config = spead2.send.StreamConfig( max_packet_size=args.packet, burst_size=args.burst, rate=args.rate * 1024**3 / 8) stream = spead2.send.trollius.UdpStream( thread_pool, args.host, args.port, config, args.buffer) try: trollius.get_event_loop().run_until_complete(run(item_group, stream, args)) except KeyboardInterrupt: sys.exit(1)
def main(): args = get_args() logging.basicConfig(level=getattr(logging, args.log.upper())) dtype = np.dtype(args.dtype) elements = args.heap_size // (args.items * dtype.itemsize) heap_size = elements * args.items * dtype.itemsize if heap_size != args.heap_size: logging.warn( 'Heap size is not an exact multiple: using %d instead of %d', heap_size, args.heap_size) bug_compat = spead2.BUG_COMPAT_PYSPEAD_0_5_2 if args.pyspead else 0 item_group = spead2.send.ItemGroup(descriptor_frequency=args.descriptors, flavour=spead2.Flavour( 4, 64, args.addr_bits, bug_compat)) for i in range(args.items): item_group.add_item(id=None, name='Test item {}'.format(i), description='A test item with arbitrary value', shape=(elements, ), dtype=dtype, value=np.zeros((elements, ), dtype=dtype)) if args.affinity is not None and len(args.affinity) > 0: spead2.ThreadPool.set_affinity(args.affinity[0]) thread_pool = spead2.ThreadPool(args.threads, args.affinity[1:] + args.affinity[:1]) else: thread_pool = spead2.ThreadPool(args.threads) config = spead2.send.StreamConfig(max_packet_size=args.packet, burst_size=args.burst, rate=args.rate * 10**9 / 8, burst_rate_ratio=args.burst_rate_ratio) if 'ibv' in args and args.ibv is not None: stream = spead2.send.trollius.UdpIbvStream(thread_pool, args.host, args.port, config, args.ibv, args.buffer, args.ttl or 1, args.ibv_vector, args.ibv_max_poll) elif args.ttl is not None: stream = spead2.send.trollius.UdpStream(thread_pool, args.host, args.port, config, args.buffer, ttl=args.ttl) else: # This is handled as a separate case, because passing TTL is only # valid for multicast addresses. stream = spead2.send.trollius.UdpStream(thread_pool, args.host, args.port, config, args.buffer) try: trollius.get_event_loop().run_until_complete( run(item_group, stream, args)) except KeyboardInterrupt: sys.exit(1)
# You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import spead2 import spead2.send import spead2.send.trollius import sys import logging import numpy as np import trollius logging.basicConfig(level=logging.INFO) thread_pool = spead2.ThreadPool() stream = spead2.send.trollius.UdpStream( thread_pool, "localhost", 8888, spead2.send.StreamConfig(rate=1e7)) del thread_pool # Make sure this doesn't crash anything shape = (40, 50) ig = spead2.send.ItemGroup(flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2)) item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32) item.value = np.zeros(shape, np.int32) coros = [ stream.async_send_heap(ig.get_heap()), stream.async_send_heap(ig.get_end()) ] # Delete things to check that there are no refcounting bugs del ig del stream trollius.get_event_loop().run_until_complete(trollius.wait(coros))
# You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import spead2 import spead2.send import spead2.send.trollius import logging import numpy as np import trollius logging.basicConfig(level=logging.INFO) thread_pool = spead2.ThreadPool() stream = spead2.send.trollius.UdpStream(thread_pool, "127.0.0.1", 8888, spead2.send.StreamConfig(rate=1e7)) del thread_pool # Make sure this doesn't crash anything shape = (40, 50) ig = spead2.send.ItemGroup( flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2)) item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32) item.value = np.zeros(shape, np.int32) futures = [ stream.async_send_heap(ig.get_heap()), stream.async_send_heap(ig.get_end()) ] # Delete things to check that there are no refcounting bugs del ig del stream trollius.get_event_loop().run_until_complete(trollius.wait(futures))
# # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import spead2 import spead2.send import spead2.send.trollius import logging import numpy as np import trollius logging.basicConfig(level=logging.INFO) thread_pool = spead2.ThreadPool() stream = spead2.send.trollius.UdpStream( thread_pool, "127.0.0.1", 8888, spead2.send.StreamConfig(rate=1e7)) del thread_pool # Make sure this doesn't crash anything shape = (40, 50) ig = spead2.send.ItemGroup(flavour=spead2.Flavour(4, 64, 48, spead2.BUG_COMPAT_PYSPEAD_0_5_2)) item = ig.add_item(0x1234, 'foo', 'a foo item', shape=shape, dtype=np.int32) item.value = np.zeros(shape, np.int32) futures = [ stream.async_send_heap(ig.get_heap()), stream.async_send_heap(ig.get_end()) ] # Delete things to check that there are no refcounting bugs del ig del stream trollius.get_event_loop().run_until_complete(trollius.wait(futures))