<commit_before>package prog_gen

import com.typesafe.scalalogging.Logger
import ir.TypeChecker
import ir.ast.Lambda
import lift.arithmetic.{ArithExpr, Cst}
import opencl.executor.Eval

object GeneratePrograms {

  private val logger = Logger(this.getClass)

  private val splitFactors = Seq[ArithExpr](64, 128)
  private val inputSizes = Seq[Cst](Cst(512), Cst(1024), Cst(2048))

  def main(args: Array[String]): Unit = {

    val generator = new ProgramGenerator
    val programs = generator.generatePrograms()

    logger.info(s"${programs.length} programs generated.")

    val concretePrograms = programs.flatMap(substituteSplitFactors)

    logger.info(s"$concretePrograms programs with split factors assigned.")


    concretePrograms.foreach(lambda => {
      val vars = lambda.getVarsInParams()

      val sizes = inputSizes.combinations(vars.length)

      sizes.foreach(size => {
        val substitutions = (vars,size).zipped.toMap

        val inputs = InputGenerator(substitutions)(lambda)

      })
    })



  }


  private def substituteSplitFactors(lambda: Lambda): Seq[Lambda] = {

    val nodes = rewriting.utils.Utils.findTunableNodes(lambda)
    val toReplace = nodes.map(rewriting.utils.Utils.extractArithExpr)
    val vars = lambda.getVarsInParams()

    val factory = Eval.getMethod(rewriting.utils.Utils.dumpLambdaToMethod(lambda))

    val replacementCombinations = splitFactors.combinations(toReplace.length)

    replacementCombinations
      .map(combinations => factory(vars ++ combinations))
      .filter(l => try { TypeChecker(l); true } catch { case _: Throwable => false} )
      .toSeq<commit_msg>Fix compilation error<commit_after>package prog_gen

import com.typesafe.scalalogging.Logger
import ir.TypeChecker
import ir.ast.Lambda
import lift.arithmetic.{ArithExpr, Cst}
import opencl.executor.Eval

object GeneratePrograms {

  private val logger = Logger(this.getClass)

  private val splitFactors = Seq[ArithExpr](64, 128)
  private val inputSizes = Seq[Cst](Cst(512), Cst(1024), Cst(2048))

  def main(args: Array[String]): Unit = {

    val generator = new ProgramGenerator
    val programs = generator.generatePrograms()

    logger.info(s"${programs.length} programs generated.")

    val concretePrograms = programs.flatMap(substituteSplitFactors)

    logger.info(s"$concretePrograms programs with split factors assigned.")


    concretePrograms.foreach(lambda => {
      val vars = lambda.getVarsInParams()

      val sizes = inputSizes.combinations(vars.length)

      sizes.foreach(size => {
        val substitutions = (vars,size).zipped.toMap[ArithExpr, Cst]

        val inputs = InputGenerator(substitutions)(lambda)

      })
    })



  }


  private def substituteSplitFactors(lambda: Lambda): Seq[Lambda] = {

    val nodes = rewriting.utils.Utils.findTunableNodes(lambda)
    val toReplace = nodes.map(rewriting.utils.Utils.extractArithExpr)
    val vars = lambda.getVarsInParams()

    val factory = Eval.getMethod(rewriting.utils.Utils.dumpLambdaToMethod(lambda))

    val replacementCombinations = splitFactors.combinations(toReplace.length)

    replacementCombinations
      .map(combinations => factory(vars ++ combinations))
      .filter(l => try { TypeChecker(l); true } catch { case _: Throwable => false} )
      .toSeq
{'fraction_non_alphanumeric': 0.1060790273556231, 'fraction_numerical': 0.009726443768996961, 'mean_word_length': 4.063076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6527642', 'n_tokens_mistral': 1047, 'n_tokens_neox': 980, 'n_words': 202}