Пример #1
0
def hack_copy(srcDir, destDir):
    """ explicitly copy files not captured by IoRegistry"""
    #couple of sanity checks
    if srcDir == '': 
        srcDir = os.curdir
    if srcDir == destDir:
        from AthenaCommon.Logging import log as msg
        msg.warning("hack_copy called with srcDir = destDir = "+srcDir)
        return

    #A hack for RDO reconstruction after nextEvent(n)
    filepattern_list = [ 'DigitParams.db', 'SimParams.db',
                         '*.pmon.stream' ]

    import fnmatch
    import shutil
    import os
    for pattern in filepattern_list:
        for f in os.listdir(srcDir):
            if fnmatch.fnmatch(f, pattern):
                import os.path
                src_path = os.path.join(srcDir,f)
                dest_path = os.path.join(destDir,f)
                if not os.path.isfile(dest_path):
                    shutil.copyfile(src_path, dest_path)
Пример #2
0
 def root6_importhook(name,
                      globals={},
                      locals={},
                      fromlist=[],
                      level=-1):
     if name == 'PyCintex':
         import sys, traceback
         source, line, f, t = traceback.extract_stack(
             sys._getframe(1))[-1]
         log.warning(
             'PyCintex imported (replace with import cppyy) from: %s:%d'
             % (source, line))
     m = oldimporthook(name, globals, locals, fromlist, level)
     if m and (m.__name__ == 'ROOT' or name[0:4] == 'ROOT'):
         log.debug('Python import module=%s  fromlist=%s' %
                   (name, str(fromlist)))
         if fromlist:
             #MN: in this case 'm' is the final nested module already, don't walk the full 'name'
             vars = [
                 '.'.join(['', fl, autoload_var_name])
                 for fl in fromlist
             ]
         else:
             vars = ['.'.join([name, autoload_var_name])]
         for v in vars:
             try:
                 mm = m
                 #MN: walk the module chain and try to touch 'autoload_var_name' to trigger ROOT autoloading of namespaces
                 for comp in v.split('.')[1:]:
                     mm = getattr(mm, comp)
             except:
                 pass
     return m
def enable_seeking(silent=False):
    """ try to install seek-stuff on the EventSelector side.
   if `silent` is True, only an attempt at installing the seeking is performed.
   otherwise an exception is raised if the seeking could not be installed.
   """

    import sys
    from AthenaCommon.Logging import log as msg
    if not sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
        if silent:
            _msg = msg.debug
        else:
            _msg = msg.info
        # user did not import that module so we give up
        _msg("Cannot enable 'seeking' b/c module "
             "[AthenaPoolCnvSvc.ReadAthenaPool] hasn't been imported...")
        _msg( "Modify your jobOptions to import that module "+ \
              "(or just ignore this message)" )

        if not silent:
            raise RuntimeError("configuration-logic error")

        return

    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    from AthenaCommon.Configurable import Configurable
    collectionType = svcMgr.EventSelector.properties()["CollectionType"]

    if collectionType in (
            "ImplicitROOT",
            Configurable.propertyNoValue,
    ):
        svcMgr.EventSelector.CollectionType = "SeekableROOT"
        msg.info("=> Seeking enabled.")

    elif collectionType in ("SeekableROOT", ):
        msg.verbose("=> Seeking already enabled.")

    else:
        msg.warning(
            "Input seeking is not compatible with collection type of %s",
            svcMgr.EventSelector.properties()["CollectionType"])
        msg.warning("=> Seeking disabled.")
        if not silent:
            raise RuntimeError("could not install seeking")

    from AthenaCommon.AppMgr import theApp
    if theApp.state() != theApp.State.OFFLINE:
        # do not bring up the whole C++ kaboodle too early in the game
        svcMgr.EventSelector.setup()
    return
Пример #4
0
    def _do_action(self):
        import multiprocessing
        if (self.get_Value() == -1):
            self.set_Value(multiprocessing.cpu_count())
        elif (self.get_Value() < -1):
            from AthenaCommon.Logging import log
            log.fatal("nprocs cannot be < -1")
            import sys
            from AthenaCommon import ExitCodes
            sys.exit(ExitCodes.CONFIGURATION_ERROR)
        elif (self.get_Value() > multiprocessing.cpu_count()):
            from AthenaCommon.Logging import log
            log.warning("nprocs is larger than core count [%s]!",
                        multiprocessing.cpu_count())

        return
