HPC Today - Performance Portable Accelerator Programming in Fortran.
Listing 1: Python implementation of the OpenMP parallelization scheme.
class OpenMPFortranImplementation(FortranImplementation): def __init__(self): self.currDependantSymbols = None def declarationEnd(self, dependantSymbols, routineIsKernelCaller, currRoutineNode, currParallelRegionTemplate): self.currDependantSymbols = dependantSymbols return FortranImplementation.declarationEnd(self, dependantSymbols, routineIsKernelCaller, currRoutineNode, currParallelRegionTemplate) def parallelRegionBegin(self, parallelRegionTemplate): if self.currDependantSymbols == None: raise Exception( "parallel region without any dependant arrays") openMPLines = "!$OMP PARALLEL DO DEFAULT(Private) " openMPLines += "SHARED(%s)\n" % (', '.join([symbol.deviceName() for symbol in self.currDependantSymbols])) return openMPLines + FortranImplementation. parallelRegionBegin(self, parallelRegionTemplate) def parallelRegionEnd(self, parallelRegionTemplate): openMPLines = "\n!$OMP END PARALLEL DO\n" return FortranImplementation. parallelRegionEnd(self, parallelRegionTemplate) + openMPLines def subroutineEnd(self, dependantSymbols, routineIsKernelCaller): self.currDependantSymbols = None return FortranImplementation.subroutineEnd(self, dependantSymbols, routineIsKernelCaller)