1import config.package 2 3# Note thrust is a C++ header library. Users can still use --download-thrust, --with-thrust-dir etc. 4# But for --with-thrust-dir=mydir, the mydir should have a structure mydir/include/{thrust, cub}/... 5# For --with-thrust-include=myinc, the myinc should have a structure myinc/{thrust, cub}/... 6# For --download-thrust=mytarball.tgz, after unzip, its structure should be mytarball/{thrust, cub}/... 7class Configure(config.package.GNUPackage): 8 def __init__(self, framework): 9 config.package.GNUPackage.__init__(self, framework) 10 self.minversion = '1.9.8' 11 self.versionname = 'THRUST_VERSION' 12 self.versioninclude = 'thrust/version.h' 13 self.gitcommit = '1.17.2' 14 self.download = ['git://https://github.com/NVIDIA/thrust.git','https://github.com/NVIDIA/thrust/archive/'+self.gitcommit+'.tar.gz'] 15 self.includes = ['thrust/version.h'] 16 self.precisions = ['single','double'] 17 self.buildLanguages = ['Cxx'] 18 self.skipMPIDependency= 1 19 return 20 21 def versionToStandardForm(self,ver): 22 '''Converts from thrust 100908 notation to standard notation 1.9.8''' 23 return ".".join(map(str,[int(ver)//100000, int(ver)//100%1000, int(ver)%100])) 24 25 def updateGitDir(self): 26 import os 27 config.package.GNUPackage.updateGitDir(self) 28 if not hasattr(self.sourceControl, 'git') or (self.packageDir != os.path.join(self.externalPackagesDir,'git.'+self.package)): 29 return 30 try: 31 self.executeShellCommand([self.sourceControl.git, 'submodule', 'update', '--init'], cwd=self.packageDir, log=self.log) 32 except RuntimeError: 33 raise RuntimeError('Could not initialize cub submodule needed by thrust') 34 return 35 36 def Install(self): 37 ''''Install thrust and return its installation dir ''' 38 import os 39 with open(os.path.join(self.packageDir,'petsc.mk'),'w') as g: 40 g.write('#empty\n') 41 42 if not self.installNeeded('petsc.mk'): 43 return self.installDir 44 45 incDir = self.includeDir 46 srcThrustDir = os.path.join(self.packageDir,'thrust') 47 srcCubDir = os.path.join(self.packageDir,'cub') 48 49 cub_cuh = os.path.join(srcCubDir,'cub.cuh') 50 if not os.path.isfile(cub_cuh): 51 raise RuntimeError(cub_cuh+' does not exist. You might have forgot to download the cub submodule in thrust.') 52 53 # srcCubDir might be a symbol link 54 cpstr = ' mkdir -p '+incDir + ' && cp -RL '+srcThrustDir+' '+srcCubDir+' '+incDir 55 try: 56 self.logPrintBox('Copying THRUST; this may take several seconds') 57 output,err,ret = config.package.Package.executeShellCommand(cpstr,timeout=100,log=self.log) 58 except RuntimeError as e: 59 self.logPrint('Error executing "'+cpstr+'": '+str(e)) 60 raise RuntimeError('Error copying THRUST') 61 self.postInstall(output+err,'petsc.mk') 62 return self.installDir 63