Пример #5
0
def enable_seeking(silent=False):
   """ try to install seek-stuff on the EventSelector side.
   if `silent` is True, only an attempt at installing the seeking is performed.
   otherwise an exception is raised if the seeking could not be installed.
   """

   import sys
   from AthenaCommon.Logging import log as msg
   if not sys.modules.has_key( 'AthenaPoolCnvSvc.ReadAthenaPool' ):
      if silent:
         _msg = msg.debug
      else:
         _msg = msg.info
      # user did not import that module so we give up
      _msg( "Cannot enable 'seeking' b/c module "
            "[AthenaPoolCnvSvc.ReadAthenaPool] hasn't been imported..." )
      _msg( "Modify your jobOptions to import that module "+ \
            "(or just ignore this message)" )

      if not silent:
         raise RuntimeError("configuration-logic error")
      
      return

   from AthenaCommon.AppMgr import ServiceMgr as svcMgr
   from AthenaCommon.Configurable import Configurable
   collectionType = svcMgr.EventSelector.properties()["CollectionType"]

   if collectionType in ( "ImplicitROOT", Configurable.propertyNoValue, ):
      svcMgr.EventSelector.CollectionType = "SeekableROOT"
      msg.info   ( "=> Seeking enabled." )

   elif collectionType in ( "SeekableROOT", ):
      msg.verbose( "=> Seeking already enabled." )

   else:
      msg.warning( "Input seeking is not compatible with collection type of %s",
                   svcMgr.EventSelector.properties()["CollectionType"] )
      msg.warning( "=> Seeking disabled." )
      if not silent:
         raise RuntimeError("could not install seeking")
      
   from AthenaCommon.AppMgr import theApp
   if theApp.state() != theApp.State.OFFLINE:
      # do not bring up the whole C++ kaboodle too early in the game
      svcMgr.EventSelector.setup()
   return
Пример #6
0
def setupEvtSelForSeekOps():
    """ try to install seek-stuff on the EventSelector side """
    #import sys
    #from AthenaCommon.Logging import log as msg
    msg.debug("setupEvtSelForSeekOps:")
    if sys.modules.has_key('AthenaRootComps.ReadAthenaRoot'):
        # athenarootcomps has seeking enabled by default
        msg.info('=> Seeking enabled.')
        return

    if not sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
        ## user did not import that module so we give up
        msg.info( "Cannot enable 'seeking' b/c module " + \
                   "[AthenaPoolCnvSvc.ReadAthenaPool] hasn't been imported..." )
        msg.info( "Modify your jobOptions to import that module "+ \
                   "(or just ignore this message)" )
        return

    from AthenaCommon.AppMgr import theApp, AthAppMgr
    if theApp.state() != AthAppMgr.State.OFFLINE:
        msg.info( "C++ ApplicationMgr already instantiated, probably seeking "+\
                  "will be ill-configured..." )
        msg.info("EventSelector writers should implement updateHandlers")

    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    from AthenaCommon.Configurable import Configurable
    collectionType = svcMgr.EventSelector.properties()["CollectionType"]

    if collectionType in (
            "ImplicitROOT",
            Configurable.propertyNoValue,
    ):
        svcMgr.EventSelector.CollectionType = "SeekableROOT"
        msg.info("=> Seeking enabled.")

    elif collectionType in ("SeekableROOT", ):
        msg.verbose("=> Seeking already enabled.")

    else:
        msg.warning(
            "Input seeking is not compatible with collection type of %s",
            svcMgr.EventSelector.properties()["CollectionType"])
        msg.warning("=> Seeking disabled.")
    return
Пример #7
0
def reopen_fds(wkdir=""):
    """redirect workers fds by setting proper flags
       <INPUT> ->  duplicate fd in RDONLY mode
       <OUTPUT> -> redirect fd to local output-copy w/ duplicate flags.
    """
    _info("reopen_fds: in dir [%s]" % wkdir)
    import os, fcntl
    #from IoRegistry import IoRegistry as ioreg
    _join = os.path.join

    _fds = IoRegistry.fds_dict
    _fds.create_symlinks(wkdir)

    for k, v in _fds.iteritems():
        fd = k
        (real_name, iomode, flags) = v
        if not os.path.isfile(real_name):
            _debug("reopen_fds: %s is not file" % real_name)
            continue

        if (iomode == '<OUTPUT>'):
            #expect the copy of <OUTPUT> to be in curdir
            _debug("reopen_fds: <OUTPUT> %s " % real_name)
            pos = os.lseek(fd, 0, os.SEEK_CUR)
            #PC HACK remove!
            try:
                new_fd = os.open(_join(wkdir, os.path.basename(real_name)),
                                 flags)
                os.lseek(new_fd, pos, os.SEEK_SET)
            except Exception, err:
                msg.warning("Exception caught handling OUTPUT file %s: %s" %
                            (real_name, err))
                msg.warning(" ...ignoring file FIXME!")
                continue
        else:
            _debug("reopen_fds:<INPUT> %s" % real_name)
            new_fd = os.open(real_name, os.O_RDONLY)

        os.close(fd)
        os.dup2(new_fd, fd)
        fcntl.fcntl(fd, fcntl.F_SETFL, flags)
        os.close(new_fd)
