Commits

Karl Rupp committed 3973d8d

SNES ex52: Added option to switch between OpenCL and CUDA backends.

Comments (0)

Files changed (1)

src/benchmarks/benchmarkExample.py

     '''Return the path to the executable for a given example number'''
     return os.path.join(self.dir(), self.arch(), 'lib', 'ex'+str(num)+'-obj', 'ex'+str(num))
 
-  def source(self, library, num):
+  def source(self, library, num, filenametail):
     '''Return the path to the sources for a given example number'''
     d = os.path.join(self.dir(), 'src', library.lower(), 'examples', 'tutorials')
     name = 'ex'+str(num)
     for f in os.listdir(d):
       if f == name+'.c':
         sources.insert(0, f)
-      elif f.startswith(name) and f.endswith('.cu'):
+      elif f.startswith(name) and f.endswith(filenametail):
         sources.append(f)
     return map(lambda f: os.path.join(d, f), sources)
 
   parser.add_argument('--events',  nargs='+',                          help='Events to process')
   parser.add_argument('--batch',   action='store_true', default=False, help='Generate batch files for the runs instead')
   parser.add_argument('--daemon',  action='store_true', default=False, help='Run as a daemon')
+  parser.add_argument('--gpulang', default='OpenCL',                   help='GPU Language to use: Either CUDA or OpenCL (default)')
   subparsers = parser.add_subparsers(help='DM types')
 
   parser_dmda = subparsers.add_parser('DMDA', help='Use a DMDA for the problem geometry')
     args.dmType = 'DMComplex'
 
   ex     = PETScExample(args.library, args.num, log_summary='summary.dat', log_summary_python = None if args.batch else args.module+'.py', preload='off')
-  source = ex.petsc.source(args.library, args.num)
+  if args.gpulang == 'CUDA':
+    source = ex.petsc.source(args.library, args.num, '.cu')
+  else:
+    source = ex.petsc.source(args.library, args.num, 'OpenCL.c')  # Using the convention of OpenCL code residing in source files ending in 'OpenCL.c' (at least for snes/ex52)
   sizes  = {}
   times  = {}
   events = {}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.