ATLAS Offline Software
KernelExampleConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env athena.py
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 #
4 # "Standalone" test for exercising AthXRT with multiple kernels (krnl_VectorAdd and krnl_VectorMult).
5 #
6 
7 import os
8 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory import CompFactory
10 from AthenaCommon.Logging import logging
11 from AthXRTServices.DeviceMgmtSvcConfig import DeviceMgmtSvcCfg
12 log = logging.getLogger("AthExXRT.XrtKernelExampleCfg")
13 
15 
16  result = ComponentAccumulator()
17 
18  xclbin_list = [os.path.join(flags.FPGAMgmt.HLSDir, 'krnl_Combined.xclbin')]
19  result.merge(DeviceMgmtSvcCfg(flags,
20  xclbin_list))
21 
22  OCLVectorAddEx = CompFactory.AthExXRT.VectorAddOCLExampleAlg()
23  result.addEventAlgo(OCLVectorAddEx)
24 
25  OCLVectorMulEx = CompFactory.AthExXRT.VectorMultOCLExampleAlg()
26  result.addEventAlgo(OCLVectorMulEx)
27 
28  return result
29 
31 
32  result = ComponentAccumulator()
33 
34  xclbin_list = [os.path.join(flags.FPGAMgmt.HLSDir, 'krnl_Combined.xclbin')]
35  result.merge(DeviceMgmtSvcCfg(flags,
36  xclbin_list))
37 
38  XRTVectorAddEx = CompFactory.AthExXRT.VectorAddXRTExampleAlg()
39  result.addEventAlgo(XRTVectorAddEx)
40 
41  XRTVectorMulEx = CompFactory.AthExXRT.VectorMultXRTExampleAlg()
42  result.addEventAlgo(XRTVectorMulEx)
43 
44  return result
45 
47 
48  result = ComponentAccumulator()
49  result.merge(XrtKernelExampleCfg(flags))
50  result.merge(OCLKernelExampleCfg(flags))
51 
52  return result
53 
54 if __name__ == "__main__":
55  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
56  from AthenaConfiguration.AllConfigFlags import initConfigFlags
57  flags = initConfigFlags()
58  flags.Exec.MaxEvents = 10
59 
60  from AthXRTServices.FPGAConfigFlags import createFPGAMgmtFlags
62 
63  flags.addFlag("FPGAMgmt.doXRT", True)
64  flags.addFlag("FPGAMgmt.doOCL", True)
65  flags.fillFromArgs()
66  flags.lock()
67 
68  cfg = MainServicesCfg(flags)
69  if flags.FPGAMgmt.doXRT:
70  cfg.merge(XrtKernelExampleCfg(flags))
71  if flags.FPGAMgmt.doOCL:
72  cfg.merge(OCLKernelExampleCfg(flags))
73 
74  import sys
75  sys.exit(cfg.run().isFailure())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
KernelExampleConfig.XrtKernelExampleCfg
def XrtKernelExampleCfg(flags)
Definition: KernelExampleConfig.py:30
DeviceMgmtSvcConfig.DeviceMgmtSvcCfg
def DeviceMgmtSvcCfg(flags, xclbin_list)
Definition: DeviceMgmtSvcConfig.py:7
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
KernelExampleConfig.OCLKernelExampleCfg
def OCLKernelExampleCfg(flags)
Definition: KernelExampleConfig.py:14
KernelExampleConfig.MultiKernelExampleCfg
def MultiKernelExampleCfg(flags)
Definition: KernelExampleConfig.py:46
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
FPGAConfigFlags.createFPGAMgmtFlags
def createFPGAMgmtFlags()
Definition: FPGAConfigFlags.py:5