Пример #8
0
def ActsTrackingGeometrySvcCfg(configFlags, name="ActsTrackingGeometrySvc"):
    result = ComponentAccumulator()

    Acts_ActsTrackingGeometrySvc = CompFactory.ActsTrackingGeometrySvc
    subDetectors = []
    if configFlags.Detector.GeometryPixel:
        subDetectors += ["Pixel"]
    if configFlags.Detector.GeometrySCT:
        subDetectors += ["SCT"]
    if configFlags.Detector.GeometryTRT:
        subDetectors += ["TRT"]
    if configFlags.Detector.GeometryCalo:
        subDetectors += ["Calo"]

        # need to configure calo geometry, otherwise we get a crash
        from LArGeoAlgsNV.LArGMConfig import LArGMCfg
        result.merge(LArGMCfg(configFlags))
        from TileGeoModel.TileGMConfig import TileGMCfg
        result.merge(TileGMCfg(configFlags))

    idSub = [sd in subDetectors for sd in ("Pixel", "SCT", "TRT")]
    if any(idSub):
        # ANY of the ID subdetectors are on => we require GM sources
        # In principle we could require only what is enabled, but the group
        # does extra config that I don't want to duplicate here
        from AtlasGeoModel.InDetGMConfig import InDetGeometryCfg
        result.merge(InDetGeometryCfg(configFlags))

        if not all(idSub):
            from AthenaCommon.Logging import log
            log.warning(
                "ConfigFlags indicate %s should be built. Not all ID subdetectors are set, but I'll set all of them up to capture the extra setup happening here.",
                ", ".join(subDetectors))

    actsTrackingGeometrySvc = Acts_ActsTrackingGeometrySvc(
        name, BuildSubDetectors=subDetectors)

    from AthenaCommon.Constants import VERBOSE
    actsTrackingGeometrySvc.OutputLevel = VERBOSE
    result.addService(actsTrackingGeometrySvc)
    return result
Пример #9
0
def reopen_fds(wkdir=""):
    """redirect workers fds by setting proper flags
       <INPUT> ->  duplicate fd in RDONLY mode
       <OUTPUT> -> redirect fd to local output-copy w/ duplicate flags.
    """
    _info("reopen_fds: in dir [%s]" % wkdir)
    import os, fcntl
    #from IoRegistry import IoRegistry as ioreg
    _join = os.path.join
    
    _fds = IoRegistry.fds_dict
    _fds.create_symlinks(wkdir)

    for k, v in _fds.iteritems():
        fd = k; 
        (real_name, iomode, flags) = v
        if not os.path.isfile (real_name):
            _debug("reopen_fds: %s is not file" % real_name)
            continue
        
        if (iomode == '<OUTPUT>'):
            #expect the copy of <OUTPUT> to be in curdir
            _debug("reopen_fds: <OUTPUT> %s " % real_name)
            pos = os.lseek(fd, 0, os.SEEK_CUR)
            #PC HACK remove!
            try:
                new_fd = os.open (_join(wkdir, os.path.basename(real_name)), flags)
                os.lseek(new_fd, pos, os.SEEK_SET)
            except Exception, err:         
                msg.warning("Exception caught handling OUTPUT file %s: %s" %  (real_name, err) )
                msg.warning(" ...ignoring file FIXME!")
                continue
        else:
            _debug("reopen_fds:<INPUT> %s" % real_name)
            new_fd = os.open (real_name, os.O_RDONLY)
        
        os.close (fd)
        os.dup2  (new_fd, fd)
        fcntl.fcntl (fd, fcntl.F_SETFL, flags)
        os.close (new_fd)
Пример #10
0
def setupEvtSelForSeekOps():
   """ try to install seek-stuff on the EventSelector side """
   #import sys
   #from AthenaCommon.Logging import log as msg
   msg.debug("setupEvtSelForSeekOps:")
   if sys.modules.has_key('AthenaRootComps.ReadAthenaRoot'):
       # athenarootcomps has seeking enabled by default
       msg.info('=> Seeking enabled.')
       return
   
   if not sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
      ## user did not import that module so we give up
      msg.info( "Cannot enable 'seeking' b/c module " + \
                 "[AthenaPoolCnvSvc.ReadAthenaPool] hasn't been imported..." )
      msg.info( "Modify your jobOptions to import that module "+ \
                 "(or just ignore this message)" )
      return

   from AthenaCommon.AppMgr import theApp, AthAppMgr
   if theApp.state() != AthAppMgr.State.OFFLINE:
      msg.info( "C++ ApplicationMgr already instantiated, probably seeking "+\
                "will be ill-configured..." )
      msg.info( "EventSelector writers should implement updateHandlers" )
   
   from AthenaCommon.AppMgr import ServiceMgr as svcMgr
   from AthenaCommon.Configurable import Configurable
   collectionType = svcMgr.EventSelector.properties()["CollectionType"]

   if collectionType in ( "ImplicitROOT", Configurable.propertyNoValue, ):
      svcMgr.EventSelector.CollectionType = "SeekableROOT"
      msg.info   ( "=> Seeking enabled." )

   elif collectionType in ( "SeekableROOT", ):
      msg.verbose( "=> Seeking already enabled." )

   else:
      msg.warning( "Input seeking is not compatible with collection type of %s",
                   svcMgr.EventSelector.properties()["CollectionType"] )
      msg.warning( "=> Seeking disabled." )
   return
