Skip to content
Snippets Groups Projects

Casacore MT performance

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Jan David Mol

    Code to toy with casacore.measures multi-threading performance. A lock can be enabled to improve performance.

    Edited
    casacore-mt.py 1.15 KiB
    import timeit
    import numpy
    import datetime
    import threading
    import tangostationcontrol
    from tango import DeviceProxy
    from tangostationcontrol.beam.delays import Delays
    
    Antenna_Field_Reference_ITRF_R = numpy.array([3826896.192,  460979.502, 5064658.231])
    Antenna_Reference_ITRF_R = numpy.array([[3826885.71898169,  460981.16159554, 5064665.97751092]] * 24)
    Pointing_direction_R = numpy.array([["J2000", "0deg", "0deg"]] * 488)
    
    d = Delays(Antenna_Field_Reference_ITRF_R)
    d.set_measure_time(datetime.datetime.now())
    relative_antenna_positions = Antenna_Reference_ITRF_R - Antenna_Field_Reference_ITRF_R
    
    l = threading.Lock()
    
    def compute_delays():
        #l.acquire()
        d.set_measure_time(datetime.datetime.now())
        _ = d.delays_bulk(Pointing_direction_R, relative_antenna_positions)
        #l.release()
    
    def fun(n,nthreads):
        elapsed=timeit.timeit(compute_delays, number=n)
        print(f"{n} calls in {nthreads} threads cost {elapsed:.2f}s: each call needed {elapsed/n:.2f}s wall clock time")
    
    for nthreads in (1,2,3,4):
        threads = [threading.Thread(target=fun,args=(10,nthreads)) for x in range(nthreads)]
        [t.start() for t in threads]
        [t.join() for t in threads]
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment