original_docstring:  pass some parameters through environment variables 
docstring: pass some parameters through environment variables
docstring_tokens: pass some parameters through environment variables
code: def objectives(point):                  # should always use this name for user-defined objective function
      
  	matrix = point['matrix']
  	COLPERM = point['COLPERM']
  	LOOKAHEAD = point['LOOKAHEAD']
  	nprows = point['nprows']
  	nproc = point['nproc']
  	NSUP = point['NSUP']
  	NREL = point['NREL']
  	npernode =  math.ceil(float(nproc)/nodes)  
  	nthreads = int(cores / npernode)
  	npcols     = int(nproc / nprows)
  	params = [matrix, 'COLPERM', COLPERM, 'LOOKAHEAD', LOOKAHEAD, 'nthreads', nthreads, 'npernode', npernode, 'nprows', nprows, 'npcols', npcols, 'NSUP', NSUP, 'NREL', NREL]
  	RUNDIR = os.path.abspath(__file__ + "/../superlu_dist/build/EXAMPLE")
  	INPUTDIR = os.path.abspath(__file__ + "/../superlu_dist/EXAMPLE/")
  	TUNER_NAME = os.environ['TUNER_NAME']
  	nproc     = int(nprows * npcols)
  
  	""" pass some parameters through environment variables """	
  	info = MPI.Info.Create()
  	envstr= 'OMP_NUM_THREADS=%d\n' %(nthreads)   
  	envstr+= 'NREL=%d\n' %(NREL)   
  	envstr+= 'NSUP=%d\n' %(NSUP)   
  	info.Set('env',envstr)
  	info.Set('npernode','%d'%(npernode))  # YL: npernode is deprecated in openmpi 4.0, but no other parameter (e.g. 'map-by') works
     
  
  	""" use MPI spawn to call the executable, and pass the other parameters and inputs through command line """
  	print('exec', "%s/pddrive_spawn"%(RUNDIR), 'args', ['-c', '%s'%(npcols), '-r', '%s'%(nprows), '-l', '%s'%(LOOKAHEAD), '-p', '%s'%(COLPERM), '%s/%s'%(INPUTDIR,matrix)], 'nproc', nproc, 'env', 'OMP_NUM_THREADS=%d' %(nthreads), 'NSUP=%d' %(NSUP), 'NREL=%d' %(NREL)  )
  	comm = MPI.COMM_SELF.Spawn("%s/pddrive_spawn"%(RUNDIR), args=['-c', '%s'%(npcols), '-r', '%s'%(nprows), '-l', '%s'%(LOOKAHEAD), '-p', '%s'%(COLPERM), '%s/%s'%(INPUTDIR,matrix)], maxprocs=nproc,info=info)
  
  	""" gather the return value using the inter-communicator, also refer to the INPUTDIR/pddrive_spawn.c to see how the return value are communicated """																	
  	tmpdata = array('f', [0,0])
  	comm.Reduce(sendbuf=None, recvbuf=[tmpdata,MPI.FLOAT],op=MPI.MAX,root=mpi4py.MPI.ROOT) 
  	comm.Disconnect()	
  
  	if(target=='time'):	
  		retval = tmpdata[0]
  		print(params, ' superlu time: ', retval)
  
  	if(target=='memory'):	
  		retval = tmpdata[1]
  		print(params, ' superlu memory: ', retval)
  
  	return [retval]
code_tokens: def objectives ( point ) : matrix = point [ 'matrix' ] COLPERM = point [ 'COLPERM' ] LOOKAHEAD = point [ 'LOOKAHEAD' ] nprows = point [ 'nprows' ] nproc = point [ 'nproc' ] NSUP = point [ 'NSUP' ] NREL = point [ 'NREL' ] npernode = math . ceil ( float ( nproc ) / nodes ) nthreads = int ( cores / npernode ) npcols = int ( nproc / nprows ) params = [ matrix , 'COLPERM' , COLPERM , 'LOOKAHEAD' , LOOKAHEAD , 'nthreads' , nthreads , 'npernode' , npernode , 'nprows' , nprows , 'npcols' , npcols , 'NSUP' , NSUP , 'NREL' , NREL ] RUNDIR = os . path . abspath ( __file__ + "/../superlu_dist/build/EXAMPLE" ) INPUTDIR = os . path . abspath ( __file__ + "/../superlu_dist/EXAMPLE/" ) TUNER_NAME = os . environ [ 'TUNER_NAME' ] nproc = int ( nprows * npcols ) info = MPI . Info . Create ( ) envstr = 'OMP_NUM_THREADS=%d\n' % ( nthreads ) envstr += 'NREL=%d\n' % ( NREL ) envstr += 'NSUP=%d\n' % ( NSUP ) info . Set ( 'env' , envstr ) info . Set ( 'npernode' , '%d' % ( npernode ) ) """ use MPI spawn to call the executable, and pass the other parameters and inputs through command line """ print ( 'exec' , "%s/pddrive_spawn" % ( RUNDIR ) , 'args' , [ '-c' , '%s' % ( npcols ) , '-r' , '%s' % ( nprows ) , '-l' , '%s' % ( LOOKAHEAD ) , '-p' , '%s' % ( COLPERM ) , '%s/%s' % ( INPUTDIR , matrix ) ] , 'nproc' , nproc , 'env' , 'OMP_NUM_THREADS=%d' % ( nthreads ) , 'NSUP=%d' % ( NSUP ) , 'NREL=%d' % ( NREL ) ) comm = MPI . COMM_SELF . Spawn ( "%s/pddrive_spawn" % ( RUNDIR ) , args = [ '-c' , '%s' % ( npcols ) , '-r' , '%s' % ( nprows ) , '-l' , '%s' % ( LOOKAHEAD ) , '-p' , '%s' % ( COLPERM ) , '%s/%s' % ( INPUTDIR , matrix ) ] , maxprocs = nproc , info = info ) """ gather the return value using the inter-communicator, also refer to the INPUTDIR/pddrive_spawn.c to see how the return value are communicated """ tmpdata = array ( 'f' , [ 0 , 0 ] ) comm . Reduce ( sendbuf = None , recvbuf = [ tmpdata , MPI . FLOAT ] , op = MPI . MAX , root = mpi4py . MPI . ROOT ) comm . Disconnect ( ) if ( target == 'time' ) : retval = tmpdata [ 0 ] print ( params , ' superlu time: ' , retval ) if ( target == 'memory' ) : retval = tmpdata [ 1 ] print ( params , ' superlu memory: ' , retval ) return [ retval ]
short_docstring: pass some parameters through environment variables
short_docstring_tokens: pass some parameters through environment variables
comment: # should always use this name for user-defined objective function$SEP$""" pass some parameters through environment variables """$SEP$# YL: npernode is deprecated in openmpi 4.0, but no other parameter (e.g. 'map-by') works$SEP$""" use MPI spawn to call the executable, and pass the other parameters and inputs through command line """$SEP$""" gather the return value using the inter-communicator, also refer to the INPUTDIR/pddrive_spawn.c to see how the return value are communicated """