Пример #11
0
def hack_copy(srcDir, destDir):
    """ explicitly copy files not captured by IoRegistry"""
    #couple of sanity checks
    if srcDir == '': 
        srcDir = os.curdir
    if srcDir == destDir:
        msg.warning("hack_copy called with srcDir = destDir = "+srcDir)
        return

    #A hack for RDO reconstruction after nextEvent(n)
    filepattern_list = [ 'DigitParams.db', 'SimParams.db',
                         '*.pmon.stream' ]

    import fnmatch
    import shutil
    import os
    for pattern in filepattern_list:
        for f in os.listdir(srcDir):
            if fnmatch.fnmatch(f, pattern):
                import os.path
                src_path = os.path.join(srcDir,f)
                dest_path = os.path.join(destDir,f)
                if not os.path.isfile(dest_path):
                    shutil.copyfile(src_path, dest_path)
Пример #12
0
    def configureStrategy(self, strategy, pileup, events_before_fork):
        from AthenaMPFlags import jobproperties as jp
        from AthenaCommon.ConcurrencyFlags import jobproperties as jp
        event_range_channel = jp.AthenaMPFlags.EventRangeChannel()
        chunk_size = jp.AthenaMPFlags.ChunkSize()
        debug_worker = jp.ConcurrencyFlags.DebugWorkers()

        if strategy == 'SharedQueue' or strategy == 'RoundRobin':
            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [
                SharedEvtQueueProvider(IsPileup=pileup,
                                       EventsBeforeFork=events_before_fork,
                                       ChunkSize=chunk_size)
            ]

            if (self.nThreads >= 1):
                from AthenaMPTools.AthenaMPToolsConf import SharedHiveEvtQueueConsumer
                self.Tools += [
                    SharedHiveEvtQueueConsumer(
                        UseSharedReader=False,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        Debug=debug_worker)
                ]
            else:
                from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
                self.Tools += [
                    SharedEvtQueueConsumer(
                        UseSharedReader=False,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        ReadEventOrders=jp.AthenaMPFlags.ReadEventOrders(),
                        EventOrdersFile=jp.AthenaMPFlags.EventOrdersFile(),
                        Debug=debug_worker)
                ]

            # Enable seeking
            setupEvtSelForSeekOps()

        elif strategy == 'FileScheduling':
            from AthenaMPTools.AthenaMPToolsConf import FileSchedulingTool
            self.Tools += [
                FileSchedulingTool(IsPileup=pileup, Debug=debug_worker)
            ]

        elif strategy == 'SharedReader':
            from AthenaCommon.AppMgr import ServiceMgr as svcMgr

            from AthenaServices.AthenaServicesConf import AthenaSharedMemoryTool
            shm_name = "EvtSelSM_" + str(os.getpid())
            svcMgr.EventSelector.SharedMemoryTool = AthenaSharedMemoryTool(
                "EventStreamingTool")
            if sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
                svcMgr.AthenaPoolCnvSvc.DataStreamingTool = AthenaSharedMemoryTool(
                    "DataStreamingTool")

            from AthenaMPTools.AthenaMPToolsConf import SharedReaderTool
            self.Tools += [SharedReaderTool()]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [
                SharedEvtQueueProvider(IsPileup=pileup, EventsBeforeFork=0)
            ]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
            self.Tools += [
                SharedEvtQueueConsumer(UseSharedReader=True,
                                       IsPileup=pileup,
                                       EventsBeforeFork=0)
            ]

        elif strategy == 'EventService':
            channelScatterer2Processor = "AthenaMP_Scatterer2Processor"
            channelProcessor2EvtSel = "AthenaMP_Processor2EvtSel"
            use_token_extractor = jp.AthenaMPFlags.UseTokenExtractor()

            if use_token_extractor:
                from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                from AthenaServices.AthenaServicesConf import AthenaYamplTool
                svcMgr.EventSelector.SharedMemoryTool = AthenaYamplTool(
                    "AthenaYamplTool",
                    ChannelName=channelProcessor2EvtSel,
                    Many2One=False)

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeScatterer
            self.Tools += [
                EvtRangeScatterer(
                    ProcessorChannel=channelScatterer2Processor,
                    EventRangeChannel=event_range_channel,
                    UseTokenExtractor=use_token_extractor,
                    TokenExtractorChannel=jp.AthenaMPFlags.
                    TokenExtractorChannel(),
                    DoCaching=jp.AthenaMPFlags.EvtRangeScattererCaching())
            ]

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeProcessor
            self.Tools += [
                EvtRangeProcessor(IsPileup=pileup,
                                  Channel2Scatterer=channelScatterer2Processor,
                                  Channel2EvtSel=channelProcessor2EvtSel,
                                  UseTokenExtractor=use_token_extractor,
                                  Debug=debug_worker)
            ]
            # Enable seeking
            setupEvtSelForSeekOps()

        else:
            msg.warning("Unknown strategy. No MP tools will be configured")
