text: import os, sys, subprocess, random
  
  class Plopper:
      def __init__(self,sourcefile,outputdir):
  
          # Initilizing global variables
          self.sourcefile = sourcefile
          self.outputdir = outputdir+"/tmp_files"
  
          if not os.path.exists(self.outputdir):
              os.makedirs(self.outputdir)
  
      #Creating a dictionary using parameter label and value
      def createDict(self, x, params):
          dictVal = {}
          for p, v in zip(params, x):
              dictVal[p] = v
          return(dictVal)
      
      # Function to find the execution time of the interim file, and return the execution time as cost to the search module
      def findRuntime(self, x, params):
          interimfile = ""
          exetime = 1
          
          # Generate intermediate file
          dictVal = self.createDict(x, params)
  
          #compile and find the execution time
          tmpbinary = self.outputdir + '/tmp.bin'
          kernel_idx = self.sourcefile.rfind('/')
          kernel_dir = self.sourcefile[:kernel_idx]
          gcc_cmd = 'g++ ' + kernel_dir +'/mmm_block.cpp '
          gcc_cmd += ' -D{0}={1}'.format('BLOCK_SIZE', dictVal['BLOCK_SIZE'])
          gcc_cmd += ' -o ' + tmpbinary
          run_cmd = kernel_dir + "/exe.pl " + tmpbinary
  
          #Find the compilation status using subprocess
          compilation_status = subprocess.run(gcc_cmd, shell=True, stderr=subprocess.PIPE)
  
          #Find the execution time only when the compilation return code is zero, else return infinity
          if compilation_status.returncode == 0 :
              execution_status = subprocess.run(run_cmd, shell=True, stdout=subprocess.PIPE)
              exetime = float(execution_status.stdout.decode('utf-8'))
              if exetime == 0:
                  exetime = 1
          else:
              print(compilation_status.stderr)
              print("compile failed")
          return exetime #return execution time as cost
  
  