Skip to content

Global timer for new GPAW

Ask Hjorth Larsen requested to merge new-gpaw-global-timer into master
  • add gpaw.new.timer module with a global_timer attribute. The plane is that this timer can be modified using context managers, but right now that is only rudimentarily implemented.
  • The global timer wraps an old-style timer, so existing timer classes can be used
  • Code imports the @trace decorator to call the timer. Such decorators have been added in order to trace the most important calls in new GPAW.

Usage example:

from ase.build import bulk
from gpaw.new.ase_interface import GPAW
from gpaw.new.timer import global_timer
from gpaw.utilities.timing import Timer, Profiler


# Timer for perfetto.io visualisation:
mytimer = Profiler('myprofiler')

# mytimer = Timer()  # alternative


with global_timer.context(mytimer):
    atoms = bulk('Si') * (1, 1, 1)
    atoms.calc = GPAW(
        mode={'name': 'pw', 'ecut': 600.0},
        kpts=[1, 1, 17],
        parallel=dict(kpt=4),
        txt='gpaw.txt')

    atoms.get_potential_energy()
    atoms.get_forces()
    atoms.get_stress()

print(global_timer.tostring())

Merge request reports