Пример #13
0
    def configureStrategy(self, strategy, pileup, events_before_fork):
        from AthenaMPFlags import jobproperties as jp
        from AthenaCommon.ConcurrencyFlags import jobproperties as jp
        event_range_channel = jp.AthenaMPFlags.EventRangeChannel()
        chunk_size = jp.AthenaMPFlags.ChunkSize()
        debug_worker = jp.ConcurrencyFlags.DebugWorkers()
        use_shared_reader = jp.AthenaMPFlags.UseSharedReader()
        use_shared_writer = jp.AthenaMPFlags.UseSharedWriter()

        if strategy == 'SharedQueue' or strategy == 'RoundRobin':
            if use_shared_reader:
                from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                from AthenaServices.AthenaServicesConf import AthenaSharedMemoryTool
                svcMgr.EventSelector.SharedMemoryTool = AthenaSharedMemoryTool(
                    "EventStreamingTool")
                if sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
                    svcMgr.AthenaPoolCnvSvc.InputStreamingTool = AthenaSharedMemoryTool(
                        "InputStreamingTool")
            if use_shared_writer:
                if sys.modules.has_key('AthenaPoolCnvSvc.WriteAthenaPool'):
                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                    from AthenaServices.AthenaServicesConf import AthenaSharedMemoryTool
                    svcMgr.AthenaPoolCnvSvc.OutputStreamingTool = [
                        AthenaSharedMemoryTool("OutputStreamingTool_0")
                    ]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [
                SharedEvtQueueProvider(UseSharedReader=use_shared_reader,
                                       IsPileup=pileup,
                                       EventsBeforeFork=events_before_fork,
                                       ChunkSize=chunk_size)
            ]

            if (self.nThreads >= 1):
                from AthenaMPTools.AthenaMPToolsConf import SharedHiveEvtQueueConsumer
                self.Tools += [
                    SharedHiveEvtQueueConsumer(
                        UseSharedReader=use_shared_reader,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        Debug=debug_worker)
                ]
            else:
                from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
                self.Tools += [
                    SharedEvtQueueConsumer(
                        UseSharedReader=use_shared_reader,
                        UseSharedWriter=use_shared_writer,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        ReadEventOrders=jp.AthenaMPFlags.ReadEventOrders(),
                        EventOrdersFile=jp.AthenaMPFlags.EventOrdersFile(),
                        Debug=debug_worker)
                ]
            if use_shared_writer:
                from AthenaMPTools.AthenaMPToolsConf import SharedWriterTool
                self.Tools += [SharedWriterTool()]

            # Enable seeking
            if not use_shared_reader:
                setupEvtSelForSeekOps()

        elif strategy == 'FileScheduling':
            from AthenaMPTools.AthenaMPToolsConf import FileSchedulingTool
            self.Tools += [
                FileSchedulingTool(IsPileup=pileup, Debug=debug_worker)
            ]

        elif strategy == 'EventService':
            channelScatterer2Processor = "AthenaMP_Scatterer2Processor"
            channelProcessor2EvtSel = "AthenaMP_Processor2EvtSel"

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeScatterer
            self.Tools += [
                EvtRangeScatterer(
                    ProcessorChannel=channelScatterer2Processor,
                    EventRangeChannel=event_range_channel,
                    DoCaching=jp.AthenaMPFlags.EvtRangeScattererCaching())
            ]

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeProcessor
            self.Tools += [
                EvtRangeProcessor(IsPileup=pileup,
                                  Channel2Scatterer=channelScatterer2Processor,
                                  Channel2EvtSel=channelProcessor2EvtSel,
                                  Debug=debug_worker)
            ]
            # Enable seeking
            setupEvtSelForSeekOps()

        else:
            msg.warning("Unknown strategy. No MP tools will be configured")
Пример #14
0
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration

from .AthAnalysisToolsConf import *

