-- ULGY FIX
executep mode program list = exec
    where 
      exec = do 
        tmp_dir <- getTemporaryDirectory
        let fullpath = tmp_dir ++ pathSeparator : "GPU-HASKELL"
        createDirectoryIfMissing False fullpath
        -- genCudaProjectL n (div n threads) fullpath name program list
        writeFile (fullpath ++ (pathSeparator : name) ++ ".cu") 
                      (test2 program list) 
        writeFile (fullpath ++ (pathSeparator : "Makefile")) 
                      (genMakefile name)
        working_dir <- getCurrentDirectory 
        setCurrentDirectory fullpath
        pid1 <- case mode of 
                  GPU -> runCommand "make -s"
                  EMU -> runCommand "make emulation -s"
        waitForProcess pid1 -- make sure the executable is generated
        pid2 <- runCommand (fullpath ++ pathSeparator:name ++ " > output.txt")
        waitForProcess pid2 -- make sure output is generated 
        result <- readOutput (fullpath ++ pathSeparator:"output.txt" )
        setCurrentDirectory working_dir
        --removeDirectoryRecursive fullpath
        return result
      n = length list
      name = "generated"
      --readOutput :: Name -> IO [(Exp b,Exp c)]
      readOutput file = 
          do 
            string  <- readFile file 
            let strings = words string
                [s1,s2] = splits "SEPARATOR" strings
                eb = map scan (s1)
                ec = map scan (s2) 
            return (zip eb ec)
executep mode program list = exec
    where 
      exec = do 
        tmp_dir <- getTemporaryDirectory
        let fullpath = tmp_dir ++ pathSeparator : "GPU-HASKELL"
        createDirectoryIfMissing False fullpath
        -- genCudaProjectL n (div n threads) fullpath name program list
        writeFile (fullpath ++ (pathSeparator : name) ++ ".cu") 
                      (test2 program list) 
        writeFile (fullpath ++ (pathSeparator : "Makefile")) 
                      (genMakefile name)
        working_dir <- getCurrentDirectory 
        setCurrentDirectory fullpath
        pid1 <- case mode of 
                  GPU -> runCommand "make -s"
                  EMU -> runCommand "make emulation -s"
        waitForProcess pid1 -- make sure the executable is generated
        pid2 <- runCommand (fullpath ++ pathSeparator:name ++ " > output.txt")
        waitForProcess pid2 -- make sure output is generated 
        result <- readOutput (fullpath ++ pathSeparator:"output.txt" )
        setCurrentDirectory working_dir
        --removeDirectoryRecursive fullpath
        return result
      n = length list
      name = "generated"
      --readOutput :: Name -> IO [(Exp b,Exp c)]
      readOutput file = 
          do 
            string  <- readFile file 
            let strings = words string
                [s1,s2] = splits "SEPARATOR" strings
                eb = map scan (s1)
                ec = map scan (s2) 
            return (zip eb ec)
executep mode program list = exec
    where 
      exec = do 
        tmp_dir <- getTemporaryDirectory
        let fullpath = tmp_dir ++ pathSeparator : "GPU-HASKELL"
        createDirectoryIfMissing False fullpath
        -- genCudaProjectL n (div n threads) fullpath name program list
        writeFile (fullpath ++ (pathSeparator : name) ++ ".cu") 
                      (test2 program list) 
        writeFile (fullpath ++ (pathSeparator : "Makefile")) 
                      (genMakefile name)
        working_dir <- getCurrentDirectory 
        setCurrentDirectory fullpath
        pid1 <- case mode of 
                  GPU -> runCommand "make -s"
                  EMU -> runCommand "make emulation -s"
        waitForProcess pid1 -- make sure the executable is generated
        pid2 <- runCommand (fullpath ++ pathSeparator:name ++ " > output.txt")
        waitForProcess pid2 -- make sure output is generated 
        result <- readOutput (fullpath ++ pathSeparator:"output.txt" )
        setCurrentDirectory working_dir
        --removeDirectoryRecursive fullpath
        return result
      n = length list
      name = "generated"
      --readOutput :: Name -> IO [(Exp b,Exp c)]
      readOutput file = 
          do 
            string  <- readFile file 
            let strings = words string
                [s1,s2] = splits "SEPARATOR" strings
                eb = map scan (s1)
                ec = map scan (s2) 
            return (zip eb ec)