from AthenaCommon.Logging import log as _msg
_msg.warning('    AnalysisTools.AnalysisToolsConf is DEPRECATED !')
_msg.warning('use AnalysisTools.AthAnalysisToolsConf instead')
Пример #15
0
    def configureStrategy(self,strategy,pileup,events_before_fork):
        from AthenaMPFlags import jobproperties as jp
        from AthenaCommon.ConcurrencyFlags import jobproperties as jp
        event_range_channel = jp.AthenaMPFlags.EventRangeChannel()
        chunk_size = jp.AthenaMPFlags.ChunkSize()
        debug_worker = jp.ConcurrencyFlags.DebugWorkers()

        if strategy=='SharedQueue' or strategy=='RoundRobin':
            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [ SharedEvtQueueProvider(IsPileup=pileup,
                                                   EventsBeforeFork=events_before_fork,
                                                   ChunkSize=chunk_size) ]

            if (self.nThreads >= 1):
                from AthenaMPTools.AthenaMPToolsConf import SharedHiveEvtQueueConsumer
                self.Tools += [ SharedHiveEvtQueueConsumer(UseSharedReader=False,
                                                           IsPileup=pileup,
                                                           IsRoundRobin=(strategy=='RoundRobin'),
                                                           EventsBeforeFork=events_before_fork,
                                                           Debug=debug_worker)   ]
            else:
                from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
                self.Tools += [ SharedEvtQueueConsumer(UseSharedReader=False,
                                                       IsPileup=pileup,
                                                       IsRoundRobin=(strategy=='RoundRobin'),
                                                       EventsBeforeFork=events_before_fork,
                                                       ReadEventOrders=jp.AthenaMPFlags.ReadEventOrders(),
                                                       EventOrdersFile=jp.AthenaMPFlags.EventOrdersFile(),
                                                       Debug=debug_worker)   ]

            # Enable seeking
            setupEvtSelForSeekOps()

        elif strategy=='FileScheduling':
            from AthenaMPTools.AthenaMPToolsConf import FileSchedulingTool
            self.Tools += [ FileSchedulingTool(IsPileup=pileup,
                                               Debug=debug_worker) ]

        elif strategy=='SharedReader':
            from AthenaCommon.AppMgr import ServiceMgr as svcMgr

            from AthenaServices.AthenaServicesConf import AthenaSharedMemoryTool
            shm_name = "EvtSelSM_" + str(os.getpid())
            svcMgr.EventSelector.SharedMemoryTool = AthenaSharedMemoryTool("EventStreamingTool")
            if sys.modules.has_key('AthenaPoolCnvSvc.ReadAthenaPool'):
                svcMgr.AthenaPoolCnvSvc.DataStreamingTool = AthenaSharedMemoryTool("DataStreamingTool")

            from AthenaMPTools.AthenaMPToolsConf import SharedReaderTool
            self.Tools += [ SharedReaderTool() ]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [ SharedEvtQueueProvider(IsPileup=pileup,
                                                   EventsBeforeFork=0) ]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
            self.Tools += [ SharedEvtQueueConsumer(UseSharedReader=True,
                                                   IsPileup=pileup,
                                                   EventsBeforeFork=0) ]

        elif strategy=='EventService':
            channelScatterer2Processor = "AthenaMP_Scatterer2Processor"
            channelProcessor2EvtSel = "AthenaMP_Processor2EvtSel"
            use_token_extractor = jp.AthenaMPFlags.UseTokenExtractor()

            if use_token_extractor:
                from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                from AthenaServices.AthenaServicesConf import AthenaYamplTool
                svcMgr.EventSelector.SharedMemoryTool = AthenaYamplTool("AthenaYamplTool",
                                                                        ChannelName = channelProcessor2EvtSel,
                                                                        Many2One=False)

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeScatterer
            self.Tools += [ EvtRangeScatterer(ProcessorChannel = channelScatterer2Processor,
                                              EventRangeChannel = event_range_channel,
                                              UseTokenExtractor = use_token_extractor,
                                              TokenExtractorChannel = jp.AthenaMPFlags.TokenExtractorChannel(),
                                              DoCaching=jp.AthenaMPFlags.EvtRangeScattererCaching()) ]

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeProcessor
            self.Tools += [ EvtRangeProcessor(IsPileup=pileup,
                                              Channel2Scatterer = channelScatterer2Processor,
                                              Channel2EvtSel = channelProcessor2EvtSel,
                                              UseTokenExtractor = use_token_extractor,
                                              Debug=debug_worker) ]
            # Enable seeking
            setupEvtSelForSeekOps()

        else:
            msg.warning("Unknown strategy. No MP tools will be configured")
Пример #16
0
    def configureStrategy(self, strategy, pileup, events_before_fork):
        from .AthenaMPFlags import jobproperties as jp
        from AthenaCommon.ConcurrencyFlags import jobproperties as jp
        event_range_channel = jp.AthenaMPFlags.EventRangeChannel()
        if (jp.AthenaMPFlags.ChunkSize() > 0):
            chunk_size = jp.AthenaMPFlags.ChunkSize()
            msg.info('Chunk size set to %i', chunk_size)
        #Use auto flush only if file is compressed with LZMA, else use default chunk_size
        elif (jp.AthenaMPFlags.ChunkSize() == -1):
            from PyUtils.MetaReaderPeeker import metadata
            if (metadata['file_comp_alg'] == 2):
                chunk_size = metadata['auto_flush']
                msg.info('Chunk size set to auto flush (%i)', chunk_size)
            else:
                chunk_size = jp.AthenaMPFlags.ChunkSize.__class__.StoredValue
                msg.info(
                    'LZMA algorithm not in use, chunk_size set to default (%i)',
                    chunk_size)
        #Use auto flush only if file is compressed with LZMA or ZLIB, else use default chunk_size
        elif (jp.AthenaMPFlags.ChunkSize() == -2):
            from PyUtils.MetaReaderPeeker import metadata
            if (metadata['file_comp_alg'] == 1
                    or metadata['file_comp_alg'] == 2):
                chunk_size = metadata['auto_flush']
                msg.info('Chunk size set to auto flush (%i)', chunk_size)
            else:
                chunk_size = jp.AthenaMPFlags.ChunkSize.__class__.StoredValue
                msg.info(
                    'LZMA nor ZLIB in use, chunk_size set to default (%i)',
                    chunk_size)
        #Use auto flush only if file is compressed with LZMA, ZLIB or LZ4, else use default chunk_size
        elif (jp.AthenaMPFlags.ChunkSize() == -3):
            from PyUtils.MetaReaderPeeker import metadata
            if (metadata['file_comp_alg'] == 1
                    or metadata['file_comp_alg'] == 2
                    or metadata['file_comp_alg'] == 4):
                chunk_size = metadata['auto_flush']
                msg.info('Chunk size set to auto flush (%i)', chunk_size)
            else:
                chunk_size = jp.AthenaMPFlags.ChunkSize.__class__.StoredValue
                msg.info(
                    'LZMA, ZLIB nor LZ4 in use, chunk_size set to default (%i)',
                    chunk_size)
        #Use auto flush value for chunk_size, regarldess of compression algorithm
        elif (jp.AthenaMPFlags.ChunkSize() <= -4):
            from PyUtils.MetaReaderPeeker import metadata
            chunk_size = metadata['auto_flush']
            msg.info('Chunk size set to auto flush (%i)', chunk_size)
        else:
            chunk_size = jp.AthenaMPFlags.ChunkSize.__class__.StoredValue
            msg.warning('Invalid ChunkSize, Chunk Size set to default (%i)',
                        chunk_size)
        debug_worker = jp.ConcurrencyFlags.DebugWorkers()
        use_shared_reader = jp.AthenaMPFlags.UseSharedReader()
        use_shared_writer = jp.AthenaMPFlags.UseSharedWriter()

        if strategy == 'SharedQueue' or strategy == 'RoundRobin':
            if use_shared_reader:
                from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                from AthenaIPCTools.AthenaIPCToolsConf import AthenaSharedMemoryTool
                svcMgr.EventSelector.SharedMemoryTool = AthenaSharedMemoryTool(
                    "EventStreamingTool",
                    SharedMemoryName="EventStream" + str(os.getpid()))
                if 'AthenaPoolCnvSvc.ReadAthenaPool' in sys.modules:
                    svcMgr.AthenaPoolCnvSvc.InputStreamingTool = AthenaSharedMemoryTool(
                        "InputStreamingTool",
                        SharedMemoryName="InputStream" + str(os.getpid()))
            if use_shared_writer:
                if 'AthenaPoolCnvSvc.WriteAthenaPool' in sys.modules:
                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                    from AthenaIPCTools.AthenaIPCToolsConf import AthenaSharedMemoryTool
                    svcMgr.AthenaPoolCnvSvc.OutputStreamingTool += [
                        AthenaSharedMemoryTool(
                            "OutputStreamingTool_0",
                            SharedMemoryName="OutputStream" + str(os.getpid()))
                    ]

            from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueProvider
            self.Tools += [
                SharedEvtQueueProvider(UseSharedReader=use_shared_reader,
                                       IsPileup=pileup,
                                       EventsBeforeFork=events_before_fork,
                                       ChunkSize=chunk_size)
            ]

            if (self.nThreads >= 1):
                from AthenaMPTools.AthenaMPToolsConf import SharedHiveEvtQueueConsumer
                self.Tools += [
                    SharedHiveEvtQueueConsumer(
                        UseSharedReader=use_shared_reader,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        Debug=debug_worker)
                ]
            else:
                from AthenaMPTools.AthenaMPToolsConf import SharedEvtQueueConsumer
                self.Tools += [
                    SharedEvtQueueConsumer(
                        UseSharedReader=use_shared_reader,
                        UseSharedWriter=use_shared_writer,
                        IsPileup=pileup,
                        IsRoundRobin=(strategy == 'RoundRobin'),
                        EventsBeforeFork=events_before_fork,
                        ReadEventOrders=jp.AthenaMPFlags.ReadEventOrders(),
                        EventOrdersFile=jp.AthenaMPFlags.EventOrdersFile(),
                        Debug=debug_worker)
                ]
            if use_shared_writer:
                from AthenaMPTools.AthenaMPToolsConf import SharedWriterTool
                self.Tools += [SharedWriterTool()]

            # Enable seeking
            if not use_shared_reader:
                setupEvtSelForSeekOps()

        elif strategy == 'FileScheduling':
            from AthenaMPTools.AthenaMPToolsConf import FileSchedulingTool
            self.Tools += [
                FileSchedulingTool(IsPileup=pileup, Debug=debug_worker)
            ]

        elif strategy == 'EventService':
            channelScatterer2Processor = "AthenaMP_Scatterer2Processor"
            channelProcessor2EvtSel = "AthenaMP_Processor2EvtSel"

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeScatterer
            self.Tools += [
                EvtRangeScatterer(
                    ProcessorChannel=channelScatterer2Processor,
                    EventRangeChannel=event_range_channel,
                    DoCaching=jp.AthenaMPFlags.EvtRangeScattererCaching())
            ]

            from AthenaMPTools.AthenaMPToolsConf import EvtRangeProcessor
            self.Tools += [
                EvtRangeProcessor(IsPileup=pileup,
                                  Channel2Scatterer=channelScatterer2Processor,
                                  Channel2EvtSel=channelProcessor2EvtSel,
                                  Debug=debug_worker)
            ]
            # Enable seeking
            setupEvtSelForSeekOps()

        else:
            msg.warning("Unknown strategy. No MP tools will be configured")
Пример #17
0
    from AthenaCommon.AlgScheduler import AlgScheduler
    AlgScheduler.OutputLevel( INFO )
    AlgScheduler.ShowControlFlow( True )
    AlgScheduler.ShowDataDependencies( True )
    AlgScheduler.setDataLoaderAlg( 'SGInputLoader' )
    
    # Support for the MT-MP hybrid mode
    if (nProc > 0) :
        
        from AthenaCommon.Logging import log as msg
        if (theApp.EvtMax == -1) : 
            msg.fatal('EvtMax must be >0 for hybrid configuration')
            sys.exit(AthenaCommon.ExitCodes.CONFIGURATION_ERROR)

            if ( theApp.EvtMax % nProc != 0 ) :
                msg.warning('EvtMax[%s] is not divisible by nProcs[%s]: MP Workers will not process all requested events',theApp.EvtMax,nProc)

            chunkSize = int (theApp.EvtMax / nProc)

            from AthenaMP.AthenaMPFlags import jobproperties as jps 
            jps.AthenaMPFlags.ChunkSize= chunkSize
         
            msg.info('AthenaMP workers will process %s events each',chunkSize)
  
# MT-specific code
#---------------------------------------------------------------------------------#

theApp.EvtMax = 5

from xAODEventInfoCnv.xAODEventInfoCreator import xAODMaker__EventInfoCnvAlg
topSequence+=xAODMaker__EventInfoCnvAlg()
Пример #18
0
    if args.dqOffByDefault:
        from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
        allSteeringFlagsOff()
    ConfigFlags.fillFromArgs(parser=parser)
    # override Input.Files with result from our own arguments
    # if --filesInput was specified as well (!) this will override
    if args.inputFiles is not None:
        ConfigFlags.Input.Files = args.inputFiles.split(',')
    # if --evtMax was specified as well this will override
    if args.maxEvents is not None:
        ConfigFlags.Exec.MaxEvents = args.maxEvents
    isReadingRaw = (GetFileMD(ConfigFlags.Input.Files).get(
        'file_type', 'POOL') == 'BS')
    if isReadingRaw:
        if ConfigFlags.DQ.Environment not in ('tier0', 'tier0Raw', 'online'):
            log.warning('Reading RAW file, but DQ.Environment set to %s',
                        ConfigFlags.DQ.Environment)
            log.warning('Will proceed but best guess is this is an error')
        log.info('Will schedule reconstruction, as best we know')
    else:
        if ConfigFlags.DQ.Environment in ('tier0', 'tier0Raw', 'online'):
            log.warning('Reading POOL file, but DQ.Environment set to %s',
                        ConfigFlags.DQ.Environment)
            log.warning('Will proceed but best guess is this is an error')

    if args.preExec:
        # bring things into scope
        from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
        log.info('Executing preExec: %s', args.preExec)
        exec(args.preExec)

    if hasattr(ConfigFlags, "DQ") and hasattr(